@@ -1061,7 +1061,8 @@ static void addPathEnvironmentVariableIfNeeded(Job::EnvironmentVector &env,
1061
1061
// / relative to the compiler.
1062
1062
static void getRuntimeLibraryPath (SmallVectorImpl<char > &runtimeLibPath,
1063
1063
const llvm::opt::ArgList &args,
1064
- const ToolChain &TC) {
1064
+ const ToolChain &TC,
1065
+ bool shared) {
1065
1066
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime
1066
1067
// library link path and the standard library module import path don't
1067
1068
// need to be the same.
@@ -1073,7 +1074,7 @@ static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
1073
1074
runtimeLibPath.append (programPath.begin (), programPath.end ());
1074
1075
llvm::sys::path::remove_filename (runtimeLibPath); // remove /swift
1075
1076
llvm::sys::path::remove_filename (runtimeLibPath); // remove /bin
1076
- llvm::sys::path::append (runtimeLibPath, " lib" , " swift" );
1077
+ llvm::sys::path::append (runtimeLibPath, " lib" , shared ? " swift" : " swift_static " );
1077
1078
}
1078
1079
llvm::sys::path::append (runtimeLibPath,
1079
1080
getPlatformNameForTriple (TC.getTriple ()));
@@ -1083,43 +1084,21 @@ static void getClangLibraryPath(const ToolChain &TC, const ArgList &Args,
1083
1084
SmallString<128 > &LibPath) {
1084
1085
const llvm::Triple &T = TC.getTriple ();
1085
1086
1086
- getRuntimeLibraryPath (LibPath, Args, TC);
1087
+ getRuntimeLibraryPath (LibPath, Args, TC, /* Shared= */ true );
1087
1088
// Remove platform name.
1088
1089
llvm::sys::path::remove_filename (LibPath);
1089
1090
llvm::sys::path::append (LibPath, " clang" , " lib" ,
1090
1091
T.isOSDarwin () ? " darwin"
1091
1092
: getPlatformNameForTriple (T));
1092
1093
}
1093
1094
1094
- // / Get the runtime library link path for static linking,
1095
- // / which is platform-specific and found relative to the compiler.
1096
- static void getRuntimeStaticLibraryPath (SmallVectorImpl<char > &runtimeLibPath,
1097
- const llvm::opt::ArgList &args,
1098
- const ToolChain &TC) {
1099
- // FIXME: Duplicated from CompilerInvocation, but in theory the runtime
1100
- // library link path and the standard library module import path don't
1101
- // need to be the same.
1102
- if (const Arg *A = args.getLastArg (options::OPT_resource_dir)) {
1103
- StringRef value = A->getValue ();
1104
- runtimeLibPath.append (value.begin (), value.end ());
1105
- } else {
1106
- auto programPath = TC.getDriver ().getSwiftProgramPath ();
1107
- runtimeLibPath.append (programPath.begin (), programPath.end ());
1108
- llvm::sys::path::remove_filename (runtimeLibPath); // remove /swift
1109
- llvm::sys::path::remove_filename (runtimeLibPath); // remove /bin
1110
- llvm::sys::path::append (runtimeLibPath, " lib" , " swift_static" );
1111
- }
1112
- llvm::sys::path::append (runtimeLibPath,
1113
- getPlatformNameForTriple (TC.getTriple ()));
1114
- }
1115
-
1116
1095
ToolChain::InvocationInfo
1117
1096
toolchains::Darwin::constructInvocation (const InterpretJobAction &job,
1118
1097
const JobContext &context) const {
1119
1098
InvocationInfo II = ToolChain::constructInvocation (job, context);
1120
1099
1121
1100
SmallString<128 > runtimeLibraryPath;
1122
- getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this );
1101
+ getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this , /* Shared= */ true );
1123
1102
1124
1103
addPathEnvironmentVariableIfNeeded (II.ExtraEnvironment , " DYLD_LIBRARY_PATH" ,
1125
1104
" :" , options::OPT_L, context.Args ,
@@ -1224,7 +1203,7 @@ addLinkRuntimeLibForLinux(const ArgList &Args, ArgStringList &Arguments,
1224
1203
StringRef LinuxLibName,
1225
1204
const ToolChain &TC) {
1226
1205
SmallString<128 > Dir;
1227
- getRuntimeLibraryPath (Dir, Args, TC);
1206
+ getRuntimeLibraryPath (Dir, Args, TC, /* Shared= */ true );
1228
1207
// Remove platform name.
1229
1208
llvm::sys::path::remove_filename (Dir);
1230
1209
llvm::sys::path::append (Dir, " clang" , " lib" , " linux" );
@@ -1432,15 +1411,15 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
1432
1411
// Add the runtime library link path, which is platform-specific and found
1433
1412
// relative to the compiler.
1434
1413
SmallString<128 > RuntimeLibPath;
1435
- getRuntimeLibraryPath (RuntimeLibPath, context.Args , *this );
1414
+ getRuntimeLibraryPath (RuntimeLibPath, context.Args , *this , /* Shared= */ true );
1436
1415
1437
1416
// Link the standard library.
1438
1417
Arguments.push_back (" -L" );
1439
1418
if (context.Args .hasFlag (options::OPT_static_stdlib,
1440
1419
options::OPT_no_static_stdlib,
1441
1420
false )) {
1442
1421
SmallString<128 > StaticRuntimeLibPath;
1443
- getRuntimeStaticLibraryPath (StaticRuntimeLibPath, context.Args , *this );
1422
+ getRuntimeLibraryPath (StaticRuntimeLibPath, context.Args , *this , /* Shared= */ false );
1444
1423
Arguments.push_back (context.Args .MakeArgString (StaticRuntimeLibPath));
1445
1424
Arguments.push_back (" -lc++" );
1446
1425
Arguments.push_back (" -framework" );
@@ -1539,7 +1518,7 @@ toolchains::GenericUnix::constructInvocation(const InterpretJobAction &job,
1539
1518
InvocationInfo II = ToolChain::constructInvocation (job, context);
1540
1519
1541
1520
SmallString<128 > runtimeLibraryPath;
1542
- getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this );
1521
+ getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this , /* Shared= */ true );
1543
1522
1544
1523
addPathEnvironmentVariableIfNeeded (II.ExtraEnvironment , " LD_LIBRARY_PATH" ,
1545
1524
" :" , options::OPT_L, context.Args ,
@@ -1673,10 +1652,10 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
1673
1652
}
1674
1653
1675
1654
SmallString<128 > SharedRuntimeLibPath;
1676
- getRuntimeLibraryPath (SharedRuntimeLibPath, context.Args , *this );
1655
+ getRuntimeLibraryPath (SharedRuntimeLibPath, context.Args , *this , /* Shared= */ true );
1677
1656
1678
1657
SmallString<128 > StaticRuntimeLibPath;
1679
- getRuntimeStaticLibraryPath (StaticRuntimeLibPath, context.Args , *this );
1658
+ getRuntimeLibraryPath (StaticRuntimeLibPath, context.Args , *this , /* Shared= */ false );
1680
1659
1681
1660
// Add the runtime library link path, which is platform-specific and found
1682
1661
// relative to the compiler.
0 commit comments