Skip to contentSkip to conversation

libgcc: Fix standalone target builds with usrmerge distro feature

PATCH Superseded Khem Raj 3 participants 7 messages Jul 23, 2022 – Jul 25, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/3 libgcc: Fix standalone target builds with usrmerge distro feature

Ignore the rmdir cmd if using usrmerge distro feature since the intention is to delete /lib or /lib64 but not libdir under /usr and base_libdir = libdir when usrmerge is enabled in distro

---
 meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
meta/recipes-devtools/gcc/libgcc-common.inc +6 -2
index 148c9f85a7c..9d4fd41f975 100644
@@ -44,10 +44,14 @@ do_install () {
 }
 
 do_install:append:libc-baremetal () {
-	rmdir ${D}${base_libdir}
+	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
+		rmdir ${D}${base_libdir}
+	fi
 }
 do_install:append:libc-newlib () {
-	rmdir ${D}${base_libdir}
+	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
+		rmdir ${D}${base_libdir}
+	fi
 }
 
 # No rpm package is actually created but -dev depends on it, avoid dnf error
Signature · 1 line
2.37.1
author
#1 lore raw

PATCH 2/3 gcc-runtime: Use static dummy libstdc++

some standalone targets e.g. riscv64-elf disable shared linking for baremetal ELF ABI in ld, therefore lets make it a static library

---
 meta/recipes-devtools/gcc/gcc-runtime.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-devtools/gcc/gcc-runtime.inc +1 -1
