|
22 | 22 | #include "swift/Driver/Compilation.h"
|
23 | 23 | #include "swift/Driver/Driver.h"
|
24 | 24 | #include "swift/Driver/Job.h"
|
| 25 | +#include "swift/Frontend/Frontend.h" |
25 | 26 | #include "swift/Option/Options.h"
|
26 | 27 | #include "clang/Basic/Version.h"
|
27 | 28 | #include "clang/Driver/Util.h"
|
@@ -264,6 +265,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
|
264 | 265 |
|
265 | 266 | // Pass on file paths that should be remapped in debug info.
|
266 | 267 | inputArgs.AddAllArgs(arguments, options::OPT_debug_prefix_map);
|
| 268 | + inputArgs.AddAllArgs(arguments, options::OPT_coverage_prefix_map); |
267 | 269 |
|
268 | 270 | // Pass through the values passed to -Xfrontend.
|
269 | 271 | inputArgs.AddAllArgValues(arguments, options::OPT_Xfrontend);
|
@@ -523,6 +525,13 @@ ToolChain::constructInvocation(const CompileJobAction &job,
|
523 | 525 | Arguments.push_back("-track-system-dependencies");
|
524 | 526 | }
|
525 | 527 |
|
| 528 | + if (context.Args.hasFlag(options::OPT_static_executable, |
| 529 | + options::OPT_no_static_executable, false) || |
| 530 | + context.Args.hasFlag(options::OPT_static_stdlib, |
| 531 | + options::OPT_no_static_stdlib, false)) { |
| 532 | + Arguments.push_back("-use-static-resource-dir"); |
| 533 | + } |
| 534 | + |
526 | 535 | context.Args.AddLastArg(
|
527 | 536 | Arguments,
|
528 | 537 | options::
|
@@ -1256,25 +1265,19 @@ void ToolChain::getClangLibraryPath(const ArgList &Args,
|
1256 | 1265 | void ToolChain::getResourceDirPath(SmallVectorImpl<char> &resourceDirPath,
|
1257 | 1266 | const llvm::opt::ArgList &args,
|
1258 | 1267 | bool shared) const {
|
1259 |
| - // FIXME: Duplicated from CompilerInvocation, but in theory the runtime |
1260 |
| - // library link path and the standard library module import path don't |
1261 |
| - // need to be the same. |
1262 | 1268 | if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) {
|
1263 | 1269 | StringRef value = A->getValue();
|
1264 | 1270 | resourceDirPath.append(value.begin(), value.end());
|
1265 | 1271 | } else if (!getTriple().isOSDarwin() && !getTriple().isOSWASI() && args.hasArg(options::OPT_sdk)) {
|
1266 | 1272 | // for WASI, sdk option points to wasi-sysroot which doesn't have Swift toolchain
|
1267 | 1273 | StringRef value = args.getLastArg(options::OPT_sdk)->getValue();
|
1268 | 1274 | resourceDirPath.append(value.begin(), value.end());
|
1269 |
| - llvm::sys::path::append(resourceDirPath, "usr", "lib", |
1270 |
| - shared ? "swift" : "swift_static"); |
| 1275 | + llvm::sys::path::append(resourceDirPath, "usr"); |
| 1276 | + CompilerInvocation::appendSwiftLibDir(resourceDirPath, shared); |
1271 | 1277 | } else {
|
1272 | 1278 | auto programPath = getDriver().getSwiftProgramPath();
|
1273 |
| - resourceDirPath.append(programPath.begin(), programPath.end()); |
1274 |
| - llvm::sys::path::remove_filename(resourceDirPath); // remove /swift |
1275 |
| - llvm::sys::path::remove_filename(resourceDirPath); // remove /bin |
1276 |
| - llvm::sys::path::append(resourceDirPath, "lib", |
1277 |
| - shared ? "swift" : "swift_static"); |
| 1279 | + CompilerInvocation::computeRuntimeResourcePathFromExecutablePath( |
| 1280 | + programPath, shared, resourceDirPath); |
1278 | 1281 | }
|
1279 | 1282 |
|
1280 | 1283 | StringRef libSubDir = getPlatformNameForTriple(getTriple());
|
|
0 commit comments