Skip to contentSkip to conversation

glibc: Pass linker choice via compiler flags

PATCH New Khem Raj 1 participant 2 messages Jun 10, 2023

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 glibc: Pass linker choice via compiler flags

glibc configury tries to detect ld version and assumes BFD or gold linker but when system ld is pointing to lld or mold it might fail the linker check, therefore pass LD variable to explicitly point at ld.bfd we are using BFD linker only to link glibc after all.

Second problem in such a case is that some partial objects are linked with CC -r which will fail if we do not inform the compiler to use BFD linker thusly pass it via appending to CC variable

---
 meta/recipes-core/glibc/glibc_2.37.bb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-core/glibc/glibc_2.37.bb +3 -1
index b27f98fb199..3387441cad9 100644
@@ -103,10 +103,12 @@ do_configure () {
 # version check and doesn't really help with anything
         (cd ${S} && gnu-configize) || die "failure in running gnu-configize"
         find ${S} -name "configure" | xargs touch
-        CPPFLAGS="" oe_runconf
+        CPPFLAGS="" LD="${HOST_PREFIX}ld.bfd ${TOOLCHAIN_OPTIONS}" oe_runconf
 }
 
 LDFLAGS += "-fuse-ld=bfd"
+CC += "-fuse-ld=bfd"
+
 do_compile () {
 	base_do_compile
 	echo "Adjust ldd script"
Signature · 1 line
2.41.0
author
#1 lore raw

PATCH 2/2 libgcc: Always use BFD linker

libgcc is linked with GNU BFD linker make sure it does not assume default ld to be BFD linker rather demand it explicitly

---
 meta/recipes-devtools/gcc/libgcc_13.1.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/gcc/libgcc_13.1.bb +2 -0
index f88963b0a42..fdcd6cc0da1 100644
@@ -1,5 +1,7 @@
 require recipes-devtools/gcc/gcc-${PV}.inc
 require libgcc.inc
 
+LDFLAGS += "-fuse-ld=bfd"
+
 # Building with thumb enabled on armv6t fails
 ARM_INSTRUCTION_SET:armv6 = "arm"
Signature · 1 line
2.41.0