Enhance cross-compilation support for FastFinder; add ARM64 and i386 … #88
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: fastfinder_build_linux | |
| on: [push, pull_request] | |
| jobs: | |
| linux_standard-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| bison \ | |
| flex \ | |
| autoconf \ | |
| pkg-config \ | |
| automake \ | |
| libtool \ | |
| gcc-aarch64-linux-gnu \ | |
| libc6-dev-arm64-cross \ | |
| gcc-i686-linux-gnu \ | |
| libc6-dev-i386-cross \ | |
| qemu-user-static \ | |
| - name: Set up Go | |
| uses: actions/setup-go@v2 | |
| with: | |
| go-version: 1.24 | |
| - name: Install YARA v4.5.5 (AMD64) | |
| run: | | |
| YARA_VERSION=4.5.5 | |
| wget --no-verbose -O- https://github.com/VirusTotal/yara/archive/v${YARA_VERSION}.tar.gz | tar -C /tmp -xzf - | |
| cd /tmp/yara-${YARA_VERSION} && ./bootstrap.sh && sudo ./configure && sudo make && sudo make install | |
| - name: Install YARA v4.5.5 (ARM64) | |
| run: | | |
| YARA_VERSION=4.5.5 | |
| # Uses previously unpacked source if available, or fetch again | |
| [ -d "/tmp/yara-${YARA_VERSION}" ] || wget --no-verbose -O- https://github.com/VirusTotal/yara/archive/v${YARA_VERSION}.tar.gz | tar -C /tmp -xzf - | |
| cd /tmp/yara-${YARA_VERSION} | |
| make clean || true | |
| ./bootstrap.sh | |
| # Build static ARM64 without OpenSSL for simplicity in CI | |
| ./configure --host=aarch64-linux-gnu --prefix=/usr/local/aarch64 --enable-static --disable-shared --disable-crypto | |
| make -j$(nproc) | |
| sudo make install | |
| - name: Install YARA v4.5.5 (i386) | |
| run: | | |
| YARA_VERSION=4.5.5 | |
| [ -d "/tmp/yara-${YARA_VERSION}" ] || wget --no-verbose -O- https://github.com/VirusTotal/yara/archive/v${YARA_VERSION}.tar.gz | tar -C /tmp -xzf - | |
| cd /tmp/yara-${YARA_VERSION} | |
| make clean || true | |
| ./bootstrap.sh | |
| ./configure --host=i686-linux-gnu --prefix=/usr/local/i686 --enable-static --disable-shared --disable-crypto | |
| make -j$(nproc) | |
| sudo make install | |
| - uses: actions/checkout@v2 | |
| - name: Run Unit Tests | |
| run: | | |
| sudo ldconfig | |
| # Test AMD64 | |
| go test ./... -v | |
| - name: Building Fastfinder AMD64 | |
| run: | | |
| go build -trimpath -tags yara_static -a -ldflags '-s -w -extldflags "-static"' -o fastfinder-amd64 . | |
| ls -l fastfinder-amd64 | |
| sudo chmod +x fastfinder-amd64 | |
| sudo ./fastfinder-amd64 -h | |
| - name: Building Fastfinder ARM64 | |
| run: | | |
| export CGO_ENABLED=1 | |
| export GOOS=linux | |
| export GOARCH=arm64 | |
| export CC=aarch64-linux-gnu-gcc | |
| export CGO_CFLAGS="-I/usr/local/aarch64/include" | |
| export CGO_LDFLAGS="-L/usr/local/aarch64/lib -lyara -static" | |
| go build -trimpath -tags yara_static -a -ldflags '-s -w -extldflags "-static"' -o fastfinder-arm64 . | |
| ls -l fastfinder-arm64 | |
| sudo chmod +x fastfinder-arm64 | |
| # Verify execution via QEMU | |
| ./fastfinder-arm64 -h | |
| - name: Building Fastfinder i386 | |
| run: | | |
| export CGO_ENABLED=1 | |
| export GOOS=linux | |
| export GOARCH=386 | |
| export CC=i686-linux-gnu-gcc | |
| export CGO_CFLAGS="-I/usr/local/i686/include" | |
| export CGO_LDFLAGS="-L/usr/local/i686/lib -lyara -static" | |
| go build -trimpath -tags yara_static -a -ldflags '-s -w -extldflags "-static"' -o fastfinder-386 . | |
| ls -l fastfinder-386 | |
| sudo chmod +x fastfinder-386 | |
| # Verify execution (native usually works on AMD64) | |
| ./fastfinder-386 -h |