]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix function overrides in unit tests on macOS
authorMichał Kępień <michal@isc.org>
Mon, 28 Sep 2020 07:16:48 +0000 (09:16 +0200)
committerMichał Kępień <michal@isc.org>
Mon, 28 Sep 2020 07:16:48 +0000 (09:16 +0200)
Since Mac OS X 10.1, Mach-O object files are by default built with a
so-called two-level namespace which prevents symbol lookups in BIND unit
tests that attempt to override the implementations of certain library
functions from working as intended.  This feature can be disabled by
passing the "-flat_namespace" flag to the linker.  Fix unit tests
affected by this issue on macOS by adding "-flat_namespace" to LDFLAGS
used for building all object files on that operating system (it is not
enough to only set that flag for the unit test executables).

configure
configure.ac

index e5acb387942fb19e8c16e213a3e948e9614cc4a2..deb7f36a75e84ba2fce11280adcfc612b35bf552 100755 (executable)
--- a/configure
+++ b/configure
@@ -13629,6 +13629,8 @@ $as_echo "$as_me: WARNING: When using GNU C Compiler on Solaris, -zrelax=transtl
 
 fi
         ;; #(
+  *-darwin*) :
+    LDFLAGS="$LDFLAGS -Wl,-flat_namespace" ;; #(
   *) :
      ;;
 esac
index f262a57c1961778295945034a2ef377227fc004b..4aaae5b0486b1d5aac35e7094afc4246a3d87a18 100644 (file)
@@ -382,7 +382,8 @@ AS_CASE([$host],
                  [LDFLAGS="$LDFLAGS -zrelax=transtls"
                   AC_MSG_WARN([When using GNU C Compiler on Solaris, -zrelax=transtls linker flag is used to fix bug in Thread Local Storage])
                  ])
-       ])
+       ],
+       [*-darwin*],[LDFLAGS="$LDFLAGS -Wl,-flat_namespace"])
 
 #
 # CCNOOPT defaults to -O0 on gcc and disables optimization when is last