From 197fc9eb778791665f81b35a3817527cc4f0810c Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Sun, 5 Jan 2020 23:07:14 +0800 Subject: 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. --- gusb/libgusb_meson.ver | 7 +++++++ gusb/meson.build | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 gusb/libgusb_meson.ver 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', -- cgit v1.2.1