]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3729] Added check for environ vs shlib
authorFrancis Dupont <fdupont@isc.org>
Wed, 5 Feb 2025 15:16:17 +0000 (16:16 +0100)
committerAndrei Pavel <andrei@isc.org>
Thu, 13 Feb 2025 08:05:19 +0000 (10:05 +0200)
compiler-checks/environ-in-shlib.cc [new file with mode: 0644]
meson.build
src/lib/asiolink/meson.build

diff --git a/compiler-checks/environ-in-shlib.cc b/compiler-checks/environ-in-shlib.cc
new file mode 100644 (file)
index 0000000..d50947a
--- /dev/null
@@ -0,0 +1,5 @@
+extern char **environ;
+
+char** fn() {
+    return environ;
+}
index 14cfb33e5df023f123d3d22a500f28ab7cb02df4..a66738c2119d4e7b5f872d0979c4b76640dbdd71 100644 (file)
@@ -269,6 +269,18 @@ result = cpp.run(
 )
 conf_data.set('HAVE_STREAM_TRUNCATED_ERROR', result.returncode() == 0)
 
+ENVIRON_SHLIB_FLAGS = []
+if cpp.has_link_argument('-Wl,--no-undefined')
+    result = cpp.links(
+        fs.read('compiler-checks/environ-in-shlib.cc'),
+        name: 'ENVIRON_SHLIB_FLAGS',
+        args: ['--shared', '-fPIC', '-Wl,--no-undefined'],
+    )
+    if not result
+        ENVIRON_SHLIB_FLAGS += ['b_lundef=false']
+    endif
+endif
+
 #### System-specific Variables
 
 SYSTEM = build_machine.system()
index 6c271a2b56fc03f7ae357560d53a4dd50d34eba8..6dbfa4928e592501f47919e54d1adae22cbc89ea 100644 (file)
@@ -19,8 +19,7 @@ kea_asiolink_lib = library(
     install: true,
     install_dir: 'lib',
     link_with: LIBS_BUILT_SO_FAR,
-    # The only way to avoid on FreeBSD: ld: error: undefined symbol: environ
-    override_options: ['b_lundef=false'],
+    override_options: ENVIRON_SHLIB_FLAGS,
 )
 LIBS_BUILT_SO_FAR = [kea_asiolink_lib] + LIBS_BUILT_SO_FAR
 subdir('testutils')