Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
FS#70688 - [aarch64-linux-gnu-gcc] Can't link a simple C program using custom --sysroot
Attached to Project:
Community Packages
Opened by João Maia (jpmmaia) - Monday, 03 May 2021, 07:26 GMT
Last edited by Toolybird (Toolybird) - Monday, 24 October 2022, 00:31 GMT
Opened by João Maia (jpmmaia) - Monday, 03 May 2021, 07:26 GMT
Last edited by Toolybird (Toolybird) - Monday, 24 October 2022, 00:31 GMT
|
DetailsDescription:
Running `aarch64-linux-gnu-gcc hello.c` works fine. However, `aarch64-linux-gnu-gcc --sysroot=/path/to/custom/sysroot hello.c` produces the following errors: ``` /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6 /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/libc.so.6 /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6 /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc_nonshared.a when searching for /lib/libc_nonshared.a /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/libc_nonshared.a /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc_nonshared.a when searching for /lib/libc_nonshared.a /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/ld-linux-aarch64.so.1 ``` I have the `community/aarch64-linux-gnu-glibc` package installed. Additional info: * package version(s): community/aarch64-linux-gnu-gdb 10.1-2 ; community/aarch64-linux-gnu-glibc 2.33-1 Steps to reproduce: The above problem happens when using a custom ARM64 sysroot created using debootstrap. However, the same happens if I do the following: ``` $ cp -r /usr/aarch64-linux-gnu . $ aarch64-linux-gnu-gcc --sysroot=$(pwd)/aarch64-linux-gnu hello.c /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6 /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/libc.so.6 /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6 /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc_nonshared.a when searching for /lib/libc_nonshared.a /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/libc_nonshared.a /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc_nonshared.a when searching for /lib/libc_nonshared.a /usr/lib/gcc/aarch64-linux-gnu/10.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/ld-linux-aarch64.so.1 ``` However, this works fine: `$ aarch64-linux-gnu-gcc --sysroot=/usr/aarch64-linux-gnu hello.c` |
This task depends upon
echo "int main() {return 0;}" > test.c
aarch64-linux-gnu-gcc --sysroot=/path/to/custom/sysroot test.c
/usr/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6
/usr/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/libc.so.6: file in wrong format
/usr/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc.so.6 when searching for /lib/libc.so.6
/usr/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc_nonshared.a when searching for /lib/libc_nonshared.a
/usr/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/libc_nonshared.a: file in wrong format
/usr/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: skipping incompatible /lib/libc_nonshared.a when searching for /lib/libc_nonshared.a
/usr/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/ld-linux-aarch64.so.1: No such file or directory
collect2: error: ld returned 1 exit status
Seems like ld ignores the --sysroot option and searches libraries in /.
If it's of any use, here is the output of aarch64-linux-gnu-gcc -v:
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/12.2.0/lto-wrapper
Target: aarch64-linux-gnu
Configured with: /build/aarch64-linux-gnu-gcc/src/gcc-12.2.0/configure --prefix=/usr --program-prefix=aarch64-linux-gnu- --with-local-prefix=/usr/aarch64-linux-gnu --with-sysroot=/usr/aarch64-linux-gnu --with-build-sysroot=/usr/aarch64-linux-gnu --with-native-system-header-dir=/include --libdir=/usr/lib --libexecdir=/usr/lib --target=aarch64-linux-gnu --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-nls --enable-default-pie --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (GCC)
For reference, here is the output of aarch64-linux-gnu-gcc -v on Ubuntu 18.04, where there is no such issue:
Using built-in specs.
COLLECT_GCC=aarch64-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/aarch64-linux-gnu/7/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include
Thread model: posix
gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04)
FS#76279.gcc correctly find /usr/aarch64-linux-gnu/lib/libc.so. But the file is an ld script that points to /lib/libc.so.6. If you manually modify the script to point to /usr/aarch64-linux-gnu/lib/libc.so.6, it will work.
For comparison, /usr/aarch64-linux-gnu/lib/libc.so points to /usr/aarch64-linux-gnu/lib/libc.so.6 on Debian.
The libc.so ld script is generated here
https://sourceware.org/git/?p=glibc.git;a=blob;f=Makerules;h=d1e139d03c1c448e14aee35af3e54ee7abe2180c;hb=refs/tags/glibc-2.36#l1040
I suppose we need to make sure slibdir expands to /usr/aarch64-linux-gnu/lib