-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Properly compute resource folder when linking statically #33168
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
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
#include "swift/Driver/Compilation.h" | ||
#include "swift/Driver/Driver.h" | ||
#include "swift/Driver/Job.h" | ||
#include "swift/Frontend/Frontend.h" | ||
#include "swift/Option/Options.h" | ||
#include "clang/Basic/Version.h" | ||
#include "clang/Driver/Util.h" | ||
|
@@ -533,6 +534,13 @@ ToolChain::constructInvocation(const CompileJobAction &job, | |
Arguments.push_back("-track-system-dependencies"); | ||
} | ||
|
||
if (context.Args.hasFlag(options::OPT_static_executable, | ||
options::OPT_no_static_executable, false) || | ||
context.Args.hasFlag(options::OPT_static_stdlib, | ||
options::OPT_no_static_stdlib, false)) { | ||
Arguments.push_back("-use-static-resource-dir"); | ||
} | ||
|
||
context.Args.AddLastArg( | ||
Arguments, | ||
options:: | ||
|
@@ -1266,24 +1274,18 @@ void ToolChain::getClangLibraryPath(const ArgList &Args, | |
void ToolChain::getResourceDirPath(SmallVectorImpl<char> &resourceDirPath, | ||
const llvm::opt::ArgList &args, | ||
bool shared) const { | ||
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime | ||
// library link path and the standard library module import path don't | ||
// need to be the same. | ||
if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) { | ||
StringRef value = A->getValue(); | ||
resourceDirPath.append(value.begin(), value.end()); | ||
} else if (!getTriple().isOSDarwin() && args.hasArg(options::OPT_sdk)) { | ||
StringRef value = args.getLastArg(options::OPT_sdk)->getValue(); | ||
resourceDirPath.append(value.begin(), value.end()); | ||
llvm::sys::path::append(resourceDirPath, "usr", "lib", | ||
shared ? "swift" : "swift_static"); | ||
llvm::sys::path::append(resourceDirPath, "usr"); | ||
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. Why are we adding 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. We are using the SDK root here as opposed to the path relative to the executable. In the executable case we get something like |
||
CompilerInvocation::appendSwiftLibDir(resourceDirPath, shared); | ||
} else { | ||
auto programPath = getDriver().getSwiftProgramPath(); | ||
resourceDirPath.append(programPath.begin(), programPath.end()); | ||
llvm::sys::path::remove_filename(resourceDirPath); // remove /swift | ||
llvm::sys::path::remove_filename(resourceDirPath); // remove /bin | ||
llvm::sys::path::append(resourceDirPath, "lib", | ||
shared ? "swift" : "swift_static"); | ||
CompilerInvocation::computeRuntimeResourcePathFromExecutablePath( | ||
programPath, shared, resourceDirPath); | ||
} | ||
|
||
StringRef libSubDir = getPlatformNameForTriple(getTriple()); | ||
|
Uh oh!
There was an error while loading. Please reload this page.