This test assumes that the driver will set -object_path_lto linker
flag and it requests the platform linker with -fuse-ld=. When lld is
used as the host linker, the host linker version is unset and so
Clang won't set -object_path_lto since that flag is set conditionally
only when linker version is at least 116. We set the linker version
explicitly to make sure that -object_path_lto is set. That approach
is already used elsewhere in the test.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
It already does, see https://github.com/llvm/llvm-project/blob/afc2f024462951d6e74c5e733f4b4666e21d3309/clang/lib/Driver/ToolChains/Darwin.cpp#L232, but in this particular case the test is explicitly requesting the platform linker by passing -fuse-ld=.
Comment Actions
Ohh gotcha. So clang assumes that the platform linker's version is at least as high as the host linker's, assuming the host linker is ld64. That seems kind of hacky, but I suppose it's existing behavior...
Comment Actions
I agree, I don't think that the version of the host linker on the system where Clang was built should affect driver's behavior. Ideally, Clang would check the linker version dynamically but that would be a change to the existing behavior and I don't know if that would cause problems.