summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw@src.gnome.org>2020-01-05 23:07:14 +0800
committerRichard Hughes <richard@hughsie.com>2021-10-10 16:56:35 +0100
commit197fc9eb778791665f81b35a3817527cc4f0810c (patch)
treed565669b311f55b34c018565e916227f08e80784
parent2b2efe3887dafc844584ab57d14a69524f5dc45b (diff)
downloadgusb-197fc9eb778791665f81b35a3817527cc4f0810c.tar.gz
Fix version script check for GNU BFD linker on FreeBSD
On FreeBSD, symbols 'environ' and ' __progname' are defined in crt1.o and referenced by libc.so. This makes it different from platforms which define 'environ' in libc.so. GNU BFD linker fails to link an executable if these two symbols are not put into the global section of the version script because a shared library should not reference a local symbol defined in a different object file. GNU gold and LLVM LLD don't have the problem. This means the current check for --version-script fails on FreeBSD when GNU BFD linker is used. The failure can be avoided by linking a shared library instead of an executable, but meson doesn't support passing additional arguments to the compiler in its 'has_link_argument' method. Instead of adding these two unused symbols to the real version script, use a smaller version script specifically made for the test.
-rw-r--r--gusb/libgusb_meson.ver7
-rw-r--r--gusb/meson.build5
2 files changed, 10 insertions, 2 deletions
diff --git a/gusb/libgusb_meson.ver b/gusb/libgusb_meson.ver
new file mode 100644
index 0000000..91f1fae
--- /dev/null
+++ b/gusb/libgusb_meson.ver
@@ -0,0 +1,7 @@
+LIBGUSB_0.1.0 {
+ global:
+ g_usb_*;
+ environ;
+ __progname;
+ local: *;
+};
diff --git a/gusb/meson.build b/gusb/meson.build
index c01bbed..b4fa382 100644
--- a/gusb/meson.build
+++ b/gusb/meson.build
@@ -43,10 +43,11 @@ install_headers([
)
mapfile = 'libgusb.ver'
+mapfile_test = 'libgusb_meson.ver'
vflag = []
-vflag_test = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
+vflag_test = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile_test)
if cc.has_link_argument(vflag_test)
- vflag += vflag_test
+ vflag += '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
endif
gusb = library(
'gusb',