|
From: Rhys K. <rhy...@so...> - 2019-01-29 12:55:40
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=5cd48eed00ffe0d7e05598787f2ec70e0fd8239e commit 5cd48eed00ffe0d7e05598787f2ec70e0fd8239e Author: Rhys Kidd <rhy...@gm...> Date: Tue Jan 29 01:07:09 2019 -0500 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 <rhy...@gm...> Diff: --- memcheck/tests/vbit-test/Makefile.am | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/memcheck/tests/vbit-test/Makefile.am b/memcheck/tests/vbit-test/Makefile.am index b679683..d3bc4c5 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 |