RFR: 8278954: Using clang together with devkit on linux doesn't work for building

Erik Joelsson erikj at openjdk.java.net
Fri Dec 17 13:38:19 UTC 2021


On Fri, 17 Dec 2021 11:27:43 GMT, Gilles Duboscq <gdub at openjdk.org> wrote:

> When running `configure`, using `--with-devkit=` to point to a typical linux devkit along with `--with-toolchain-path=` and `--with-toolchain-type=clang` to point to a clang-based toolchain results in:
> 
> configure:75064: checking whether the C compiler works
> configure:75086: /dl/tools/clang -m64 -isysroot /dl/x86_64-linux-gnu-to-x86_64-linux-gnu/x86_64-linux-gnu/sysroot -isysroot /dl/x86_64-linux-gnu-to-x86_64-linux-gnu/x86_64-linux-gnu/sysroot -m64 -isysroot /dl/x86_64-linux-gnu-to-x86_64-linux-gnu/x86_64-linux-gnu/sysroot conftest.c >&5
> d.lld: error: cannot open crt1.o: No such file or directory
> ld.lld: error: cannot open crti.o: No such file or directory
> ld.lld: error: cannot open crtbegin.o: No such file or directory
> ld.lld: error: unable to find library -lgcc
> ld.lld: error: unable to find library -lgcc_s
> ld.lld: error: unable to find library -lc
> ld.lld: error: unable to find library -lgcc
> ld.lld: error: unable to find library -lgcc_s
> ld.lld: error: cannot open crtend.o: No such file or directory
> ld.lld: error: cannot open crtn.o: No such file or directory
> clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
> ``` 
> This is because clang is unable to locate the gcc installation from the devkit.
> The gcc toolchain is not in the location clang expects in the sysroot (that's not how our devkits are structured).
> Note that it might go unnoticed on machines that have gcc installed because clang will fallback to system-global locations.
> 
> We can help clang by letting it now about the gcc location in the devkit with `--gcc-toolchain=`.
> However that's not enough and we then get:
> 
> ld.lld: error: cannot open crt1.o: No such file or directory
> ld.lld: error: cannot open crti.o: No such file or directory
> ld.lld: error: unable to find library -lc
> ld.lld: error: cannot open crtn.o: No such file or directory
> 
> clang was able to locate the gcc support libraries but is not able to locate required system libraries.
> That's because `-isysroot` is not intended for libraries (only headers) but also because `-isysroot` has no effect for clang on linux (see [llvm#11503](https://bugs.llvm.org/show_bug.cgi?id=11503)).
> Using `--sysroot=` in this case (clang on linux) resolves this issue.

Marked as reviewed by erikj (Reviewer).

-------------

PR: https://git.openjdk.java.net/jdk/pull/6880



More information about the build-dev mailing list