index b63280ab3a4..15f4175214b 100644
@@ -54,7 +54,7 @@ do_configure () {
 	# libstdc++ isn't built yet so CXX would error not able to find it which breaks stdc++'s configure
 	# tests. Create a dummy empty lib for the purposes of configure.
 	mkdir -p ${WORKDIR}/dummylib
-	${CC} -x c /dev/null -nostartfiles -shared -o ${WORKDIR}/dummylib/libstdc++.so
+	${CC} -x c /dev/null -nostartfiles -nostdlib -nostdinc -static -o ${WORKDIR}/dummylib/libstdc++.a
 	for d in libgcc ${RUNTIMETARGET}; do
 		echo "Configuring $d"
 		rm -rf ${B}/${TARGET_SYS}/$d/
Signature · 1 line
2.37.1
author
#2 lore raw

PATCH 3/3 gcc-runtime: Use --with-target-subdir for baremetal targets

In reply to Khem Raj

This disables tests for runtime system specific functions like fcntl there is no other change seen

+configure:77372: checking for fcntl
+configure:77372: result: yes

In libsttdc++ configure log outputs.

[YOCTO #14803]

---
 meta/recipes-devtools/gcc/gcc-runtime.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
meta/recipes-devtools/gcc/gcc-runtime.inc +2 -1
index 15f4175214b..91b74c732bd 100644
@@ -16,7 +16,8 @@ EXTRA_OECONF_PATHS = "\
 
 EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu"
 EXTRA_OECONF:append = " --cache-file=${B}/config.cache"
-EXTRA_OECONF:append:libc-newlib = " --with-newlib"
+EXTRA_OECONF:append:libc-newlib = " --with-newlib --with-target-subdir"
+EXTRA_OECONF:append:libc-baremetal = " --with-target-subdir"
 
 # Disable ifuncs for libatomic on arm conflicts -march/-mcpu
 EXTRA_OECONF:append:arm = " libat_cv_have_ifunc=no "
Signature · 1 line
2.37.1
#3 lore raw

Re: [OE-core] [PATCH 3/3] gcc-runtime: Use --with-target-subdir for baremetal targets

Fixes our builds, thanks Khem!

Ross

Quoted 43 lines · Khem Raj via lists.openembedded.org

This disables tests for runtime system specific functions like fcntl there is no other change seen

(quoted diff) +2 -0
+configure:77372: checking for fcntl
+configure:77372: result: yes

In libsttdc++ configure log outputs.

[YOCTO #14803]

---
meta/recipes-devtools/gcc/gcc-runtime.inc | 3 ++-

1 file changed, 2 insertions(+), 1 deletion(-)
meta/recipes-devtools/gcc/gcc-runtime.inc +0 -0
index 15f4175214b..91b74c732bd 100644
@@ -16,7 +16,8 @@ EXTRA_OECONF_PATHS = "\
 

EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu" EXTRA_OECONF:append = " --cache-file=${B}/config.cache"

meta/recipes-devtools/gcc/gcc-runtime.inc +2 -1
-EXTRA_OECONF:append:libc-newlib = " --with-newlib"
+EXTRA_OECONF:append:libc-newlib = " --with-newlib --with-target-subdir"
+EXTRA_OECONF:append:libc-baremetal = " --with-target-subdir"

# Disable ifuncs for libatomic on arm conflicts -march/-mcpu EXTRA_OECONF:append:arm = " libat_cv_have_ifunc=no "

Signature · 10 lines
2.37.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#168442): https://lists.openembedded.org/g/openembedded-core/message/168442
Mute This Topic: https://lists.openembedded.org/mt/92568011/6875888
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#4 lore raw
In reply to Khem Raj
Quoted 21 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Khem Raj
Sent: den 23 juli 2022 16:54
To: [email protected]
Cc: Khem Raj <[email protected]>
Subject: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds with usrmerge distro feature

Ignore the rmdir cmd if using usrmerge distro feature since the intention is to delete /lib or /lib64 but not libdir under /usr and base_libdir = libdir when usrmerge is enabled in distro

---
 meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
meta/recipes-devtools/gcc/libgcc-common.inc +0 -0
index 148c9f85a7c..9d4fd41f975 100644

meta/recipes-devtools/gcc/libgcc-common.inc do_install () { · line 47

Quoted 5 lines
meta/recipes-devtools/gcc/libgcc-common.inc +1 -1
@@ -44,10 +44,14 @@ do_install () {
 }
 
 do_install:append:libc-baremetal () {
-	rmdir ${D}${base_libdir}
+	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then

Since the goal is to avoid deleting ${libdir} in case it happens to match ${base_libdir}, I recommend to change the tests to instead be:

	if [ "${base_libdir}" != "${libdir}" ]; then
Quoted 12 lines
meta/recipes-devtools/gcc/libgcc-common.inc +5 -2
+		rmdir ${D}${base_libdir}
+	fi
 }
 do_install:append:libc-newlib () {
-	rmdir ${D}${base_libdir}
+	if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
+		rmdir ${D}${base_libdir}
+	fi
 }
 
 # No rpm package is actually created but -dev depends on it, avoid dnf error
--
Quoted 1 line

2.37.1

//Peter

author
#5 lore raw

Hi Peter

Thanks for the review.

Quoted 24 lines · Peter Kjellerstedt
Quoted 24 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Khem Raj
Sent: den 23 juli 2022 16:54
To: [email protected]
Cc: Khem Raj <[email protected]>
Subject: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds with usrmerge distro feature

Ignore the rmdir cmd if using usrmerge distro feature since the intention is to delete /lib or /lib64 but not libdir under /usr and base_libdir = libdir when usrmerge is enabled in distro

---
 meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
meta/recipes-devtools/gcc/libgcc-common.inc +0 -0
index 148c9f85a7c..9d4fd41f975 100644
@@ -44,10 +44,14 @@ do_install () {
 }
 
Quoted 9 lines

meta/recipes-devtools/gcc/libgcc-common.inc do_install () { · line 47

Quoted 3 lines
meta/recipes-devtools/gcc/libgcc-common.inc +1 -1
 do_install:append:libc-baremetal () {
-     rmdir ${D}${base_libdir}
+     if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then

Since the goal is to avoid deleting ${libdir} in case it happens to match ${base_libdir}, I recommend to change the tests to instead be:

        if [ "${base_libdir}" != "${libdir}" ]; then

I don't see much benefit of doing this since our usecase is guarded by distro feature and I found it more readable
having said that I am fine to change it as well, other option would be to use rmdir --ignore-fail-on-non-empty and avoid
the check but that will make it generic and we might not see some unwanted files sneaking into base_libdir so erroring out
is a good check.

Quoted 15 lines
Quoted 12 lines
meta/recipes-devtools/gcc/libgcc-common.inc +5 -2
+             rmdir ${D}${base_libdir}
+     fi
 }
 do_install:append:libc-newlib () {
-     rmdir ${D}${base_libdir}
+     if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
+             rmdir ${D}${base_libdir}
+     fi
 }
 
 # No rpm package is actually created but -dev depends on it, avoid dnf error
--
Quoted 1 line

2.37.1

//Peter

#6 lore raw
Quoted 47 lines

-----Original Message-----
From: Khem Raj <[email protected]>
Sent: den 24 juli 2022 15:52
To: Peter Kjellerstedt <[email protected]>
Cc: [email protected]
Subject: Re: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds with usrmerge distro feature

Hi Peter

Thanks for the review.

Quoted 3 lines · Peter Kjellerstedt
Quoted 3 lines

-----Original Message-----
From: [email protected] <openembedded-

[email protected]> On Behalf Of Khem Raj

Quoted 4 lines
Quoted 4 lines

Sent: den 23 juli 2022 16:54
To: [email protected]
Cc: Khem Raj <[email protected]>
Subject: [OE-core] [PATCH 1/3] libgcc: Fix standalone target builds

with usrmerge distro feature

Quoted 11 lines

Review

Quoted 11 lines

Ignore the rmdir cmd if using usrmerge distro feature since the intention is to delete /lib or /lib64 but not libdir under /usr and base_libdir = libdir when usrmerge is enabled in distro

---
 meta/recipes-devtools/gcc/libgcc-common.inc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/meta/recipes-devtools/gcc/libgcc-common.inc

Quoted 9 lines

meta/recipes-devtools/gcc/libgcc-common.inc do_install () { · line 47

Quoted 9 lines

index 148c9f85a7c..9d4fd41f975 100644

meta/recipes-devtools/gcc/libgcc-common.inc +1 -1
@@ -44,10 +44,14 @@ do_install () {
 }
 
 do_install:append:libc-baremetal () {
-     rmdir ${D}${base_libdir}
+     if

${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then

Quoted 2 lines

Since the goal is to avoid deleting ${libdir} in case it happens to

Quoted 8 lines

match

Quoted 4 lines

${base_libdir}, I recommend to change the tests to instead be:

        if [ "${base_libdir}" != "${libdir}" ]; then

I don't see much benefit of doing this since our usecase is guarded by distro feature and I found it more readable

We already have corresponding tests in other places where we want to avoid removing ${libdir} if it happens to match ${base_libdir}, e.g., in the glibc-package.inc file.

The benefit I see with comparing the two variables rather than relying on the distro feature is that the test isn't really related to usrmerge, it only happens to coincide. I.e., if I would manually configure my system so that ${base_libdir} == ${libdir} without setting usrmerge, the test here would still do the right thing (things would probably break in other places though, but that is a different story).

Quoted 21 lines

having said that I am fine to change it as well, other option would be to use rmdir --ignore-fail-on-non-empty and avoid
the check but that will make it generic and we might not see some unwanted files sneaking into base_libdir so erroring out
is a good check.

Quoted 15 lines
Quoted 12 lines
meta/recipes-devtools/gcc/libgcc-common.inc +5 -2
+             rmdir ${D}${base_libdir}
+     fi
 }
 do_install:append:libc-newlib () {
-     rmdir ${D}${base_libdir}
+     if ${@bb.utils.contains('DISTRO_FEATURES','usrmerge','false','true',d)}; then
+             rmdir ${D}${base_libdir}
+     fi
 }
 
 # No rpm package is actually created but -dev depends on it, avoid dnf error
--
Quoted 1 line

2.37.1

//Peter

//Peter