Page MenuHomePhabricator

[clang][cmake] Force CMAKE_LINKER for multistage build in case of BOOTSTRAP_LLVM_ENABLE_LLD and MSVC
Needs ReviewPublic

Authored by krisb on May 30 2020, 11:15 AM.



(I'm trying to get a bootstrap self-build on Windows, where lld is used as a
linker for the stage2.)

I assume BOOTSTRAP_LLVM_ENABLE_LLD works the same way as LLVM_ENABLE_LLD,
but enables to use just-built lld for the next stage.

The issue with LLVM_ENABLE_LLD is that it just passes -fuse-ld=lld
to compiler/linker options which makes sense only for those platforms
where cmake invokes a compiler driver for linking.

On Windows cmake invokes a linker directly and requires CMAKE_LINKER
option to be specified otherwise it defaults CMAKE_LINKER to be link.exe.
Passing CMAKE_LINKER is easy for 1-stage builds, but it's notquite handy
to do for multistage builds, because it's not possible to know for sure
where to find just-built lld.

This patch allows BOOTSTRAP_LLVM_ENABLE_LLD to set CMAKE_LINKER in the case
of building for host Windows. It also skips adding '-fuse-ld=lld' to make
lld-link not warning about 'unknown argument'. The latter part is taken
from with additional checks that
CMAKE_LINKER doesn't contain a path to another compiler.

Diff Detail

Event Timeline

krisb created this revision.May 30 2020, 11:15 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 30 2020, 11:15 AM