-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Have the frontend and new swift-driver look in an external -sdk
for non-Darwin platform runtime libraries and modules too
#79621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2319,6 +2319,7 @@ static bool validateSwiftModuleFileArgumentAndAdd(const std::string &swiftModule | |
|
||
static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args, | ||
DiagnosticEngine &Diags, | ||
const llvm::Triple &Triple, | ||
const CASOptions &CASOpts, | ||
const FrontendOptions &FrontendOpts, | ||
StringRef workingDirectory) { | ||
|
@@ -2453,6 +2454,18 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args, | |
|
||
if (const Arg *A = Args.getLastArg(OPT_resource_dir)) | ||
Opts.RuntimeResourcePath = A->getValue(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @etcwilde, just so it's clear what I'm talking about, If you guys have changed your mind on what that doc says, please let us know what the new plan is. |
||
else if (!Triple.isOSDarwin() && Args.hasArg(OPT_sdk)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code explicitly follows what the original C++ Driver has long done when looking for the Swift runtime libraries,
Note how the SDK is only looked in if a non-Darwin That C++ Driver setup now matches this Frontend setup, because the default in both is now to look relative to the compiler, which is done first in this Frontend here, ie This is important for two reasons:
However, unlike the C++ Driver, my We should probably tighten this up to require an explicit |
||
llvm::SmallString<128> SDKResourcePath(Opts.getSDKPath()); | ||
llvm::sys::path::append( | ||
SDKResourcePath, "usr", "lib", | ||
FrontendOpts.UseSharedResourceFolder ? "swift" : "swift_static"); | ||
// Check for eg <sdkRoot>/usr/lib/swift/ | ||
if (llvm::sys::fs::exists(SDKResourcePath)) | ||
Opts.RuntimeResourcePath = SDKResourcePath.str(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line confuses me. The compiler resource dir should be relative to the compiler. Updating it to point into the SDK seems suspicious to me.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the This change brings back what the legacy C++ Driver did, which is look in the I know that you would like to split up the |
||
else | ||
Diags.diagnose(SourceLoc(), diag::warning_no_resource_dir_in_sdk, | ||
Opts.RuntimeResourcePath); | ||
} | ||
|
||
Opts.SkipAllImplicitImportPaths |= Args.hasArg(OPT_nostdimport); | ||
Opts.SkipSDKImportPaths |= Args.hasArg(OPT_nostdlibimport); | ||
|
@@ -4142,7 +4155,7 @@ bool CompilerInvocation::parseArgs( | |
|
||
ParseSymbolGraphArgs(SymbolGraphOpts, ParsedArgs, Diags, LangOpts); | ||
|
||
if (ParseSearchPathArgs(SearchPathOpts, ParsedArgs, Diags, | ||
if (ParseSearchPathArgs(SearchPathOpts, ParsedArgs, Diags, LangOpts.Target, | ||
CASOpts, FrontendOpts, workingDirectory)) { | ||
return true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, why are we not preferring
-sdk
paths?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the Frontend change is made for non-Darwin, the
RuntimeResourcePath
in the very next block has been set to<-sdk>/usr/lib/swift
, so this explicitgetSDKPath()
check is not needed when targeting non-Darwin. 😺