Bug 240717 - Building kernel fails when using linker from llvm ports
Summary: Building kernel fails when using linker from llvm ports
Status: Closed Overcome By Events
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-09-20 21:51 UTC by sid
Modified: 2021-10-12 04:53 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sid 2019-09-20 21:51:32 UTC
When building a kernel using llvm70 and llvm80, I got this error message.

 kernel.full
 ld.lld: error: unknown -z value: common-page-size=4096

This error doesn't occur when building the base system or for a few ports. Also, this error happens when building a kernel after a basesystem was rebuilt without linker in it.

Because LD is not working from make.conf, I softlinked /usr/bin/ld to llvm's different linkers from ports.

When I softlinked /usr/bin/ld to /local/x86_64-unknown-freebsd12.0/bin/ld (binutil's linker) this worked.

This error may be likely with other llvm versions too, and also for other architectures.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2019-09-23 19:59:08 UTC
It looks like you are attempting to defeat the linker detection mechanism in /usr/share/mk/bsd.linker.mk, and succeeding. :)

If you say "building a kernel using llvm70 and llvm80", can you describe exactly how you are doing this?  As far as I know, it is not possible to build anything with two different compilers at the same time.

Note that symlinking /usr/bin/ld to something random might or might not work, your mileage may vary (a lot).

I think that in your case, overriding LINKER_TYPE might be the best approach.  E.g. if you symlink /usr/bin/ld to a ports version of lld, it is safest to put LINKER_TYPE=lld in your environment or make.conf.

All that said, it would be much easier if you just used any of the devel/xtoolchain-llvm[6-9]0 ports.
Comment 2 sid 2019-09-23 22:39:23 UTC
Thank you.

I meant that at different times, that the compiler and linker from llvm70 and llvm80 from ports operated the same way.

LD and LINKER_TYPE had to both be set to the same linker in make.conf for it to start compiling the kernel, but it didn't work for compiling the world. This was after removing the ld link.

When I used devel/xtoolchain-llvm* in the past, it gave an instruction to use an X prefix in from of CC, CXX, CPP and LD to XCC, XCXX ... I believe that's all it does. The X prefix is an override for the ports tree.

It seems that the error messages for the linker should be observed in stable, current and the later linker versions from ports. It may not be necessary for in 12.0, except for llvm90 for consistency in future versions.