devel/basu: unbreak build with LLD 13 (devel/llvm13 or -CURRENT)

ld: error: undefined symbol: __start_BUS_ERROR_MAP
>>> referenced by bus-error.c
>>>               libsystemd_static.a.p/sd-bus_bus-error.c.o:(bus_error_name_to_errno) in archive src/libsystemd/libsystemd_static.a

ld: error: undefined symbol: __stop_BUS_ERROR_MAP
>>> referenced by bus-error.c
>>>               libsystemd_static.a.p/sd-bus_bus-error.c.o:(bus_error_name_to_errno) in archive src/libsystemd/libsystemd_static.a
>>> referenced by bus-error.c
>>>               libsystemd_static.a.p/sd-bus_bus-error.c.o:(bus_error_name_to_errno) in archive src/libsystemd/libsystemd_static.a
cc: error: linker command failed with exit code 1 (use -v to see invocation)

PR:		258812
Obtained from:	https://github.com/systemd/systemd/commit/945317a4b69d

(cherry picked from commit ffe546db80)
This commit is contained in:
Evgeniy Khramtsov 2021-10-09 15:37:45 +00:00 committed by Jan Beich
parent 917e3a5bdd
commit b1a8e908da

View File

@ -0,0 +1,23 @@
https://lists.sr.ht/~emersion/public-inbox/%3CCANvPQf_5qOdfbe4Tk029yVB6BHipmYfQnuuCVoTUv3N%3D2f8jfw%40mail.gmail.com%3E
https://github.com/systemd/systemd/commit/945317a4b69d33752c9513bb8994fe8d5a786ea6
--- src/libsystemd/sd-bus/bus-error.h.orig 2021-01-06 13:56:51 UTC
+++ src/libsystemd/sd-bus/bus-error.h
@@ -28,11 +28,17 @@ int bus_error_set_errnofv(sd_bus_error *e, int error,
* the bus error table, and BUS_ERROR_MAP_ELF_USE has to be used at
* least once per compilation unit (i.e. per library), to ensure that
* the error map is really added to the final binary.
+ *
+ * In addition, set the retain attribute so that the section cannot be
+ * discarded by ld --gc-sections -z start-stop-gc. Older compilers would
+ * warn for the unknown attribute, so just disable -Wattributes.
*/
#define BUS_ERROR_MAP_ELF_REGISTER \
+ _Pragma("GCC diagnostic ignored \"-Wattributes\"") \
__attribute__ ((__section__("BUS_ERROR_MAP"))) \
__attribute__ ((__used__)) \
+ __attribute__ ((retain)) \
__attribute__ ((aligned(8)))
#define BUS_ERROR_MAP_ELF_USE(errors) \