I have added native gcc support to an ARM Yocto SDK. But the native compiler 
does not work when passing the sysroot argument to the compiler. 

kenth@se-kenth-lx yocto-xr $ x86_64-xr-linux-gcc test.c
kenth@se-kenth-lx yocto-xr $ x86_64-xr-linux-gcc test.c 
--sysroot=/opt/infn-xr/1.0/sysroots/x86_64-xr-linux
/opt/infn-xr/1.0/sysroots/x86_64-xr-linux/usr/lib/gcc/x86_64-xr-linux/9.2.0/../../../../x86_64-xr-linux/bin/ld:
 cannot find /opt/infn-xr/1.0/sysroots/x86_64-xr-linux/lib/libc.so.6 inside 
/opt/infn-xr/1.0/sysroots/x86_64-xr-linux
/opt/infn-xr/1.0/sysroots/x86_64-xr-linux/usr/lib/gcc/x86_64-xr-linux/9.2.0/../../../../x86_64-xr-linux/bin/ld:
 cannot find /opt/infn-xr/1.0/sysroots/x86_64-xr-linux/usr/lib/libc_nonshared.a 
inside /opt/infn-xr/1.0/sysroots/x86_64-xr-linux
/opt/infn-xr/1.0/sysroots/x86_64-xr-linux/usr/lib/gcc/x86_64-xr-linux/9.2.0/../../../../x86_64-xr-linux/bin/ld:
 cannot find /opt/infn-xr/1.0/sysroots/x86_64-xr-linux/lib/ld-linux-x86-64.so.2 
inside /opt/infn-xr/1.0/sysroots/x86_64-xr-linux
collect2: error: ld returned 1 exit status

Error trace seems to incorrectly tell that libc is missing on that path

kenth@se-kenth-lx yocto-xr $ ls -l 
/opt/infn-xr/1.0/sysroots/x86_64-xr-linux/lib/libc.so.6
lrwxrwxrwx 1 root root 12 Jan 11 10:33 
/opt/infn-xr/1.0/sysroots/x86_64-xr-linux/lib/libc.so.6 -> libc-2.30.so*
kenth@se-kenth-lx yocto-xr $

The sysroot argument works when only compiling the source file (no linking)
kenth@se-kenth-lx yocto-xr $ x86_64-xr-linux-gcc -c test.c -o test.o 
--sysroot=/opt/infn-xr/1.0/sysroots/x86_64-xr-linux

But when gcc invokes binutils with sysroot argument then it fails. Doing a 
strace on the invocation of gcc with sysroot shows that sometimes the sysroot 
path is concatenated twice;

[pid  4197] openat(AT_FDCWD, 
"/opt/infn-xr/1.0/sysroots/x86_64-xr-linux//opt/infn-xr/1.0/sysroots/x86_64-xr-linux/lib/libc.so.6",
 O_RDONLY) = -1 ENOENT (No such file or directory)
[pid  4197] write(2, "/opt/infn-xr/1.0/sysroots/x86_64"..., 110) = 110

The arm compiler has a compiled sysroot (as defined in the bb recipe)
kenth@se-kenth-lx yocto-xr $ aarch64-xr-linux-gcc --print-sysroot
/not/exist
kenth@se-kenth-lx yocto-xr $

whereas the native x86 compiler does not have a compiled sysroot

kenth@se-kenth-lx yocto-xr $ x86_64-xr-linux-gcc --print-sysroot
kenth@se-kenth-lx yocto-xr $

If I symlink the path to mitigate the concatenation effect into binutils then 
it all works. 

Known issue? How to resolve?
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#51962): https://lists.yoctoproject.org/g/yocto/message/51962
Mute This Topic: https://lists.yoctoproject.org/mt/79592920/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to