Skip to contentSkip to conversation

populate_sdk_base: Add ld.so.conf for nativesdk-binutils

PATCH In review Ovidiu Panait 4 participants 9 messages Apr 28, 2020 – May 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 populate_sdk_base: Add ld.so.conf for nativesdk-binutils

Extend the functionality provided by commit [1] to the SDK as well. This way we can make sure that nativesdk-binutils finds SDK libraries first rather than host ones.

This is useful for example when trying to build the linux kernel using nativesdk-gcc. This scenario currently fails because it tries to link to host libraries rather than SDK host ones:

make x86_64_defconfig
make bzImage
...
error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel Makefile:1101: recipe for target 'prepare-objtool' failed
make: *** [prepare-objtool] Error 1
....
/../../../../x86_64-wrlinuxsdk-linux/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE'
...

[1] 15049c610b [buildtools-tarball: Add an ld.so.conf for nativesdk-binutils]

---
 meta/classes/populate_sdk_base.bbclass       | 5 +++++
 meta/recipes-core/meta/buildtools-tarball.bb | 4 ----
 2 files changed, 5 insertions(+), 4 deletions(-)
meta/classes/populate_sdk_base.bbclass +5 -0
index ef0d8bef58..6a1ebc8c02 100644
@@ -185,6 +185,11 @@ fakeroot create_sdk_files() {
 	# Escape special characters like '+' and '.' in the SDKPATH
 	escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
 	sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
+
+       mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
+       echo '${SDKPATHNATIVE}${libdir}
+${SDKPATHNATIVE}${base_libdir}
+include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
 }
 
 python check_sdk_sysroots() {
meta/recipes-core/meta/buildtools-tarball.bb +0 -4
index 977b6a5e1d..c49802eef8 100644
@@ -76,10 +76,6 @@ create_sdk_files_append () {
 	echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script
 	echo 'export OPENSSL_CONF="${SDKPATHNATIVE}${sysconfdir}/ssl/openssl.cnf"' >>$script
 
-	mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
-	echo '${SDKPATHNATIVE}${libdir}
-${SDKPATHNATIVE}${base_libdir}
-include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
 	if [ "${SDKMACHINE}" = "i686" ]; then
 		echo 'export NO32LIBS="0"' >>$script
 		echo 'echo "$BB_ENV_EXTRAWHITE" | grep -q "NO32LIBS"' >>$script
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 populate_sdk_base: create_sdk_files: Use _nativesdk variants for libdir and base_libdir

Use the _nativesdk variants for libdir and base_libdir to fix the resulting ld.so.conf paths in the SDK for systems with libdir=/lib64.

---
 meta/classes/populate_sdk_base.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/classes/populate_sdk_base.bbclass +2 -2
index 6a1ebc8c02..f85c3b9f62 100644
@@ -187,8 +187,8 @@ fakeroot create_sdk_files() {
 	sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
 
        mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
-       echo '${SDKPATHNATIVE}${libdir}
-${SDKPATHNATIVE}${base_libdir}
+       echo '${SDKPATHNATIVE}${libdir_nativesdk}
+${SDKPATHNATIVE}${base_libdir_nativesdk}
 include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
 }
 
Signature · 1 line
2.17.1
#2 lore raw
In reply to Ovidiu Panait

Should I consider these two patches for dunfell LTS?

Thanks!

Steve

Quoted 62 lines · Ovidiu Panait

Extend the functionality provided by commit [1] to the SDK as well. This way we can make sure that nativesdk-binutils finds SDK libraries first rather than host ones.

This is useful for example when trying to build the linux kernel using nativesdk-gcc. This scenario currently fails because it tries to link to host libraries rather than SDK host ones:

make x86_64_defconfig
make bzImage
...
error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel Makefile:1101: recipe for target 'prepare-objtool' failed
make: *** [prepare-objtool] Error 1
....
/../../../../x86_64-wrlinuxsdk-linux/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE'
...

[1] 15049c610b [buildtools-tarball: Add an ld.so.conf for nativesdk-binutils]

---
 meta/classes/populate_sdk_base.bbclass       | 5 +++++
 meta/recipes-core/meta/buildtools-tarball.bb | 4 ----
 2 files changed, 5 insertions(+), 4 deletions(-)
meta/classes/populate_sdk_base.bbclass +5 -0
index ef0d8bef58..6a1ebc8c02 100644
@@ -185,6 +185,11 @@ fakeroot create_sdk_files() {
        # Escape special characters like '+' and '.' in the SDKPATH
        escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
        sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
+
+       mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
+       echo '${SDKPATHNATIVE}${libdir}
+${SDKPATHNATIVE}${base_libdir}
+include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
 }
 
 python check_sdk_sysroots() {
meta/recipes-core/meta/buildtools-tarball.bb +0 -5
index 977b6a5e1d..c49802eef8 100644
@@ -76,10 +76,6 @@ create_sdk_files_append () {
        echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script
        echo 'export OPENSSL_CONF="${SDKPATHNATIVE}${sysconfdir}/ssl/openssl.cnf"' >>$script
 
-       mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
-       echo '${SDKPATHNATIVE}${libdir}
-${SDKPATHNATIVE}${base_libdir}
-include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
        if [ "${SDKMACHINE}" = "i686" ]; then
                echo 'export NO32LIBS="0"' >>$script
                echo 'echo "$BB_ENV_EXTRAWHITE" | grep -q "NO32LIBS"' >>$script
--

2.17.1

#3 lore raw
Quoted 2 lines · Steve Sakoman

Should I consider these two patches for dunfell LTS?

Yes I think they are fixing a problem and are safe.

Quoted 70 lines

Thanks!

Steve

Quoted 64 lines · Ovidiu Panait

Extend the functionality provided by commit [1] to the SDK as well. This way we can make sure that nativesdk-binutils finds SDK libraries first rather than host ones.

This is useful for example when trying to build the linux kernel using nativesdk-gcc. This scenario currently fails because it tries to link to host libraries rather than SDK host ones:

make x86_64_defconfig
make bzImage
...
error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel Makefile:1101: recipe for target 'prepare-objtool' failed
make: *** [prepare-objtool] Error 1
....
/../../../../x86_64-wrlinuxsdk-linux/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE'
...

[1] 15049c610b [buildtools-tarball: Add an ld.so.conf for nativesdk-binutils]

---
 meta/classes/populate_sdk_base.bbclass       | 5 +++++
 meta/recipes-core/meta/buildtools-tarball.bb | 4 ----
 2 files changed, 5 insertions(+), 4 deletions(-)
meta/classes/populate_sdk_base.bbclass +5 -0
index ef0d8bef58..6a1ebc8c02 100644
@@ -185,6 +185,11 @@ fakeroot create_sdk_files() {
        # Escape special characters like '+' and '.' in the SDKPATH
        escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
        sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
+
+       mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
+       echo '${SDKPATHNATIVE}${libdir}
+${SDKPATHNATIVE}${base_libdir}
+include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
 }
 
 python check_sdk_sysroots() {
meta/recipes-core/meta/buildtools-tarball.bb +0 -5
index 977b6a5e1d..c49802eef8 100644
@@ -76,10 +76,6 @@ create_sdk_files_append () {
        echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script
        echo 'export OPENSSL_CONF="${SDKPATHNATIVE}${sysconfdir}/ssl/openssl.cnf"' >>$script
 
-       mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
-       echo '${SDKPATHNATIVE}${libdir}
-${SDKPATHNATIVE}${base_libdir}
-include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
        if [ "${SDKMACHINE}" = "i686" ]; then
                echo 'export NO32LIBS="0"' >>$script
                echo 'echo "$BB_ENV_EXTRAWHITE" | grep -q "NO32LIBS"' >>$script
--

2.17.1

#4 lore raw
Quoted 7 lines · Khem Raj
Quoted 2 lines · Steve Sakoman

Should I consider these two patches for dunfell LTS?

Yes I think they are fixing a problem and are safe.

I don't think it is safe though!

The code has been moved to create_sdk_files() which is a POSTPROCESS command for SDK creation. What if SDK already provides own /etc/ld.so.conf? The code just simply overwrites it.

Signature · 1 line
Denys
Quoted 72 lines
Quoted 70 lines

Thanks!

Steve

Quoted 64 lines · Ovidiu Panait

Extend the functionality provided by commit [1] to the SDK as well. This way we can make sure that nativesdk-binutils finds SDK libraries first rather than host ones.

This is useful for example when trying to build the linux kernel using nativesdk-gcc. This scenario currently fails because it tries to link to host libraries rather than SDK host ones:

make x86_64_defconfig
make bzImage
...
error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel Makefile:1101: recipe for target 'prepare-objtool' failed
make: *** [prepare-objtool] Error 1
....
/../../../../x86_64-wrlinuxsdk-linux/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE'
...

[1] 15049c610b [buildtools-tarball: Add an ld.so.conf for nativesdk-binutils]

---
 meta/classes/populate_sdk_base.bbclass       | 5 +++++
 meta/recipes-core/meta/buildtools-tarball.bb | 4 ----
 2 files changed, 5 insertions(+), 4 deletions(-)
meta/classes/populate_sdk_base.bbclass +5 -0
index ef0d8bef58..6a1ebc8c02 100644
@@ -185,6 +185,11 @@ fakeroot create_sdk_files() {
        # Escape special characters like '+' and '.' in the SDKPATH
        escaped_sdkpath=$(echo ${SDKPATH} |sed -e "s:[\+\.]:\\\\\\\\\0:g")
        sed -i -e "s:##DEFAULT_INSTALL_DIR##:$escaped_sdkpath:" ${SDK_OUTPUT}/${SDKPATH}/relocate_sdk.py
+
+       mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
+       echo '${SDKPATHNATIVE}${libdir}
+${SDKPATHNATIVE}${base_libdir}
+include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
 }
 
 python check_sdk_sysroots() {
meta/recipes-core/meta/buildtools-tarball.bb +0 -5
index 977b6a5e1d..c49802eef8 100644
@@ -76,10 +76,6 @@ create_sdk_files_append () {
        echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script
        echo 'export OPENSSL_CONF="${SDKPATHNATIVE}${sysconfdir}/ssl/openssl.cnf"' >>$script
 
-       mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
-       echo '${SDKPATHNATIVE}${libdir}
-${SDKPATHNATIVE}${base_libdir}
-include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
        if [ "${SDKMACHINE}" = "i686" ]; then
                echo 'export NO32LIBS="0"' >>$script
                echo 'echo "$BB_ENV_EXTRAWHITE" | grep -q "NO32LIBS"' >>$script
--

2.17.1

#5 lore raw
Quoted 7 lines · Denys Dmytriyenko
Quoted 6 lines · Khem Raj
Quoted 2 lines · Steve Sakoman

Should I consider these two patches for dunfell LTS?

Quoted 8 lines
Quoted 1 line

Yes I think they are fixing a problem and are safe.

I don't think it is safe though!

The code has been moved to create_sdk_files() which is a POSTPROCESS command for SDK creation. What if SDK already provides own /etc/ld.so.conf? The code just simply overwrites it.

but are there such usecases ? looking closely if SDK is extending the ld.so.conf then they should be appending to it instead of overwriting and same is true for this patch for master.

#6 lore raw
Quoted 14 lines · Khem Raj
Quoted 11 lines · Denys Dmytriyenko
Quoted 7 lines · Khem Raj
Quoted 2 lines · Steve Sakoman

Should I consider these two patches for dunfell LTS?

Yes I think they are fixing a problem and are safe.

I don't think it is safe though!

Quoted 8 lines
Quoted 4 lines

The code has been moved to create_sdk_files() which is a POSTPROCESS command for SDK creation. What if SDK already provides own /etc/ld.so.conf? The code just simply overwrites it.

but are there such usecases ? looking closely if SDK is extending the ld.so.conf then they should be appending to it instead of overwriting and same is true for this patch for master.

Exactly my point - should probably append, not overwrite.
As of usecases - I can think of a non-standard nativesdk tool that adjusts /etc/ld.so.conf during install...

Signature · 1 line
Denys
#7 lore raw
Quoted 21 lines · Denys Dmytriyenko
Quoted 19 lines · Khem Raj
Quoted 15 lines · Denys Dmytriyenko
Quoted 7 lines · Khem Raj
Quoted 2 lines · Steve Sakoman

Should I consider these two patches for dunfell LTS?

Yes I think they are fixing a problem and are safe.

I don't think it is safe though!

The code has been moved to create_sdk_files() which is a POSTPROCESS command for SDK creation. What if SDK already provides own /etc/ld.so.conf? The code just simply overwrites it.

Quoted 7 lines
Quoted 3 lines

but are there such usecases ? looking closely if SDK is extending the ld.so.conf then they should be appending to it instead of overwriting and same is true for this patch for master.

Exactly my point - should probably append, not overwrite.
As of usecases - I can think of a non-standard nativesdk tool that adjusts /etc/ld.so.conf during install...

I think you've convinced me to pass on this for dunfell (at least in the short term)

If a patch is submitted that appends rather than overwrites I'll consider the series again once it makes it into master.

If you submit such a patch please tag it with [dunfell] too.

Thanks for the comments!

Steve

Quoted 1 line
#8 lore raw
Quoted 31 lines · Steve Sakoman
Quoted 21 lines · Denys Dmytriyenko
Quoted 19 lines · Khem Raj
Quoted 15 lines · Denys Dmytriyenko
Quoted 7 lines · Khem Raj
Quoted 2 lines · Steve Sakoman

Should I consider these two patches for dunfell LTS?

Yes I think they are fixing a problem and are safe.

I don't think it is safe though!

The code has been moved to create_sdk_files() which is a POSTPROCESS command for SDK creation. What if SDK already provides own /etc/ld.so.conf? The code just simply overwrites it.

Quoted 7 lines
Quoted 3 lines

but are there such usecases ? looking closely if SDK is extending the ld.so.conf then they should be appending to it instead of overwriting and same is true for this patch for master.

Exactly my point - should probably append, not overwrite.
As of usecases - I can think of a non-standard nativesdk tool that adjusts /etc/ld.so.conf during install...

Quoted 6 lines

I think you've convinced me to pass on this for dunfell (at least in the short term)

If a patch is submitted that appends rather than overwrites I'll consider the series again once it makes it into master.

yes, I think that will be right thing to do although I think it fills in a good gap in dunfell
but as it is might not work as expected.

Quoted 6 lines

If you submit such a patch please tag it with [dunfell] too.

Thanks for the comments!

Steve

Quoted 1 line