diff --git a/3rdparty.mk b/3rdparty.mk index 18dbc98..3bd3339 100644 --- a/3rdparty.mk +++ b/3rdparty.mk @@ -9,14 +9,24 @@ endef # Determine host architecture: 3rdparty_NATIVE_ARCH := $(shell cc -dumpmachine) # Determine target architectures: -# On Linux, we can cross-build for Linux and Windows. -# On MacOSX, we can only build for MacOSX. +# On Linux, we can cross-build for Windows. +# On other systems, we only build for the respective host architecture $(or \ - $(if $(or $(findstring -linux-gnu,$(3rdparty_NATIVE_ARCH)),\ - $(findstring -redhat-linux,$(3rdparty_NATIVE_ARCH))),\ - $(eval 3rdparty_ARCHS=i386-linux-musl x86_64-linux-musl i686-w64-mingw32 x86_64-w64-mingw32)\ + $(if $(or $(findstring x86_64-linux-gnu,$(3rdparty_NATIVE_ARCH)),\ + $(findstring x86_64-redhat-linux,$(3rdparty_NATIVE_ARCH))),\ + $(eval 3rdparty_ARCHS=\ + i386-linux-musl x86_64-linux-musl \ + i686-w64-mingw32 x86_64-w64-mingw32)\ $(foreach arch,i686-w64-mingw32 x86_64-w64-mingw32,\ $(if $(not $(shell which $(arch)-gcc)),$(error $(arch)-gcc not found)))),\ + $(if $(findstring -linux-gnu,$(3rdparty_NATIVE_ARCH)),\ + $(eval 3rdparty_ARCHS=\ + $(patsubst %-linux-gnu,%-linux-musl,$(3rdparty_NATIVE_ARCH)) \ + i686-w64-mingw32 x86_64-w64-mingw32)\ + $(foreach arch,i686-w64-mingw32 x86_64-w64-mingw32,\ + $(if $(not $(shell which $(arch)-gcc)),$(error $(arch)-gcc not found)))),\ + $(if $(or $(findstring -linux-gnu,$(3rdparty_NATIVE_ARCH))),\ + $(eval 3rdparty_ARCHS=$(patsubst %-linux-gnu,%-linux-musl,$(3rdparty_NATIVE_ARCH)))),\ $(if $(or $(findstring -apple-darwin,$(3rdparty_NATIVE_ARCH)),\ $(findstring -freebsd,$(3rdparty_NATIVE_ARCH))),\ $(eval 3rdparty_ARCHS=$(3rdparty_NATIVE_ARCH))),\ @@ -48,6 +58,7 @@ yara_PREP := ./bootstrap.sh musl_VERSION := 1.2.5 musl_URL := https://musl.libc.org/releases/musl-$(musl_VERSION).tar.gz musl_ARCHS := $(filter %-linux-musl,$(3rdparty_ARCHS)) +musl_PATCHES := getauxval.patch openssl_VERSION := 1.1.1w openssl_URL := https://www.openssl.org/source/openssl-$(openssl_VERSION).tar.gz @@ -55,8 +66,8 @@ openssl_ARCHS := $(3rdparty_ARCHS) # Declare dependencies $(eval $(call DEPENDS,yara,openssl,)) -$(eval $(call DEPENDS,yara,musl,i386-linux-musl x86_64-linux-musl)) -$(eval $(call DEPENDS,openssl,musl,i386-linux-musl x86_64-linux-musl)) +$(eval $(call DEPENDS,yara,musl,i386-linux-musl x86_64-linux-musl aarch64-linux-musl)) +$(eval $(call DEPENDS,openssl,musl,i386-linux-musl x86_64-linux-musl aarch64-linux-musl)) # Rules/Templates # --------------- @@ -103,7 +114,8 @@ _3rdparty/build/$1/musl-$(musl_VERSION)/.build-stamp: _3rdparty/src/musl-$(musl_ --syslibdir=$(abspath _3rdparty/tgt/$1/lib) \ CC=gcc \ CROSS_COMPILE= \ - CFLAGS="-fPIC $(if $(findstring x86_64,$1),-m64,-m32)" + CFLAGS="-fPIC $(or $(if $(findstring x86_64,$1),-m64),\ + $(if $(or $(findstring i386,$1),$(findstring i686,$1)),-m32))" $(MAKE) -s -j$(3rdparty_JOBS) -C $$(@D) AR=ar RANLIB=ranlib $(MAKE) -s -C $$(@D) install $(abspath _3rdparty)/patch-musl-spec.sh $(abspath _3rdparty/tgt/$1) @@ -117,6 +129,7 @@ endef # Out-of-tree build for yara, architecture $1, with dependency on musl # where appropriate define build_yara_TEMPLATE +_3rdparty/build/$1/yara-$(yara_VERSION)/.build-stamp: export PKG_CONFIG_PATH=$(abspath _3rdparty/tgt/$1/lib/pkgconfig) _3rdparty/build/$1/yara-$(yara_VERSION)/.build-stamp: _3rdparty/src/yara-$(yara_VERSION)/.unpack-stamp @mkdir -p $$(@D) cd $$(@D) && $$(abspath $$( +Date: Thu, 12 Oct 2023 20:31:48 +0200 +From: Szabolcs Nagy +To: musl@...ts.openwall.com +Subject: [PATCH] make __getauxval a public ABI symbol + +This is needed so that libgcc can access AT_HWCAP without violating +link namespace rules. + +Internally musl already used __getauxval symbol for the same reason, +we just remove the hidden marking. + +Currently libgcc only uses __getauxval on aarch64 for outline atomics +and only on glibc, but there is plan to add more usage (this time in +the unwinder) which may cause link failure on musl in the future. +(libgcc cannot easily check for libc symbols due to bootstrap order, +the feature could be unconditionally disabled for *-linux-musl, but +it's probably more future proof to provide the symbol.) +--- + src/include/sys/auxv.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/include/sys/auxv.h b/src/include/sys/auxv.h +index 9358a4a5..63c5bfe9 100644 +--- a/src/include/sys/auxv.h ++++ b/src/include/sys/auxv.h +@@ -5,6 +5,6 @@ + + #include + +-hidden unsigned long __getauxval(unsigned long); ++unsigned long __getauxval(unsigned long); + + #endif +-- +2.41.0