Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion include/swift/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ class ToolChain {
/// Get the resource dir link path, which is platform-specific and found
/// relative to the compiler.
void getResourceDirPath(SmallVectorImpl<char> &runtimeLibPath,
const llvm::opt::ArgList &args, bool shared) const;
const llvm::opt::ArgList &args, bool shared,
StringRef SDKPath) const;

/// Get the secondary runtime library link path given the primary path.
void getSecondaryResourceDirPath(
Expand Down
3 changes: 2 additions & 1 deletion lib/Driver/DarwinToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ toolchains::Darwin::addArgsToLinkStdlib(ArgStringList &Arguments,
// Link compatibility libraries, if we're deploying back to OSes that
// have an older Swift runtime.
SmallString<128> SharedResourceDirPath;
getResourceDirPath(SharedResourceDirPath, context.Args, /*Shared=*/true);
getResourceDirPath(SharedResourceDirPath, context.Args, /*Shared=*/true,
context.OI.SDKPath);
std::optional<llvm::VersionTuple> runtimeCompatibilityVersion;

if (context.Args.hasArg(options::OPT_runtime_compatibility_version)) {
Expand Down
11 changes: 5 additions & 6 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ void ToolChain::getClangLibraryPath(const ArgList &Args,
SmallString<128> &LibPath) const {
const llvm::Triple &T = getTriple();

getResourceDirPath(LibPath, Args, /*Shared=*/true);
getResourceDirPath(LibPath, Args, /*Shared=*/true, StringRef());
// Remove platform name.
llvm::sys::path::remove_filename(LibPath);
StringRef platformName = "darwin";
Expand All @@ -1619,13 +1619,12 @@ void ToolChain::getClangLibraryPath(const ArgList &Args,
/// relative to the compiler.
void ToolChain::getResourceDirPath(SmallVectorImpl<char> &resourceDirPath,
const llvm::opt::ArgList &args,
bool shared) const {
bool shared, StringRef SDKPath) const {
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());
} else if (!getTriple().isOSDarwin() && !SDKPath.empty()) {
resourceDirPath.append(SDKPath.begin(), SDKPath.end());
llvm::sys::path::append(resourceDirPath, "usr");
CompilerInvocation::appendSwiftLibDir(resourceDirPath, shared);
} else {
Expand Down Expand Up @@ -1661,7 +1660,7 @@ void ToolChain::getRuntimeLibraryPaths(SmallVectorImpl<std::string> &runtimeLibP
const llvm::opt::ArgList &args,
StringRef SDKPath, bool shared) const {
SmallString<128> scratchPath;
getResourceDirPath(scratchPath, args, shared);
getResourceDirPath(scratchPath, args, shared, SDKPath);
runtimeLibPaths.push_back(std::string(scratchPath.str()));

// If there's a secondary resource dir, add it too.
Expand Down
6 changes: 4 additions & 2 deletions lib/Driver/UnixToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,

SmallString<128> SharedResourceDirPath;
getResourceDirPath(SharedResourceDirPath, context.Args,
/*Shared=*/!(staticExecutable || staticStdlib));
/*Shared=*/!(staticExecutable || staticStdlib),
context.OI.SDKPath);

if (!context.Args.hasArg(options::OPT_nostartfiles)) {
SmallString<128> swiftrtPath = SharedResourceDirPath;
Expand Down Expand Up @@ -294,7 +295,8 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
// if we're going that route, we'll set `linkFilePath` to the path to that
// file.
SmallString<128> linkFilePath;
getResourceDirPath(linkFilePath, context.Args, /*Shared=*/false);
getResourceDirPath(linkFilePath, context.Args, /*Shared=*/false,
context.OI.SDKPath);

if (staticExecutable) {
llvm::sys::path::append(linkFilePath, "static-executable-args.lnk");
Expand Down
6 changes: 4 additions & 2 deletions lib/Driver/WebAssemblyToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ toolchains::WebAssembly::constructInvocation(const DynamicLinkJobAction &job,
/*Shared=*/false);

SmallString<128> SharedResourceDirPath;
getResourceDirPath(SharedResourceDirPath, context.Args, /*Shared=*/false);
getResourceDirPath(SharedResourceDirPath, context.Args, /*Shared=*/false,
context.OI.SDKPath);

if (!context.Args.hasArg(options::OPT_nostartfiles)) {
SmallString<128> swiftrtPath = SharedResourceDirPath;
Expand Down Expand Up @@ -152,7 +153,8 @@ toolchains::WebAssembly::constructInvocation(const DynamicLinkJobAction &job,
// if we're going that route, we'll set `linkFilePath` to the path to that
// file.
SmallString<128> linkFilePath;
getResourceDirPath(linkFilePath, context.Args, /*Shared=*/false);
getResourceDirPath(linkFilePath, context.Args, /*Shared=*/false,
context.OI.SDKPath);
llvm::sys::path::append(linkFilePath, "static-executable-args.lnk");

auto linkFile = linkFilePath.str();
Expand Down
3 changes: 2 additions & 1 deletion lib/Driver/WindowsToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ toolchains::Windows::constructInvocation(const DynamicLinkJobAction &job,

if (!context.Args.hasArg(options::OPT_nostartfiles)) {
SmallString<128> SharedResourceDirPath;
getResourceDirPath(SharedResourceDirPath, context.Args, /*Shared=*/true);
getResourceDirPath(SharedResourceDirPath, context.Args, /*Shared=*/true,
context.OI.SDKPath);

SmallString<128> swiftrtPath = SharedResourceDirPath;
llvm::sys::path::append(swiftrtPath,
Expand Down