Skip to contentSkip to conversation

Bad lib symlink in Host SDK

DISCUSSION Lukas Weiß 2 participants 6 messages May 29, 2024 – Jun 8, 2024

lore
Share & tools
lore
#0 lore raw

Hi together,

i have a question about Yocto SDK generation. We use the Yocto-SDK not only for generation of target binaries outside the Yocto Build process, but also for generation of the same binaries *for the host* (nativesdk). This way we are able to run our applications as Simulations or Unit-Tests in our CI process without the need to install dev- and runtime libs on the host system (also the libs have the same build configuration as on target).

Unfortunately, the SDK doesn't really seem to be designed for this. The BB classes for the native/nativesdk are also missing for most libraries. And last but not least, I still have the feeling that I haven't really found the "right" way to define the SDK. Whatever.

I'm currently trying to add the libudev (yes, i know that its probably not the best idea to add a system lib to host sdk ;-). I added an eudev_%.bbappend file containing

Quoted 3 lines

BBCLASSEXTEND = "native nativesdk"

and appended "nativesdk-eudev" and "nativesdk-eudev-dev" to the RDEPENDS of my nativesdk-packagegroup-sdk-host recipe.

This works, but unfortunately the resulting installed SDK has a wrong symlink for the hosts libudev.so:

Quoted 9 lines

/home/admin/sdk/plat/5.0/sysroots/x86_64-platsdk-linux/usr/lib/libudev.so
-> ../../../../../../home/admin/sdk/plat/5.0/sysroots/x86_64-platsdk-linux/lib/libudev.so.1.6.3

The correct link would be

Quoted 3 lines

/home/admin/sdk/plat/5.0/sysroots/x86_64-platsdk-linux/usr/lib/libudev.so -> ../../lib/libudev.so.1.6.3

This must happen on SDK installation, as the install path is not known before. All other links in SDK ( *including the link for target libudev.so* ) are correct. Do you have any hints for me how i can dig into this? All debug methods i know belong to built process itself, not the install.

My Yocto version is "yocto-5.0" Tag in Repo.

#1 lore raw

Is the link correct when nativesdk-udev is built and packaged or is it already broken at that point?

Generally you should take the trouble to spin up qemu and run the tests in that.

Alex

Quoted 53 lines · Lukas Weiß via lists.yoctoproject.org

Hi together,

i have a question about Yocto SDK generation. We use the Yocto-SDK not only for generation of target binaries outside the Yocto Build process, but also for generation of the same binaries *for the host* (nativesdk). This way we are able to run our applications as Simulations or Unit-Tests in our CI process without the need to install dev- and runtime libs on the host system (also the libs have the same build configuration as on target).

Unfortunately, the SDK doesn't really seem to be designed for this. The BB classes for the native/nativesdk are also missing for most libraries. And last but not least, I still have the feeling that I haven't really found the "right" way to define the SDK. Whatever.

I'm currently trying to add the libudev (yes, i know that its probably not the best idea to add a system lib to host sdk ;-). I added an eudev_%.bbappend file containing

BBCLASSEXTEND = "native nativesdk"

and appended "nativesdk-eudev" and "nativesdk-eudev-dev" to the RDEPENDS of my *nativesdk-packagegroup-sdk-host* recipe.

This works, but unfortunately the resulting installed SDK has a wrong symlink for the hosts libudev.so:

/home/admin/sdk/plat/5.0/sysroots/x86_64-platsdk-linux/usr/lib/libudev.so
-> ../../../../../../home/admin/sdk/plat/5.0/sysroots/x86_64-platsdk-linux/lib/libudev.so.1.6.3

The correct link would be

/home/admin/sdk/plat/5.0/sysroots/x86_64-platsdk-linux/usr/lib/libudev.so -> ../../lib/libudev.so.1.6.3

This must happen on SDK installation, as the install path is not known before. All other links in SDK (*including the link for target libudev.so*) are correct.
Do you have any hints for me how i can dig into this? All debug methods i know belong to built process itself, not the install.

My Yocto version is "yocto-5.0" Tag in Repo.
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#63227):
https://lists.yoctoproject.org/g/yocto/message/63227
Mute This Topic: https://lists.yoctoproject.org/mt/106368600/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw

Hallo Alexander,

how can i see if the link is broken on build or packaging? Since the path of the broken link can't be known on build process (it was entered in install process of SDK sh installer), i will not be able to find it somewhere in logs or env. It must be some kind of variable that is used here, but i have no idea which one. Note that the broken link os not only the wrong directory depth - the parent-dir dots only lead to /home/admin/sdk (not root).

Since we use host SDK not only for tests, but also for partial "Simulations" with real devices connected, qemu is not the best choice. The pain is just on another end.

#3 lore raw
Quoted 1 line · Lukas Weiß via Lists.Yoctoproject.Org

how can i see if the link is broken on build or packaging? Since the path of the broken link can't be known on build process (it was entered in install process of SDK sh installer), i will not be able to find it somewhere in logs or env. It must be some kind of variable that is used here, but i have no idea which one. Note that the broken link os not only the wrong directory depth - the parent-dir dots only lead to /home/admin/sdk (not root).

