Bug 219168

Summary: -Bsymbolic-functions breaks psx_load_syscalls override
Product: Tools Reporter: Stas Sergeev (stsp)
Component: libcapAssignee: Andrew G. Morgan (morgan)
Status: RESOLVED CODE_FIX    
Severity: normal CC: morgan
Priority: P3    
Hardware: All   
OS: Linux   
Kernel Version: Subsystem:
Regression: No Bisected commit-id:

Description Stas Sergeev 2024-08-16 08:07:28 UTC
Many build systems (well, ubuntu's one for sure)
add -Wl,-Bsymbolic-functions to LDFLAGS. After that,
libpsx doesn't work as it can't override psx_load_syscalls.

I propose this small hack as a fix:

diff --git a/libcap/Makefile b/libcap/Makefile
index f5dde3e..b23a925 100644
--- a/libcap/Makefile
+++ b/libcap/Makefile
@@ -21,6 +21,10 @@ PSXMAGICOBJ=psx_magic.o
 # Always build libcap sources this way:
 CFLAGS += -fPIC
 
+# Many build systems add -Bsymbolic-functions - remove
+CMA = ,
+LDFLAGS := $(filter-out -Wl$(CMA)-Bsymbolic-functions,$(LDFLAGS))
+
 # The linker magic needed to build a dynamic library as independently
 # executable
 MAGIC=-Wl,-e,__so_start
Comment 1 Andrew G. Morgan 2024-08-17 14:30:40 UTC
What does "$(CMA)" achieve here?
Comment 2 Andrew G. Morgan 2024-08-17 14:32:12 UTC
Oh, never mind. filter-out takes two arguments. I see.
Comment 3 Andrew G. Morgan 2024-08-17 14:44:20 UTC
This was a new one on me:

  https://stackoverflow.com/a/71559422
Comment 5 Stas Sergeev 2024-08-17 22:28:55 UTC
Good, so I filled up this ticket now:
https://bugs.launchpad.net/ubuntu/+source/libcap2/+bug/2077246