@@ -1025,7 +1025,8 @@ static void addPathEnvironmentVariableIfNeeded(Job::EnvironmentVector &env,
1025
1025
// / relative to the compiler.
1026
1026
static void getRuntimeLibraryPath (SmallVectorImpl<char > &runtimeLibPath,
1027
1027
const llvm::opt::ArgList &args,
1028
- const ToolChain &TC) {
1028
+ const ToolChain &TC,
1029
+ bool shared) {
1029
1030
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime
1030
1031
// library link path and the standard library module import path don't
1031
1032
// need to be the same.
@@ -1037,7 +1038,7 @@ static void getRuntimeLibraryPath(SmallVectorImpl<char> &runtimeLibPath,
1037
1038
runtimeLibPath.append (programPath.begin (), programPath.end ());
1038
1039
llvm::sys::path::remove_filename (runtimeLibPath); // remove /swift
1039
1040
llvm::sys::path::remove_filename (runtimeLibPath); // remove /bin
1040
- llvm::sys::path::append (runtimeLibPath, " lib" , " swift" );
1041
+ llvm::sys::path::append (runtimeLibPath, " lib" , shared ? " swift" : " swift_static " );
1041
1042
}
1042
1043
llvm::sys::path::append (runtimeLibPath,
1043
1044
getPlatformNameForTriple (TC.getTriple ()));
@@ -1047,43 +1048,21 @@ static void getClangLibraryPath(const ToolChain &TC, const ArgList &Args,
1047
1048
SmallString<128 > &LibPath) {
1048
1049
const llvm::Triple &T = TC.getTriple ();
1049
1050
1050
- getRuntimeLibraryPath (LibPath, Args, TC);
1051
+ getRuntimeLibraryPath (LibPath, Args, TC, /* Shared= */ true );
1051
1052
// Remove platform name.
1052
1053
llvm::sys::path::remove_filename (LibPath);
1053
1054
llvm::sys::path::append (LibPath, " clang" , " lib" ,
1054
1055
T.isOSDarwin () ? " darwin"
1055
1056
: getPlatformNameForTriple (T));
1056
1057
}
1057
1058
1058
- // / Get the runtime library link path for static linking,
1059
- // / which is platform-specific and found relative to the compiler.
1060
- static void getRuntimeStaticLibraryPath (SmallVectorImpl<char > &runtimeLibPath,
1061
- const llvm::opt::ArgList &args,
1062
- const ToolChain &TC) {
1063
- // FIXME: Duplicated from CompilerInvocation, but in theory the runtime
1064
- // library link path and the standard library module import path don't
1065
- // need to be the same.
1066
- if (const Arg *A = args.getLastArg (options::OPT_resource_dir)) {
1067
- StringRef value = A->getValue ();
1068
- runtimeLibPath.append (value.begin (), value.end ());
1069
- } else {
1070
- auto programPath = TC.getDriver ().getSwiftProgramPath ();
1071
- runtimeLibPath.append (programPath.begin (), programPath.end ());
1072
- llvm::sys::path::remove_filename (runtimeLibPath); // remove /swift
1073
- llvm::sys::path::remove_filename (runtimeLibPath); // remove /bin
1074
- llvm::sys::path::append (runtimeLibPath, " lib" , " swift_static" );
1075
- }
1076
- llvm::sys::path::append (runtimeLibPath,
1077
- getPlatformNameForTriple (TC.getTriple ()));
1078
- }
1079
-
1080
1059
ToolChain::InvocationInfo
1081
1060
toolchains::Darwin::constructInvocation (const InterpretJobAction &job,
1082
1061
const JobContext &context) const {
1083
1062
InvocationInfo II = ToolChain::constructInvocation (job, context);
1084
1063
1085
1064
SmallString<128 > runtimeLibraryPath;
1086
- getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this );
1065
+ getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this , /* Shared= */ true );
1087
1066
1088
1067
addPathEnvironmentVariableIfNeeded (II.ExtraEnvironment , " DYLD_LIBRARY_PATH" ,
1089
1068
" :" , options::OPT_L, context.Args ,
@@ -1188,7 +1167,7 @@ addLinkRuntimeLibForLinux(const ArgList &Args, ArgStringList &Arguments,
1188
1167
StringRef LinuxLibName,
1189
1168
const ToolChain &TC) {
1190
1169
SmallString<128 > Dir;
1191
- getRuntimeLibraryPath (Dir, Args, TC);
1170
+ getRuntimeLibraryPath (Dir, Args, TC, /* Shared= */ true );
1192
1171
// Remove platform name.
1193
1172
llvm::sys::path::remove_filename (Dir);
1194
1173
llvm::sys::path::append (Dir, " clang" , " lib" , " linux" );
@@ -1397,15 +1376,15 @@ toolchains::Darwin::constructInvocation(const LinkJobAction &job,
1397
1376
// Add the runtime library link path, which is platform-specific and found
1398
1377
// relative to the compiler.
1399
1378
SmallString<128 > RuntimeLibPath;
1400
- getRuntimeLibraryPath (RuntimeLibPath, context.Args , *this );
1379
+ getRuntimeLibraryPath (RuntimeLibPath, context.Args , *this , /* Shared= */ true );
1401
1380
1402
1381
// Link the standard library.
1403
1382
Arguments.push_back (" -L" );
1404
1383
if (context.Args .hasFlag (options::OPT_static_stdlib,
1405
1384
options::OPT_no_static_stdlib,
1406
1385
false )) {
1407
1386
SmallString<128 > StaticRuntimeLibPath;
1408
- getRuntimeStaticLibraryPath (StaticRuntimeLibPath, context.Args , *this );
1387
+ getRuntimeLibraryPath (StaticRuntimeLibPath, context.Args , *this , /* Shared= */ false );
1409
1388
Arguments.push_back (context.Args .MakeArgString (StaticRuntimeLibPath));
1410
1389
Arguments.push_back (" -lc++" );
1411
1390
Arguments.push_back (" -framework" );
@@ -1504,7 +1483,7 @@ toolchains::GenericUnix::constructInvocation(const InterpretJobAction &job,
1504
1483
InvocationInfo II = ToolChain::constructInvocation (job, context);
1505
1484
1506
1485
SmallString<128 > runtimeLibraryPath;
1507
- getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this );
1486
+ getRuntimeLibraryPath (runtimeLibraryPath, context.Args , *this , /* Shared= */ true );
1508
1487
1509
1488
addPathEnvironmentVariableIfNeeded (II.ExtraEnvironment , " LD_LIBRARY_PATH" ,
1510
1489
" :" , options::OPT_L, context.Args ,
@@ -1638,10 +1617,10 @@ toolchains::GenericUnix::constructInvocation(const LinkJobAction &job,
1638
1617
}
1639
1618
1640
1619
SmallString<128 > SharedRuntimeLibPath;
1641
- getRuntimeLibraryPath (SharedRuntimeLibPath, context.Args , *this );
1620
+ getRuntimeLibraryPath (SharedRuntimeLibPath, context.Args , *this , /* Shared= */ true );
1642
1621
1643
1622
SmallString<128 > StaticRuntimeLibPath;
1644
- getRuntimeStaticLibraryPath (StaticRuntimeLibPath, context.Args , *this );
1623
+ getRuntimeLibraryPath (StaticRuntimeLibPath, context.Args , *this , /* Shared= */ false );
1645
1624
1646
1625
// Add the runtime library link path, which is platform-specific and found
1647
1626
// relative to the compiler.
0 commit comments