-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] clang driver fails to find headers/libraries when specified --gcc-install-dir or --gcc-toolchain or --sysroot to a cross-compiler directory #114210
Comments
@llvm/issue-subscribers-clang-driver Author: Bin Meng (lbmeng)
I am trying to use clang 18 to cross compile a program for Arm 32-bit target.
The clang 18 was installed from the official LLVM Ubuntu repository following the instructions [here](https://apt.llvm.org/).
The GCC toolchain I was using is from bootlin. The rough GCC toolchain directory layout is:
Compiling a simple program using:
clang-18 complains Changing to use Then I found a workaround to help locate the header file by creating a symbolic link
Then I removed
I realized the new clang compiler driver defaults to use ld.lld, so I added
The libgcc.a is located in the bootlin gcc toolchain directorty here:
So I added
I gave up here. So what is the expected way of using clang to cross-compile a program and using libraries from a gcc cross-toolchain? |
I am trying to use clang 18 to cross compile a program for Arm 32-bit target.
The clang 18 was installed from the official LLVM Ubuntu repository following the instructions here.
The GCC toolchain I was using is from bootlin.
The rough GCC toolchain directory layout is:
Compiling a simple program using:
clang-18 complains
--gcc-toolchain
is unused. Changing to use--gcc-install-dir
does not make it better. The same unused argument warning was thrown. By looking at the documentation, the doc does not mention how exactly these 2 options affects what behavior of clang.Changing to use
--sysroot
failed too. The sysroot value was obtained from the result of/path/to/bootlin/toolchain/bin/arm-buildroot-linux-gnueabihf-gcc --print-sysroot
.Then I found a workaround to help locate the header file by creating a symbolic link
include
to point tousr/include
in the sysroot directory when usingThen I removed
-c
to see if I can compile and link the program correctly, I got:I realized the new clang compiler driver defaults to use ld.lld, so I added
-fuse-ld=/path/to/bootlin/toolchain/bin/arm-buildroot-linux-gnueabihf-ld
in the command line, which made clang to successfully locate libc and libm libraries, but not libgcc.The libgcc.a is located in the bootlin gcc toolchain directorty here:
So I added
-L/path/to/bootlin/toolchain/lib/gcc/arm-buildroot-linux-gnueabihf/12.3.0
in the command line, then libgcc was located by clang, but the final linking procedure still complained:I gave up here. So what is the expected way of using clang to cross-compile a program and using libraries from a gcc cross-toolchain?
The text was updated successfully, but these errors were encountered: