From 33e9cda847836c08808f4cc6af3bc40fae12852c Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Sun, 2 Jan 2022 12:54:10 +0100 Subject: [PATCH] valgrind: fix build for non-aarch64 arches as well Valgrind seem to work fine after the memcpy overrides have been removed, but as always I don't really know what I am doing. --- packages/valgrind/android-memcpy.patch | 39 ++++++++++++++++++++++++++ packages/valgrind/build.sh | 5 ++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 packages/valgrind/android-memcpy.patch diff --git a/packages/valgrind/android-memcpy.patch b/packages/valgrind/android-memcpy.patch new file mode 100644 index 000000000..f7db1b937 --- /dev/null +++ b/packages/valgrind/android-memcpy.patch @@ -0,0 +1,39 @@ +When we link against clang's builtin library +(LDFLAGS+=" $($CC print-libgcc-file-name)") we get errors like: + + errors.o ../coregrind/libcoregrind-arm-linux.a ../VEX/libvex-arm-linux.a -lgcc ../coregrind/libgcc-sup-arm-linux.a + ld: error: duplicate symbol: __aeabi_memcpy + >>> defined at aeabi_memcpy.S.o:(__aeabi_memcpy) in archive /home/builder/.termux-build/_cache/android-r23b-api-24-v5/lib64/clang/12.0.8/lib/linux/libclang_rt.builtins-arm-android.a + >>> defined at m_main.c:2602 (/home/builder/.termux-build/valgrind/src/coregrind/m_main.c:2602) + >>> libnolto_coregrind_arm_linux_a-m_main.o:(.text+0x5A1C) in archive ../coregrind/libcoregrind-arm-linux.a + +Hopefully it is fine to remove these overrides now. + +--- ./coregrind/m_main.c.orig 2022-01-02 12:15:07.892429627 +0100 ++++ ./coregrind/m_main.c 2022-01-02 12:24:20.961799164 +0100 +@@ -2595,25 +2595,6 @@ + || defined(VGPV_mips32_linux_android) \ + || defined(VGPV_arm64_linux_android)) + +-/* Replace __aeabi_memcpy* functions with vgPlain_memcpy. */ +-void *__aeabi_memcpy(void *dest, const void *src, SizeT n); +-void *__aeabi_memcpy(void *dest, const void *src, SizeT n) +-{ +- return VG_(memcpy)(dest, src, n); +-} +- +-void *__aeabi_memcpy4(void *dest, const void *src, SizeT n); +-void *__aeabi_memcpy4(void *dest, const void *src, SizeT n) +-{ +- return VG_(memcpy)(dest, src, n); +-} +- +-void *__aeabi_memcpy8(void *dest, const void *src, SizeT n); +-void *__aeabi_memcpy8(void *dest, const void *src, SizeT n) +-{ +- return VG_(memcpy)(dest, src, n); +-} +- + /* Replace __aeabi_memclr* functions with vgPlain_memset. */ + void *__aeabi_memclr(void *dest, SizeT n); + void *__aeabi_memclr(void *dest, SizeT n) diff --git a/packages/valgrind/build.sh b/packages/valgrind/build.sh index 8c0f5ad7d..1e86630cc 100644 --- a/packages/valgrind/build.sh +++ b/packages/valgrind/build.sh @@ -10,6 +10,9 @@ TERMUX_PKG_REPLACES="valgrind-dev" TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-tmpdir=$TERMUX_PREFIX/tmp" termux_step_pre_configure() { + CFLAGS=${CFLAGS/-fstack-protector-strong/} + LDFLAGS+=" $($CC -print-libgcc-file-name)" + if [ "$TERMUX_ARCH" == "aarch64" ]; then cp $TERMUX_PKG_BUILDER_DIR/aarch64-setjmp.S $TERMUX_PKG_SRCDIR autoreconf -if @@ -21,6 +24,4 @@ termux_step_pre_configure() { # "valgrind uses inline assembly that is not Thumb compatible": CFLAGS=${CFLAGS/-mthumb/} fi - - CFLAGS=${CFLAGS/-fstack-protector-strong/} }