Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build yara static lib with a musl-gcc for rust project #153

Open
fivlao opened this issue Apr 26, 2023 · 0 comments
Open

Build yara static lib with a musl-gcc for rust project #153

fivlao opened this issue Apr 26, 2023 · 0 comments
Assignees
Labels

Comments

@fivlao
Copy link

fivlao commented Apr 26, 2023

I am trying to build yara static lib with a musl-gcc for my rust project. But when it is running

CC="musl-gcc"  \
CFLAGS="-I/usr/local/musl/include -I/usr/include/linux -I/usr/include/x86_64-linux-musl"  \
LDFLAGS="-L/usr/local/musl/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-musl"  \
./configure \
  --with-crypto \
    --enable-magic \
    --enable-cuckoo \
    --enable-dotnet

it return me error "configure: error: pthread API support is required". Details output

checking for the pthreads library -lpthreads... no
checking whether pthreads work without any flags... no
checking whether pthreads work with -Kthread... no
checking whether pthreads work with -kthread... no
checking for the pthreads library -llthread... no
checking whether pthreads work with -pthread... no
checking whether pthreads work with -pthreads... no
checking whether pthreads work with -mthreads... no
checking for the pthreads library -lpthread... no
checking whether pthreads work with --thread-safe... no
checking whether pthreads work with -mt... no
checking for pthread-config... no 	

Dockerfile

FROM ekidd/rust-musl-builder
USER root

ENV JANSSON_VERSION 2.14
ENV YARA_VERSION 4.3.1

RUN apt-get update

RUN cd /tmp \
    && curl -LO https://github.com/akheron/jansson/releases/download/v2.14/jansson-${JANSSON_VERSION}.tar.gz \
    && tar -zxf jansson-${JANSSON_VERSION}.tar.gz \
    && cd /tmp/jansson-$JANSSON_VERSION \
    && CC="musl-gcc" CFLAGS="-fPIC" ./configure --prefix=/usr/local/musl --host=x86_64-linux-musl --disable-shared \
    && make \
    && make check \
    && make install \
    && cd /tmp \
    && rm -r jansson-$JANSSON_VERSION

RUN cd /tmp \
    && curl -LO https://github.com/VirusTotal/yara/archive/refs/tags/v${YARA_VERSION}.tar.gz \
    && tar -zxf v${YARA_VERSION}.tar.gz

WORKDIR /tmp/yara-$YARA_VERSION

RUN apt-get install -y --no-install-recommends libmagic-dev \
    automake \
    libtool \
    autoconf

RUN ./bootstrap.sh \
    && CC="musl-gcc"  \
    CFLAGS="-I/usr/local/musl/include -I/usr/include/linux -I/usr/include/x86_64-linux-musl"  \
    LDFLAGS="-L/usr/local/musl/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/x86_64-linux-musl"  \
    ./configure \
      --with-crypto \
        --enable-magic \
        --enable-cuckoo \
        --enable-dotnet  \
    && sudo make depend \
    && sudo make -j$(nproc) \
    && sudo make install \
    && rm -r /tmp/yara-$YARA_VERSION

I tried add path pthread header to CFLAGS and add path pthread static lib to LDFLAGS but it did not help

About CFLAGS:
/usr/local/musl/include - path to jansson headers
/usr/include/linux - path to libmagic headers
/usr/include/x86_64-linux-musl - path to pthread header (it did not help 🥲)

About LDFLAGS:
/usr/local/musl/lib - path to jansson static lib
/usr/lib/x86_64-linux-gnu - path to libmagic static lib
/usr/lib/x86_64-linux-musl - path to pthread static lib (it also did not help 😭)

docker build command: docker build . -f ./Dockerfile -t yara-build-image:latest

Maybe who knows how to fix this problem and build yara static lib

@fivlao fivlao added the bug label Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants