[PATCH] libbsd.map: Add guards for LIBBSD_OVERLAY symbols
Nicholas Vinson
nvinson234 at gmail.com
Mon Jan 8 03:04:46 UTC 2024
When built with the LIBBSD_OVERLAY macro set, the following functions
are not built which results in undefined symbols in libbsd.map:
vwarn, vwarnx, warn, warnx, verr, verrx, err, errx
leading to build failures similar to
ld.lld: error: version script assignment of 'LIBBSD_0.10.0' to
symbol 'vwarn' failed: symbol not defined
when linking with ld.lld since ld.lld does not allow undefined symbols
in the map by default.
Add guards, so these functions are excluded from libbsd.map when not
built. Thereby, allowing ld.lld-16 and newer to link successfully with
default options. See
https://maskray.me/blog/2023-03-19-lld-16-elf-changes for ld.lld-16
change summary.
Fixes Gentoo Bug 915068 ( https://bugs.gentoo.org/915068 )
Signed-off-by: Nicholas Vinson <nvinson234 at gmail.com>
---
src/Makefile.am | 6 +++++-
src/{libbsd.map => libbsd.map.in} | 2 ++
2 files changed, 7 insertions(+), 1 deletion(-)
rename src/{libbsd.map => libbsd.map.in} (99%)
diff --git a/src/Makefile.am b/src/Makefile.am
index 6f2325c..9492d31 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -64,8 +64,9 @@ libbsd_la_LDFLAGS = \
# EOL
if HAVE_LINKER_VERSION_SCRIPT
libbsd_la_LDFLAGS += \
- -Wl,--version-script=$(srcdir)/libbsd.map \
+ -Wl,--version-script=$(top_builddir)/src/libbsd.map \
# EOL
+EXTRA_libbsd_la_DEPENDENCIES += $(top_builddir)/src/libbsd.map
else
libbsd_la_LDFLAGS += \
-export-symbols libbsd.sym \
@@ -200,6 +201,9 @@ libbsd_ctor_a_SOURCES = \
setproctitle_ctor.c \
# EOL
+libbsd.map: libbsd.map.in
+ $(CC) -E $(AM_CPPFLAGS) $(CPPFLAGS) -x assembler-with-cpp -o $@ $<
+
# Generate a simple libtool symbol export list to be used as a fallback if
# there is no version script support.
libbsd.sym: libbsd.map
diff --git a/src/libbsd.map b/src/libbsd.map.in
similarity index 99%
rename from src/libbsd.map
rename to src/libbsd.map.in
index 6c61235..f645600 100644
--- a/src/libbsd.map
+++ b/src/libbsd.map.in
@@ -174,6 +174,7 @@ LIBBSD_0.9.1 {
} LIBBSD_0.9;
LIBBSD_0.10.0 {
+#ifndef LIBBSD_OVERLAY
/* These BSD extensions are available on GNU systems, but not on other
* systems such as Windows or musl libc based ones. */
vwarn;
@@ -184,6 +185,7 @@ LIBBSD_0.10.0 {
verrx;
err;
errx;
+#endif
} LIBBSD_0.9.1;
LIBBSD_0.11.0 {
--
2.43.0
More information about the libbsd
mailing list