You need to look in ${WORKDIR} of nativesdk-udev, specifically, under image/ package/ packages/split/ directories. Links like that are typically created already at that stage, so is it correct then?

Quoted 1 line

Since we use host SDK not only for tests, but also for partial "Simulations" with real devices connected, qemu is not the best choice. The pain is just on another end.

It's just not a supported use case and you're entirely on your own trying to make it work. nativesdk- is meant only for building toolchains and their dependencies; any target items should be built for the target and deployed to physical hardware or qemu.

Alex

#4 lore raw

Sorry, was busy with something else.

Thanks for the hint. I think, i found the reason: The Links is already broken on install. Its part of the Autotools Install of the eudev project (src/libudev/Makefile.in):

Quoted 15 lines

install-exec-hook:
libname=libudev.so; if test "$(libdir)" != "$(rootlibdir)"; then \
$(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \
so_img_rel_target_prefix=$$(echo $(libdir) | sed 's,\(^/\)\?[^/]\+,..,g') && \
$(LN_S) -f $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name $(DESTDIR)$(libdir)/$$libname && \
mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \
fi

In Case of nativesdk, this leads to bad results, as all of these paths a prefixed with default SDK path (/opt/plat_sdk/sysroots/x86_64-platsdk-linux in my case):

Quoted 16 lines

libname=libudev.so; if test
"/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib" !=
"/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib"; then \
/home/admin/workspaces/yocto/build/tmp/hosttools/mkdir -p /home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib && \
so_img_name=$(readlink /home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib/$libname) && \
so_img_rel_target_prefix=$(echo
/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib | sed
's,\(^/\)\?[^/]\+,..,g') && \
ln -s -f

Quoted 10 lines

$so_img_rel_target_prefix/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib/$so_img_name /home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib/$libname && \
mv /home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib/$libname.* /home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib; \
fi

That path seems to be replaced in all symlinks when SDK is installed to a different location than default - thats the reason for the individual bad symlinks. As a workaround i just replace the symlink with the correct one. This is very dirty, but it works and i do not have to patch eudev:

Quoted 13 lines

do_install:append:class-nativesdk() {
# Workaround to fix libudev.so symlink in nativesdk
ln -s -f ../../lib/$(basename $(readlink -f ${D}${libdir}/libudev.so)) ${D}${libdir}/libudev.so.new
rm -f ${D}${libdir}/libudev.so
mv ${D}${libdir}/libudev.so.new ${D}${libdir}/libudev.so
}

Thanks for help!

#5 lore raw

You should open a ticket with eudev though or submit a patch there.

Alex

Quoted 59 lines · Lukas Weiß via Lists.Yoctoproject.Org

Sorry, was busy with something else.

Thanks for the hint. I think, i found the reason: The Links is already broken on install. Its part of the Autotools Install of the eudev project (src/libudev/Makefile.in):

install-exec-hook:

    libname=libudev.so; if test "$(libdir)" != "$(rootlibdir)"; then \
        $(MKDIR_P) $(DESTDIR)$(rootlibdir) && \
        so_img_name=$$(readlink $(DESTDIR)$(libdir)/$$libname) && \
        so_img_rel_target_prefix=$$(echo $(libdir) | sed
's,\(^/\)\?[^/]\+,..,g') && \
        $(LN_S) -f $$so_img_rel_target_prefix$(rootlibdir)/$$so_img_name
$(DESTDIR)$(libdir)/$$libname && \
        mv $(DESTDIR)$(libdir)/$$libname.* $(DESTDIR)$(rootlibdir); \
    fi

In Case of nativesdk, this leads to bad results, as all of these paths a prefixed with default SDK path (/opt/plat_sdk/sysroots/x86_64-platsdk-linux in my case):

libname=libudev.so; if test
"/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib" !=
"/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib"; then \
/home/admin/workspaces/yocto/build/tmp/hosttools/mkdir -p
/home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib && \
so_img_name=$(readlink
/home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib/$libname) && \
so_img_rel_target_prefix=$(echo
/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib | sed
's,\(^/\)\?[^/]\+,..,g') && \
ln -s -f
$so_img_rel_target_prefix/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib/$so_img_name /home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib/$libname && \
mv
/home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/usr/lib/$libname.* /home/admin/workspaces/yocto/build/tmp/work/x86_64-nativesdk-platsdk-linux/nativesdk-eudev/3.2.14/image/opt/plat_sdk/sysroots/x86_64-platsdk-linux/lib; \
fi

That path seems to be replaced in all symlinks when SDK is installed to a different location than default - thats the reason for the individual bad symlinks.
As a workaround i just replace the symlink with the correct one. This is very dirty, but it works and i do not have to patch eudev:

do_install:append:class-nativesdk() {
# Workaround to fix libudev.so symlink in nativesdk
ln -s -f ../../lib/$(basename $(readlink -f ${D}${libdir}/libudev.so))
${D}${libdir}/libudev.so.new

    rm -f ${D}${libdir}/libudev.so
    mv ${D}${libdir}/libudev.so.new ${D}${libdir}/libudev.so
}

Thanks for help!