From: Rhys Kidd Date: Tue, 29 Jan 2019 06:07:09 +0000 (-0500) Subject: memcheck,macos: Fix vbit-test building on macOS x86 architectures. n-i-bz. X-Git-Tag: VALGRIND_3_15_0~83 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5cd48eed00ffe0d7e05598787f2ec70e0fd8239e;p=thirdparty%2Fvalgrind.git memcheck,macos: Fix vbit-test building on macOS x86 architectures. n-i-bz. Secondary architectures on macOS are generally x86, which requires additional LDFLAGS to be set to avoid linker errors. apple clang (clang-800.0.42.1) error: ld: illegal text-relocation to '___stderrp' in /usr/lib/libSystem.dylib from '_main' in vbit_test_sec-main.o for architecture i386 Fixes: 49ca185 ("Also test memcheck/tests/vbit-test on any secondary arch.") Signed-off-by: Rhys Kidd --- diff --git a/memcheck/tests/vbit-test/Makefile.am b/memcheck/tests/vbit-test/Makefile.am index b679683d8c..d3bc4c51ff 100644 --- a/memcheck/tests/vbit-test/Makefile.am +++ b/memcheck/tests/vbit-test/Makefile.am @@ -37,6 +37,12 @@ SOURCES = \ irops.c \ valgrind.c +# The link flags for this are tricky, because we want to build it for +# both the primary and secondary platforms, and add +# "-Wl,-read_only_relocs -Wl,suppress" to whichever of those is x86-darwin, +# if any. Hence there's a double-nested conditional that adds to the +# LDFLAGS in both cases. + vbit_test_SOURCES = $(SOURCES) vbit_test_CPPFLAGS = $(AM_CPPFLAGS_PRI) \ -I$(top_srcdir)/include \ @@ -46,6 +52,13 @@ vbit_test_CFLAGS = $(AM_CFLAGS_PRI) vbit_test_DEPENDENCIES = vbit_test_LDADD = $(top_builddir)/VEX/libvex-@VGCONF_ARCH_PRI@-@VGCONF_OS@.a vbit_test_LDFLAGS = $(AM_CFLAGS_PRI) @LIB_UBSAN@ +# If there is no secondary platform, and the platforms include x86-darwin, +# then the primary platform must be x86-darwin. Hence: +if ! VGCONF_HAVE_PLATFORM_SEC +if VGCONF_PLATFORMS_INCLUDE_X86_DARWIN +vbit_test_LDFLAGS += -Wl,-read_only_relocs -Wl,suppress +endif +endif if VGCONF_HAVE_PLATFORM_SEC vbit_test_sec_SOURCES = $(SOURCES) @@ -62,3 +75,11 @@ vbit_test_sec_LDADD = $(top_builddir)/VEX/libvex-@VGCONF_ARCH_SEC@-@VGCON vbit_test_sec_LDFLAGS = $(AM_CFLAGS_SEC) @LIB_UBSAN@ \ $(TOOL_LDFLAGS_@VGCONF_PLATFORM_SEC_CAPS@) endif +# If there is a secondary platform, and the platforms include x86-darwin, +# then the primary platform must be amd64-darwin and the secondary platform +# must be x86-darwin. Hence: +if VGCONF_HAVE_PLATFORM_SEC +if VGCONF_PLATFORMS_INCLUDE_X86_DARWIN +vbit_test_sec_LDFLAGS += -Wl,-read_only_relocs -Wl,suppress +endif +endif