I'm trying to cross compile to AArch64 using clang on Ubuntu. I've installed the right packages and am able to compile successfully using a pre-packaged clang, but doing the same with a self built version causes errors over missing header files or libraries. For example:
simulator/fileoutscalarmgr.cc:22:10: fatal error: 'fstream' file not found
22 | #include <fstream>
I'm able to fix these by manually specifying include paths (I don't have to do this with pre-packaged clang), but compilation still fails at linking which I can't fix.
The outputs of clang -v
when setting --sysroot=/usr/aarch64-linux-gnu
and --target=aarch64-linux-gnu
do not match for the pre-packaged and self built clang versions. Pre-packaged is able to find everything automatically:
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/12
Selected GCC installation: /usr/bin/../lib/gcc-cross/aarch64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
While the one built from source cannot find the cross compiler libraries (has no matching output when using -v).
How can I get the clang built from source to find these libraries?
Managed to solve the problem! Inexplicitly, removing --sysroot=/usr/aarch64-linux-gnu
causes the clang built from source to work. When just using --target=aarch64-linux-gnu
it works fine. Pre-packaged is still able to work with sysroot
set for some reason though.