On Fri, 17 Dec 2021 11:27:43 GMT, Gilles Duboscq <g...@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.

This pull request has now been integrated.

Changeset: b17f8d5b
Author:    Gilles Duboscq <g...@openjdk.org>
URL:       
https://git.openjdk.java.net/jdk/commit/b17f8d5b6c4d4ec75bb57f1d2009e30332bdb3ce
Stats:     15 lines in 1 file changed: 13 ins; 0 del; 2 mod

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

Reviewed-by: erikj

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

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

Reply via email to