Skip to contentSkip to conversation

libselinux: Add EXTRA_LD_SONAME_FLAGS for musl+llvm builds

PATCH Superseded Stephen Smalley 2 participants 2 messages Jun 15 – Jun 16 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Stephen Smalley

author maintainer
#0 lore raw

PATCH 1/1 libselinux: Add EXTRA_LD_SONAME_FLAGS for musl+llvm builds

Introduce an optionally defined EXTRA_LD_SONAME_FLAGS variable for use by musl+llvm builds to pass --undefined-version. This enables such builds to link despite the intentionally omitted matchpathcon_filespec_add64 symbol.

---
 README.md               | 4 ++++
 libselinux/src/Makefile | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)
README.md +4 -0
index 5e65a049..a458a930 100644
@@ -151,6 +151,10 @@ set when overriding are:
 - -fno-semantic-interposition for gcc or compilers that do not do this. clang does this by default. clang-10 and up
    will support passing this flag, but ignore it. Previous clang versions fail.
 
+## Setting EXTRA_LD_SONAME_FLAGS
+
+Build with EXTRA_LD_SONAME_FLAGS=--undefined-version to fix
+linking against musl with llvm.
 
 macOS
 -----
libselinux/src/Makefile +3 -1
index 9982faad..fe8d3239 100644
@@ -91,7 +91,9 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
 
 override CFLAGS += $(LFS_CFLAGS)
 
-LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro
+# Use make EXTRA_LD_SONAME_FLAGS=--undefined-version to fix
+# linking against musl with llvm.
+LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro$(EXTRA_LD_SONAME_FLAGS)
 
 ifeq ($(OS), Darwin)
 override CFLAGS += -I/opt/local/include
Signature · 1 line
2.54.0
#1 lore raw
Quoted 36 lines · Stephen Smalley

Introduce an optionally defined EXTRA_LD_SONAME_FLAGS variable for use by musl+llvm builds to pass --undefined-version. This enables such builds to link despite the intentionally omitted matchpathcon_filespec_add64 symbol.

---
 README.md               | 4 ++++
 libselinux/src/Makefile | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)
README.md +4 -0
index 5e65a049..a458a930 100644
@@ -151,6 +151,10 @@ set when overriding are:
 - -fno-semantic-interposition for gcc or compilers that do not do this. clang does this by default. clang-10 and up
    will support passing this flag, but ignore it. Previous clang versions fail.
 
+## Setting EXTRA_LD_SONAME_FLAGS
+
+Build with EXTRA_LD_SONAME_FLAGS=--undefined-version to fix
+linking against musl with llvm.
 
 macOS
 -----
libselinux/src/Makefile +0 -0
index 9982faad..fe8d3239 100644

libselinux/src/Makefile CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi · line 96

Quoted 7 lines
libselinux/src/Makefile +3 -1
@@ -91,7 +91,9 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
 
 override CFLAGS += $(LFS_CFLAGS)
 
-LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro
+# Use make EXTRA_LD_SONAME_FLAGS=--undefined-version to fix
+# linking against musl with llvm.
+LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro$(EXTRA_LD_SONAME_FLAGS)

I guess there would be missing ',' before --undefined-version

something like this could fix it:

+LD_SONAME_FLAGS=-soname,$(LIBSO),--version-script=libselinux.map,-z,defs,-z,relro$(EXTRA_LD_SONAME_FLAGS:%=,%)

Quoted 4 lines
libselinux/src/Makefile +0 -0
 ifeq ($(OS), Darwin)
 override CFLAGS += -I/opt/local/include
Signature · 1 line
2.54.0