Re: [yocto] Handling sysroots

Xaver Gruber <[email protected]> Mon, 4 May 2026 21:28:28 +0200
Newsgroups org.yoctoproject.lists.yocto
Message-ID <CACxWsr5Y0t2kFZW7G+vZZ6GfMxwaQ1vf8u_9F5Udeu99+u09Eg@mail.gmail.com>
Following up to this.
I am maintaining a meta Swift layer. Swift compiles clang as well and
therefore the conflict.
I introduced a clang bbappend file with this content in order to have a
custom clang native path:
CLANG_NATIVE_DIR = "${STAGING_BINDIR_NATIVE}/clang-native"
EXTRA_OECMAKE:append:class-native = "
-DCMAKE_INSTALL_PREFIX=${CLANG_NATIVE_DIR}"
SYSROOT_DIRS:append:class-native = " ${CLANG_NATIVE_DIR}"

When ld.ldd runs, it is not able to find libLLVM.so.18.1(from
$CLANG_NATIVE_DIR/lib)
I tried this and several other flags with no success:
EXTRA_OECMAKE:append:class-native = "
-DCMAKE_INSTALL_RPATH='\$ORIGIN/../lib'"

This is the log:
bitbake -c devshell swift-native
ldd /home/xaver/code/meta-swift-examples/builds/build-qemuarm/tmp-glibc/w
ork/x86_64-linux/swift-native/repro/recipe-sysroot-native/usr/bin/clang-native/bin/ld.lld
        linux-vdso.so.1 (0x000074223b123000)
        libz.so.1 =>
/home/xaver/code/meta-swift-examples/builds/build-qemuarm/tmp-glibc/work/x86_64-linux/swift-native/repro/recipe-sysroot-native/usr/bin/clang-native/bin/../../../lib/libz.so.1
(0x000074223b101000)
        libzstd.so.1 =>
/home/xaver/code/meta-swift-examples/builds/build-qemuarm/tmp-glibc/work/x86_64-linux/swift-native/repro/recipe-sysroot-native/usr/bin/clang-native/bin/../../../lib/libzstd.so.1
(0x000074223b03d000)
        libLLVM.so.18.1 => not found
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6
(0x000074223a7d4000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x000074223b015000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x000074223a5ab000)
        /lib64/ld-linux-x86-64.so.2 (0x000074223b125000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x000074223a4c4000)


readelf -d
/home/xaver/code/meta-swift-examples/builds/build-qemuarm/tmp-ive/repro/recipe-sysroot-native/usr/bin/clang-native/bin/ld.lld
glibc/work/x86_64-linux/swift-native/repro/recipe-sysroot-native/usr/bin/clang-native/bin/clang

Dynamic section at offset 0x27288 contains 32 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library:
[libclang-cpp.so.18.1]
 0x0000000000000001 (NEEDED)             Shared library: [libLLVM.so.18.1]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000001d (RUNPATH)            Library runpath:
[$ORIGIN/../../../lib:$ORIGIN/../../../../lib:$ORIGIN/../../../lib]
 0x000000000000000c (INIT)               0xa000
 0x000000000000000d (FINI)               0x23e0c
 0x0000000000000019 (INIT_ARRAY)         0x28188
 0x000000000000001b (INIT_ARRAYSZ)       16 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x28198
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x3b0
 0x0000000000000005 (STRTAB)             0x2a18
 0x0000000000000006 (SYMTAB)             0x558
 0x000000000000000a (STRSZ)              19292 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x284c8
 0x0000000000000002 (PLTRELSZ)           7968 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x7ef8
 0x0000000000000007 (RELA)               0x7988
 0x0000000000000008 (RELASZ)             1392 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW PIE
 0x000000006ffffffe (VERNEED)            0x7888
 0x000000006fffffff (VERNEEDNUM)         4
 0x000000006ffffff0 (VERSYM)             0x7574
 0x000000006ffffff9 (RELACOUNT)          20
 0x0000000000000000 (NULL)               0x0

Adjusting libary runpath, it should find it.
How to make it find it? What are the flags that I need to set in clang
bbappend?

Best regards,
Xaver Gruber

Am Do., 23. Apr. 2026 um 21:51 Uhr schrieb Khem Raj <[email protected]>:

>
>
> On Thu, Apr 23, 2026 at 11:04 AM Xaver Gruber via lists.yoctoproject.org
> <[email protected]> wrote:
>
>> Hey guys,
>>
>>
>> Clang-native builds clang, however I have another native, let us call it
>> native X, building clang as well. I get an error that it is duplicated in
>> global sysroot. I only need clang-native to build native X. How do I make
>> sure clang-native does not reach global sysroot, however still being
>> available for native X?
>>
>
> Well, it will not be easy, you might need to carve out directories to put
> the conflicting files in or rename files. why would you not be able to use
> clang-native ?
> we just started to use same llvm across clang, mesa and rust e.g. so we
> are moving in towards consolidation, which makes your ask even harder
>
>
>> Best regards,
>> Xaver Gruber
>>
>> -=-=-=-=-=-=-=-=-=-=-=-
>> Links: You receive all messages sent to this group.
>> You automatically follow any topics you start or reply to.
>> View/Reply Online (#66436):
>> https://lists.yoctoproject.org/g/yocto/message/66436
>> Mute This Topic: https://lists.yoctoproject.org/mt/118976274/1997914
>> Group Owner: [email protected]
>> Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [
>> [email protected]]
>> -=-=-=-=-=-=-=-=-=-=-=-
>>
>>