Applying version map to executables breaks nix on FreeBSD
I'm trying to package libwnck with nix on FreeBSD and have encountered the following error while building:
/nix/store/q6byj644j3x7dsd3zkja41db8iq5j8zd-binutils-2.40/bin/ld: libwnck/wnckprop: local symbol `__progname' in /nix/store/58yvb7l3lkli2knf31dx38ng9br0srj4-libc-14.0/lib/crt1.o is referenced by DSO
/nix/store/q6byj644j3x7dsd3zkja41db8iq5j8zd-binutils-2.40/bin/ld: final link failed: bad value
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
This error is duplicated for each executable program. This is an expected error if you actually do try to link __progname
into a DSO on FreeBSD, but we're not linking a DSO, we're linking an executable. I found that for whatever reason, the compiler here has decided that the use of a version map with local symbols forces the executable to become a DSO. The fix I came up with for this is to make the version map only apply to the shared objects:
--- libwnck-43.0/libwnck/meson.build.orig 2024-02-27 16:59:16.524416000 +0000
+++ libwnck-43.0/libwnck/meson.build 2024-02-27 17:04:36.368760000 +0000
@@ -118,7 +118,6 @@
dependencies: LIBWNCK_DEPS,
compile_args: libwnck_cflags,
sources: headers + [enum_types[1]],
- link_args: libwnck_ldflags,
)
libwnck_lib = shared_library(LIBNAME,
@@ -126,6 +125,7 @@
sources: sources + a11y_sources + enum_types + resources,
version: '@0@.@1@.@2@'.format(LIBWNCK_SOVERSION, LIBWNCK_CURRENT, LIBWNCK_REVISION),
soversion: LIBWNCK_SOVERSION,
+ link_args: libwnck_ldflags,
link_depends: mapfile,
install: true,
)
Feel free to apply this patch if it is a fix you like.