]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
memcheck,macos: Fix vbit-test building on macOS x86 architectures. n-i-bz.
authorRhys Kidd <rhyskidd@gmail.com>
Tue, 29 Jan 2019 06:07:09 +0000 (01:07 -0500)
committerRhys Kidd <rhyskidd@gmail.com>
Tue, 29 Jan 2019 06:34:27 +0000 (01:34 -0500)
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 <rhyskidd@gmail.com>
memcheck/tests/vbit-test/Makefile.am

index b679683d8c3e9701cc81b039699622e24a86717a..d3bc4c51ffcb1f9f6483dddc9380eeff84d8fafd 100644 (file)
@@ -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