Skip to content

Commit 659278d

Browse files
committed
Revert "[REPL] When using the default resource directory, prefer loading Swift dylibs from /usr/lib/swift."
This reverts commit 14c722b.
1 parent 66dc01b commit 659278d

File tree

6 files changed

+8
-37
lines changed

6 files changed

+8
-37
lines changed

include/swift/AST/SearchPathOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ class SearchPathOptions {
7272

7373
/// Don't look in for compiler-provided modules.
7474
bool SkipRuntimeLibraryImportPaths = false;
75-
76-
/// Whether the runtime library path is set to the compiler-relative default.
77-
bool RuntimeLibraryPathIsDefault = true;
7875

7976
/// Return a hash code of any components from these options that should
8077
/// contribute to a Swift Bridging PCH hash.

include/swift/Frontend/Frontend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class CompilerInvocation {
183183

184184
void setMainExecutablePath(StringRef Path);
185185

186-
void setRuntimeResourcePath(StringRef Path, bool IsDefault = false);
186+
void setRuntimeResourcePath(StringRef Path);
187187

188188
void setSDKPath(const std::string &Path);
189189

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void CompilerInvocation::setMainExecutablePath(StringRef Path) {
3939
llvm::sys::path::remove_filename(LibPath); // Remove /swift
4040
llvm::sys::path::remove_filename(LibPath); // Remove /bin
4141
llvm::sys::path::append(LibPath, "lib", "swift");
42-
setRuntimeResourcePath(LibPath.str(), /*IsDefault=*/true);
42+
setRuntimeResourcePath(LibPath.str());
4343
}
4444

4545
/// If we haven't explicitly passed -prebuilt-module-cache-path, set it to
@@ -87,11 +87,9 @@ static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,
8787
}
8888
}
8989

90-
void CompilerInvocation::setRuntimeResourcePath(StringRef Path,
91-
bool IsDefault) {
90+
void CompilerInvocation::setRuntimeResourcePath(StringRef Path) {
9291
SearchPathOpts.RuntimeResourcePath = Path;
9392
updateRuntimeLibraryPaths(SearchPathOpts, LangOpts.Target);
94-
SearchPathOpts.RuntimeLibraryPathIsDefault = IsDefault;
9593
}
9694

9795
void CompilerInvocation::setTargetTriple(StringRef Triple) {

lib/Immediate/Immediate.cpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,10 @@
5151
using namespace swift;
5252
using namespace swift::immediate;
5353

54-
/// The path for Swift libraries in the OS.
55-
#define OS_LIBRARY_PATH "/usr/lib/swift"
56-
5754
static void *loadRuntimeLib(StringRef runtimeLibPathWithName) {
5855
#if defined(_WIN32)
5956
return LoadLibraryA(runtimeLibPathWithName.str().c_str());
6057
#else
61-
#if defined(__APPLE__) && defined(__MACH__)
62-
if (!llvm::sys::path::is_absolute(runtimeLibPathWithName)) {
63-
// Try an absolute path search for Swift in the OS first.
64-
llvm::SmallString<128> absolutePath(OS_LIBRARY_PATH);
65-
llvm::sys::path::append(absolutePath, runtimeLibPathWithName);
66-
auto result = dlopen(absolutePath.c_str(), RTLD_LAZY | RTLD_GLOBAL);
67-
if (result) return result;
68-
}
69-
#endif
7058
return dlopen(runtimeLibPathWithName.str().c_str(), RTLD_LAZY | RTLD_GLOBAL);
7159
#endif
7260
}
@@ -78,16 +66,8 @@ static void *loadRuntimeLib(StringRef sharedLibName, StringRef runtimeLibPath) {
7866
return loadRuntimeLib(Path);
7967
}
8068

81-
void *swift::immediate::loadSwiftRuntime(StringRef runtimeLibPath,
82-
bool IsDefault) {
83-
StringRef LibName = "libswiftCore" LTDL_SHLIB_EXT;
84-
#if defined(__APPLE__) && defined(__MACH__)
85-
if (IsDefault) {
86-
auto result = loadRuntimeLib(LibName);
87-
if (result) return result;
88-
}
89-
#endif
90-
return loadRuntimeLib(LibName, runtimeLibPath);
69+
void *swift::immediate::loadSwiftRuntime(StringRef runtimeLibPath) {
70+
return loadRuntimeLib("libswiftCore" LTDL_SHLIB_EXT, runtimeLibPath);
9171
}
9272

9373
static bool tryLoadLibrary(LinkLibrary linkLib,
@@ -260,9 +240,7 @@ int swift::RunImmediately(CompilerInstance &CI, const ProcessCmdLine &CmdLine,
260240
//
261241
// This must be done here, before any library loading has been done, to avoid
262242
// racing with the static initializers in user code.
263-
auto stdlib = loadSwiftRuntime(
264-
Context.SearchPathOpts.RuntimeLibraryPath,
265-
Context.SearchPathOpts.RuntimeLibraryPathIsDefault);
243+
auto stdlib = loadSwiftRuntime(Context.SearchPathOpts.RuntimeLibraryPath);
266244
if (!stdlib) {
267245
CI.getDiags().diagnose(SourceLoc(),
268246
diag::error_immediate_mode_missing_stdlib);

lib/Immediate/ImmediateImpl.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ namespace immediate {
3838
/// calls or \c null if an error occurred.
3939
///
4040
/// \param runtimeLibPath Path to search for compiler-relative stdlib dylibs.
41-
/// \param IsDefault If true, the path is the default compiler-relative path.
42-
void *loadSwiftRuntime(StringRef runtimeLibPath, bool IsDefault);
41+
void *loadSwiftRuntime(StringRef runtimeLibPath);
4342
bool tryLoadLibraries(ArrayRef<LinkLibrary> LinkLibraries,
4443
SearchPathOptions SearchPathOpts,
4544
DiagnosticEngine &Diags);

lib/Immediate/REPL.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -969,8 +969,7 @@ class REPLEnvironment {
969969
ASTContext &Ctx = CI.getASTContext();
970970
Ctx.LangOpts.EnableAccessControl = false;
971971
if (!ParseStdlib) {
972-
if (!loadSwiftRuntime(Ctx.SearchPathOpts.RuntimeLibraryPath,
973-
Ctx.SearchPathOpts.RuntimeLibraryPathIsDefault)) {
972+
if (!loadSwiftRuntime(Ctx.SearchPathOpts.RuntimeLibraryPath)) {
974973
CI.getDiags().diagnose(SourceLoc(),
975974
diag::error_immediate_mode_missing_stdlib);
976975
return;

0 commit comments

Comments
 (0)