Skip to contentSkip to conversation

multilib: Add musl multilib support

PATCH In review Khem Raj 1 participant 2 messages Aug 21, 2020 – Aug 22, 2020

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/1 multilib: Add musl multilib support

Since musl ldso can now co-exist in multilib therefore add support to build multilibbed headers and adjust the wrapper header to support musl, it needs __WORDSIZE which is defined in bits/reg.h for musl

[YOCTO #13122]

---
v2: Use OE's libc switch to include relevant header instead of __GLIBC__ define

 meta/classes/multilib_header.bbclass | 16 +++++++++-------
 scripts/multilib_header_wrapper.h    |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)
meta/classes/multilib_header.bbclass +9 -7
index e03f5b13b2..0304f6d3af 100644
@@ -6,13 +6,14 @@ inherit siteinfo
 # all of the ABI variants for that given architecture.
 #
 oe_multilib_header() {
-
-	case ${HOST_OS} in
-	*-musl*)
-		return
-		;;
-	*)
-	esac
+       case ${HOST_OS} in
+       *-musl*)
+               wordsize="bits/reg.h"
+               ;;
+       *)
+               wordsize="bits/wordsize.h"
+               ;;
+       esac
         # For MIPS: "n32" is a special case, which needs to be
         # distinct from both 64-bit and 32-bit.
         case ${TARGET_ARCH} in
@@ -37,6 +38,7 @@ oe_multilib_header() {
 	   mv ${D}/${includedir}/$each_header ${D}/${includedir}/${stem}-${ident}.h
 
 	   sed -e "s#ENTER_HEADER_FILENAME_HERE#${stem}#g" ${COREBASE}/scripts/multilib_header_wrapper.h > ${D}/${includedir}/$each_header
+	   sed -i -e "s#WORDSIZE_HEADER#${wordsize}#g" ${D}/${includedir}/$each_header
 	done
 }
 
scripts/multilib_header_wrapper.h +1 -1
index 88f3193812..ae441b4445 100644
@@ -5,7 +5,7 @@
  * 
  */
 
-#include <bits/wordsize.h>
+#include <WORDSIZE_HEADER>
 
 #if __WORDSIZE == 32
 
Signature · 1 line
2.28.0
author
#1 lore raw

I did few world builds and more I realized we should not pursue this path a few packages started to fail with redefining some defines which are in bits/reg.h and attleat 5-6 packages showed the issue unlike glibc where bits/wordsize.h just defined __WORDSIZE on musl this define is in bits/reg.h but its not the only define. So I feel that its a wrong fix. Plus I think multilib for musl might be less of an usecase
practically then say glibc which has some legacy of multilib. Unless upstream musl separates this out into wordsize.h this would be a wrong way to fix the multilib. So lets not apply this patch as yet.

Quoted 65 lines · Khem Raj

Since musl ldso can now co-exist in multilib therefore add support to build multilibbed headers and adjust the wrapper header to support musl, it needs __WORDSIZE which is defined in bits/reg.h for musl

[YOCTO #13122]

---
v2: Use OE's libc switch to include relevant header instead of __GLIBC__ define

 meta/classes/multilib_header.bbclass | 16 +++++++++-------
 scripts/multilib_header_wrapper.h    |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)
meta/classes/multilib_header.bbclass +9 -7
index e03f5b13b2..0304f6d3af 100644
@@ -6,13 +6,14 @@ inherit siteinfo
 # all of the ABI variants for that given architecture.
 #
 oe_multilib_header() {
-
-       case ${HOST_OS} in
-       *-musl*)
-               return
-               ;;
-       *)
-       esac
+       case ${HOST_OS} in
+       *-musl*)
+               wordsize="bits/reg.h"
+               ;;
+       *)
+               wordsize="bits/wordsize.h"
+               ;;
+       esac
         # For MIPS: "n32" is a special case, which needs to be
         # distinct from both 64-bit and 32-bit.
         case ${TARGET_ARCH} in
@@ -37,6 +38,7 @@ oe_multilib_header() {
           mv ${D}/${includedir}/$each_header ${D}/${includedir}/${stem}-${ident}.h
 
           sed -e "s#ENTER_HEADER_FILENAME_HERE#${stem}#g" ${COREBASE}/scripts/multilib_header_wrapper.h > ${D}/${includedir}/$each_header
+          sed -i -e "s#WORDSIZE_HEADER#${wordsize}#g" ${D}/${includedir}/$each_header
        done
 }
 
scripts/multilib_header_wrapper.h +1 -2
index 88f3193812..ae441b4445 100644
@@ -5,7 +5,7 @@
  *
  */
 
-#include <bits/wordsize.h>
+#include <WORDSIZE_HEADER>
 
 #if __WORDSIZE == 32
 
--

2.28.0