Skip to content

Commit acf2c9f

Browse files
committed
[Driver] On Apple platforms, add /usr/lib/swift to the beginning of the DYLD_LIBRARY_PATH value in constructInvocation.
rdar://problem/47819780
1 parent 14c722b commit acf2c9f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/Driver/DarwinToolChains.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ using namespace swift;
3838
using namespace swift::driver;
3939
using namespace llvm::opt;
4040

41+
/// The path for Swift libraries in the OS. (Duplicated from Immediate.cpp.
42+
/// Eventually we should consolidate this.)
43+
#define OS_LIBRARY_PATH "/usr/lib/swift"
44+
4145
std::string
4246
toolchains::Darwin::findProgramRelativeToSwiftImpl(StringRef name) const {
4347
StringRef swiftPath = getDriver().getSwiftProgramPath();
@@ -71,12 +75,15 @@ toolchains::Darwin::constructInvocation(const InterpretJobAction &job,
7175
const JobContext &context) const {
7276
InvocationInfo II = ToolChain::constructInvocation(job, context);
7377

78+
SmallString<128> envValue(OS_LIBRARY_PATH ":");
79+
7480
SmallString<128> runtimeLibraryPath;
7581
getRuntimeLibraryPath(runtimeLibraryPath, context.Args, /*Shared=*/true);
82+
envValue.append(runtimeLibraryPath);
7683

7784
addPathEnvironmentVariableIfNeeded(II.ExtraEnvironment, "DYLD_LIBRARY_PATH",
7885
":", options::OPT_L, context.Args,
79-
runtimeLibraryPath);
86+
envValue);
8087
addPathEnvironmentVariableIfNeeded(II.ExtraEnvironment, "DYLD_FRAMEWORK_PATH",
8188
":", options::OPT_F, context.Args);
8289
// FIXME: Add options::OPT_Fsystem paths to DYLD_FRAMEWORK_PATH as well.

test/Driver/environment-mac.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// REQUIRES: OS=macosx
2+
3+
// RUN: %swift_driver -driver-use-frontend-path %S/Inputs/print-var.sh %s DYLD_LIBRARY_PATH | %FileCheck %s
4+
5+
// CHECK: {{^/usr/lib/swift:}}

0 commit comments

Comments
 (0)