Skip to contentSkip to conversation

populate_sdk_base: do not overwrite ld.so.conf in nativesdk

PATCH In review Denys Dmytriyenko 2 participants 2 messages May 19, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 populate_sdk_base: do not overwrite ld.so.conf in nativesdk

From: Denys Dmytriyenko <[email protected]>

Commit 7ec84a463ad4c45aee9cd2cbc75b43e5aab5cd18 has moved creation of ld.so.conf from buildtools-tarball.bb to create_sdk_files() in populate_sdk_base.bbclass. But since create_sdk_files() is an SDK_POSTPROCESS_COMMAND, creating ld.so.conf can potentially overwrite existing file already provided by a nativesdk package. Use append instead to avoid overwriting existing file.

---
 meta/classes/populate_sdk_base.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/populate_sdk_base.bbclass +1 -1
index 990505e..83c3448 100644
@@ -189,7 +189,7 @@ fakeroot create_sdk_files() {
        mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
        echo '${SDKPATHNATIVE}${libdir_nativesdk}
 ${SDKPATHNATIVE}${base_libdir_nativesdk}
-include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
+include /etc/ld.so.conf' >> ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
 }
 
 python check_sdk_sysroots() {
Signature · 1 line
2.7.4
#1 lore raw
Quoted 18 lines · Denys Dmytriyenko

From: Denys Dmytriyenko <[email protected]>

Commit 7ec84a463ad4c45aee9cd2cbc75b43e5aab5cd18 has moved creation of ld.so.conf from buildtools-tarball.bb to create_sdk_files() in populate_sdk_base.bbclass. But since create_sdk_files() is an SDK_POSTPROCESS_COMMAND, creating ld.so.conf can potentially overwrite existing file already provided by a nativesdk package. Use append instead to avoid overwriting existing file.

---
  meta/classes/populate_sdk_base.bbclass | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/populate_sdk_base.bbclass +0 -0
index 990505e..83c3448 100644

meta/classes/populate_sdk_base.bbclass fakeroot create_sdk_files() { · line 193

Quoted 6 lines
meta/classes/populate_sdk_base.bbclass +1 -1
@@ -189,7 +189,7 @@ fakeroot create_sdk_files() {
         mkdir -p ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/
         echo '${SDKPATHNATIVE}${libdir_nativesdk}
  ${SDKPATHNATIVE}${base_libdir_nativesdk}
-include /etc/ld.so.conf' > ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
+include /etc/ld.so.conf' >> ${SDK_OUTPUT}/${SDKPATHNATIVE}${sysconfdir}/ld.so.conf
  }

Hi Denys,

With this change, in my testing (Ubuntu 18.04 server), nativesdk-gcc would still try to link with host libraries first rather than nativesdk ones, basically reverting the original intent of commit 7ec84a463ad4c45aee9cd2cbc75b43e5aab5cd18:

local.conf:

KERNEL_DEV_HOST_PKGS = "\
    nativesdk-openssl-dev \
    nativesdk-libelf \
    nativesdk-elfutils-dev \
    nativesdk-ncurses-terminfo-base \
    nativesdk-chrpath \
    nativesdk-tar \
    nativesdk-git \
    nativesdk-pigz \
    nativesdk-make \
    nativesdk-wget \
    nativesdk-ca-certificates \
    nativesdk-texinfo \
    nativesdk-libnss-nis \
    nativesdk-rpcsvc-proto \
    nativesdk-patch \
    nativesdk-automake \
    nativesdk-autoconf \
    nativesdk-binutils \
    nativesdk-binutils-symlinks \
    nativesdk-cpp \
    nativesdk-cpp-symlinks \
    nativesdk-gcc \
    nativesdk-gcc-symlinks \
    nativesdk-g++ \
    nativesdk-g++-symlinks \
    nativesdk-gettext \
    nativesdk-libatomic \
    nativesdk-libgcc \
    nativesdk-libstdc++ \
    nativesdk-libstdc++-dev \
    nativesdk-libtool \
    nativesdk-pkgconfig \
    nativesdk-glibc-utils \
    nativesdk-libxcrypt-dev \
"
KERNEL_DEV_HOST_PKGS_pn-uninative-tarball = "" KERNEL_DEV_HOST_PKGS_pn-buildtools-tarball = "" TOOLCHAIN_HOST_TASK_append = " ${KERNEL_DEV_HOST_PKGS}"

bitbake -c populate_sdk core-image-minimal

<extract and source sdk>

$ cat ld.so.conf
include /etc/ld.so.conf.d/*.conf
/buildarea/raid0/ovidiu/Builds/Yocto/yocto-latest/poky/build/tmp/deploy/sdk/sdk/sysroots/x86_64-pokysdk-linux/usr/lib
/buildarea/raid0/ovidiu/Builds/Yocto/yocto-latest/poky/build/tmp/deploy/sdk/sdk/sysroots/x86_64-pokysdk-linux/lib
include /etc/ld.so.conf
$ cat test.c
int main()
{
    return 0;
}
$ gcc -o test test.c -lcrypto
/buildarea/raid0/ovidiu/Builds/Yocto/yocto-latest/poky/build/tmp/deploy/sdk/sdk/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/10.1.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `__libc_vfork@GLIBC_PRIVATE'
collect2: error: ld returned 1 exit status

Before this change:

$ gcc -o test test.c -lcrypto
$ echo $?
0

Also, it seems that the scenario in which the SDK provides its own /etc/ld.so.conf and other nativesdk packages append to it did not operate correctly even before commit 7ec84a463ad4c45aee9cd2cbc75b43e5aab5cd18, because host paths would be appended instead of SDK paths.

Maybe we should try in create_sdk_files to prepend all existing paths from /etc/ld.so.conf with ${SDK_OUTPUT}/${SDKPATHNATIVE} to solve this overwrite problem?

Ovidiu

Quoted 4 lines
meta/classes/populate_sdk_base.bbclass +0 -0
  python check_sdk_sysroots() {