-
Notifications
You must be signed in to change notification settings - Fork 10.5k
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 |
---|---|---|
|
@@ -768,8 +768,8 @@ void importer::getNormalInvocationArguments( | |
invocationArgStrs.push_back("-fapinotes-swift-version=" + | ||
languageVersion.asAPINotesVersionString()); | ||
|
||
// Prefer `-sdk` paths. | ||
if (!searchPathOpts.getSDKPath().empty()) { | ||
// Prefer `-sdk` paths for Darwin. | ||
if (triple.isOSDarwin() && !searchPathOpts.getSDKPath().empty()) { | ||
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. Wait, why are we not preferring 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. Once the Frontend change is made for non-Darwin, the |
||
llvm::SmallString<261> path{searchPathOpts.getSDKPath()}; | ||
llvm::sys::path::append(path, "usr", "lib", "swift", "apinotes"); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2283,6 +2283,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) { | ||
|
@@ -2417,6 +2418,18 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts, ArgList &Args, | |
|
||
if (const Arg *A = Args.getLastArg(OPT_resource_dir)) | ||
Opts.RuntimeResourcePath = A->getValue(); | ||
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(); | ||
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); | ||
|
@@ -4082,7 +4095,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.
This feels wrong. I don't think that we should be trying to format with indentation here. Do any other warnings try to do this?
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.
I thought it read better, but had not finalized it yet. I will look at the other warnings next and match them.