Skip to content

Commit 6128a51

Browse files
committed
Fix search paths for runtime libs on non-Darwin
Fixes swift-intermediate ability to open libswiftCore and some broken tests.
1 parent c3d8063 commit 6128a51

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,19 @@ static void updateRuntimeLibraryPath(SearchPathOptions &SearchPathOpts,
4949
llvm::SmallString<128> LibPath(SearchPathOpts.RuntimeResourcePath);
5050

5151
llvm::sys::path::append(LibPath, getPlatformNameForTriple(Triple));
52-
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
52+
if (Triple.isOSDarwin()) {
53+
// On Darwin the library search path is where we store fat binaries.
54+
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
55+
}
5356

5457
llvm::sys::path::append(LibPath, swift::getMajorArchitectureName(Triple));
5558
SearchPathOpts.RuntimeLibraryImportPath = LibPath.str();
59+
if (!Triple.isOSDarwin()) {
60+
// On platforms without fat binaries, we use the arch specific
61+
// directory for searching for binaries. This is the same as the import
62+
// path for modules.
63+
SearchPathOpts.RuntimeLibraryPath = LibPath.str();
64+
}
5665
}
5766

5867
void CompilerInvocation::setRuntimeResourcePath(StringRef Path) {

test/Driver/environment.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
// RUN: %swift_driver -target x86_64-unknown-gnu-linux -L/foo/ -driver-use-frontend-path %S/Inputs/print-var.sh %s LD_LIBRARY_PATH | %FileCheck -check-prefix=CHECK${LD_LIBRARY_PATH+_LAX} %s
55

6-
// CHECK: {{^/foo/:[^:]+/lib/swift/linux$}}
7-
// CHECK_LAX: {{^/foo/:[^:]+/lib/swift/linux}}
6+
// CHECK: {{^/foo/:[^:]+/lib/swift/linux/x86_64$}}
7+
// CHECK_LAX: {{^/foo/:[^:]+/lib/swift/linux/x86_64}}

test/Driver/options-interpreter.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
// CHECK-RESOURCE-DIR-ONLY: # DYLD_LIBRARY_PATH=/RSRC/macosx{{$}}
1919

2020
// RUN: %swift_driver -### -target x86_64-unknown-linux-gnu -resource-dir /RSRC/ %s | %FileCheck -check-prefix=CHECK-RESOURCE-DIR-ONLY-LINUX${LD_LIBRARY_PATH+_LAX} %s
21-
// CHECK-RESOURCE-DIR-ONLY-LINUX: # LD_LIBRARY_PATH=/RSRC/linux{{$}}
22-
// CHECK-RESOURCE-DIR-ONLY-LINUX_LAX: # LD_LIBRARY_PATH=/RSRC/linux{{$|:}}
21+
// CHECK-RESOURCE-DIR-ONLY-LINUX: # LD_LIBRARY_PATH=/RSRC/linux/x86_64{{$}}
22+
// CHECK-RESOURCE-DIR-ONLY-LINUX_LAX: # LD_LIBRARY_PATH=/RSRC/linux/x86_64{{$|:}}
2323

2424
// RUN: %swift_driver -### -target x86_64-apple-macosx10.9 -L/foo/ %s | %FileCheck -check-prefix=CHECK-L %s
2525
// CHECK-L: # DYLD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/macosx$}}
@@ -59,9 +59,9 @@
5959
// CHECK-COMPLEX-DAG: DYLD_LIBRARY_PATH={{/foo2/:/bar2/:[^:]+/lib/swift/macosx($| )}}
6060

6161
// RUN: %swift_driver -### -target x86_64-unknown-linux-gnu -L/foo/ %s | %FileCheck -check-prefix=CHECK-L-LINUX${LD_LIBRARY_PATH+_LAX} %s
62-
// CHECK-L-LINUX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux$}}
63-
// CHECK-L-LINUX_LAX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux($|:)}}
62+
// CHECK-L-LINUX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux/x86_64$}}
63+
// CHECK-L-LINUX_LAX: # LD_LIBRARY_PATH={{/foo/:[^:]+/lib/swift/linux/x86_64($|:)}}
6464

6565
// RUN: env LD_LIBRARY_PATH=/abc/ %swift_driver_plain -### -target x86_64-unknown-linux-gnu -L/foo/ -L/bar/ %s | %FileCheck -check-prefix=CHECK-LINUX-COMPLEX${LD_LIBRARY_PATH+_LAX} %s
66-
// CHECK-LINUX-COMPLEX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux:/abc/$}}
67-
// CHECK-LINUX-COMPLEX_LAX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux:/abc/($|:)}}
66+
// CHECK-LINUX-COMPLEX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux/x86_64:/abc/$}}
67+
// CHECK-LINUX-COMPLEX_LAX: # LD_LIBRARY_PATH={{/foo/:/bar/:[^:]+/lib/swift/linux/x86_64:/abc/($|:)}}

0 commit comments

Comments
 (0)