This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms.
ClosedPublic

Authored by delcypher on Apr 30 2021, 7:20 PM.

Details

Summary

When the target triple was an Apple platform ToolChain::getOSLibName()
(called by getCompilerRTPath()) would return the full OS name
including the version number (e.g. darwin20.3.0). This is not correct
because the library directory for all Apple platforms is darwin.

This in turn caused

  • -print-runtime-dir to return a non-existant path.
  • -print-file-name=<any compiler-rt library> to return the filename instead of the full path to the library.

Two regression tests are included.

rdar://77417317

Diff Detail

Event Timeline

delcypher requested review of this revision.Apr 30 2021, 7:20 PM
delcypher created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 30 2021, 7:20 PM
arphaman added inline comments.Apr 30 2021, 8:12 PM
clang/lib/Driver/ToolChain.cpp
404

Should this also apply to llvm::Triple::MacOSX , iOS, and other Darwin OSes?

delcypher updated this revision to Diff 342152.May 1 2021, 7:53 AM
  • Support other Apple target triples.
delcypher marked an inline comment as done.May 1 2021, 7:54 AM
delcypher added inline comments.
clang/lib/Driver/ToolChain.cpp
404

Good catch. I've fixed this.

delcypher retitled this revision from [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Darwin. to [Driver] Fix `ToolChain::getCompilerRTPath()` to return the correct path on Apple platforms..May 1 2021, 7:55 AM
delcypher edited the summary of this revision. (Show Details)
delcypher marked an inline comment as done.May 3 2021, 5:14 PM
arphaman accepted this revision.May 4 2021, 9:05 AM

LGTM, the only suggestion I have is below.

clang/lib/Driver/ToolChain.cpp
405

It might be cleaner to do a check for isOSDarwin here, as that will help with any other Darwin platforms that we need to support.

This revision is now accepted and ready to land.May 4 2021, 9:05 AM
delcypher updated this revision to Diff 342809.May 4 2021, 11:20 AM
delcypher edited the summary of this revision. (Show Details)

Use isOSDarwin() instead of explicitly checking Darwin OS enum values.

delcypher marked an inline comment as done.May 4 2021, 11:21 AM
delcypher added inline comments.
clang/lib/Driver/ToolChain.cpp
405

@arphaman That seems like a good idea. I didn't know this API existed. I'll try to switch to that.

delcypher marked an inline comment as done.May 4 2021, 11:22 AM
arphaman accepted this revision.May 4 2021, 11:25 AM
This revision was landed with ongoing or failed builds.May 4 2021, 11:28 AM
This revision was automatically updated to reflect the committed changes.