This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Set -mlinker-version explicitly in the lto test
ClosedPublic

Authored by phosek on Mar 20 2022, 6:01 PM.

Details

Summary

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.

Diff Detail

Event Timeline

phosek created this revision.Mar 20 2022, 6:01 PM
phosek requested review of this revision.Mar 20 2022, 6:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2022, 6:01 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
int3 added a comment.Mar 20 2022, 7:20 PM

Would it make sense to have clang pass -object_path_lto whenever it's invoking LLD?

Would it make sense to have clang pass -object_path_lto whenever it's invoking LLD?

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=.

int3 accepted this revision.Mar 20 2022, 11:26 PM

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...

This revision is now accepted and ready to land.Mar 20 2022, 11:26 PM

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...

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.

This revision was automatically updated to reflect the committed changes.