penny
1
I’m trying to cross compile the following program called hello.c on Ubuntu22.04 x86_64 to aarch64:
void main(){}
I installed the following two dependencies:
apt-get install g++-aarch64-linux-gnu lld
The Clang version is 14.0.0.
When I compile using command clang --target=aarch64-none-linux-gnu -fuse-ld=lld hello.c -o hello --sysroot=/usr/aarch64-linux-gnu -v
, I get the following error:
ld.lld: error: /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/lib/libc.so:5: cannot find /usr/aarch64-linux-gnu/lib/libc.so.6 inside /usr/aarch64-linux-gnu
>>> GROUP ( /usr/aarch64-linux-gnu/lib/libc.so.6 /usr/aarch64-linux-gnu/lib/libc_nonshared.a AS_NEEDED ( /usr/aarch64-linux-gnu/lib/ld-linux-aarch64.so.1 ) )
>>> ^
clang: error: linker command failed with exit code 1 (use -v to see invocation)
On Ubuntu20.04 with clang10.0.0, the above command works.
However, the following command works on Ubuntu22.04 without specifying sysroot: clang --target=aarch64-none-linux-gnu -fuse-ld=lld hello.c -o hello -v
.
I’m wondering what changed from clang10 to clang14 that caused this behaviour? Do I still need sysroot?