Skip to content

Commit 1def01e

Browse files
committed
Use RTLD_DEEP_BIND on Linux when opening libsourcekitdInProc
We have multiple copies of llvm symbols (indexstoredb, indexstore, llbuild via swiftpm, and sourcekitd), so it's important to keep them isolated. In practice this seems to have started breaking after we updated swiftpm and llbuild was added, but it was already a potential issue before that. The most egregious issue is if you build sourcekit with assertions, it enables ABI-breaking checks in llvm. On macOS this dlopen behaviour is already the default.
1 parent 048d72b commit 1def01e

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Sources/SKSupport/dlopen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public struct DLOpenFlags: RawRepresentable, OptionSet {
4747
// Platform-specific flags.
4848
#if os(macOS)
4949
public static let first: DLOpenFlags = DLOpenFlags(rawValue: RTLD_FIRST)
50+
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: 0)
5051
#else
5152
public static let first: DLOpenFlags = DLOpenFlags(rawValue: 0)
53+
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: RTLD_DEEPBIND)
5254
#endif
5355

5456
public var rawValue: Int32

Sources/SourceKit/sourcekitd/SwiftSourceKitFramework.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ final class SwiftSourceKitFramework {
4242

4343
init(dylib path: AbsolutePath) throws {
4444
self.path = path
45-
self.dylib = try dlopen(path.asString, mode: [.lazy, .local, .first])
45+
self.dylib = try dlopen(path.asString, mode: [.lazy, .local, .first, .deepBind])
4646

4747
func dlsym_required<T>(_ handle: DLHandle, symbol: String) throws -> T {
4848
guard let sym: T = dlsym(handle, symbol: symbol) else {

0 commit comments

Comments
 (0)