Skip to content

Commit 5892c04

Browse files
authored
Merge pull request swiftlang#269 from benlangmuir/parallelize-but-not-destructorize
[linux] Re-enable parallel testing after avoiding static destructors
2 parents 7922ef4 + 4c925df commit 5892c04

File tree

7 files changed

+39
-9
lines changed

7 files changed

+39
-9
lines changed

Package.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ let package = Package(
4545
]
4646
),
4747

48+
.target(
49+
name: "CSKTestSupport",
50+
dependencies: []),
4851
.target(
4952
name: "SKTestSupport",
5053
dependencies: [
54+
"CSKTestSupport",
5155
"ISDBTestSupport",
5256
"LSPTestSupport",
5357
"SourceKit",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifdef __linux__
14+
// For testing, override __cxa_atexit to prevent registration of static
15+
// destructors due to SR-12668.
16+
int __cxa_atexit(void (*f) (void *), void *arg, void *dso_handle) {
17+
return 0;
18+
}
19+
#endif

Sources/CSKTestSupport/include/module.modulemap

Whitespace-only changes.

Sources/SKSupport/dlopen.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,8 @@ public struct DLOpenFlags: RawRepresentable, OptionSet {
5959
// Platform-specific flags.
6060
#if os(macOS)
6161
public static let first: DLOpenFlags = DLOpenFlags(rawValue: RTLD_FIRST)
62-
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: 0)
6362
#else
6463
public static let first: DLOpenFlags = DLOpenFlags(rawValue: 0)
65-
#if !os(Android)
66-
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: RTLD_DEEPBIND)
67-
#endif
6864
#endif
6965
#endif
7066

Sources/SourceKit/sourcekitd/SwiftSourceKitFramework.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ final class SwiftSourceKitFramework {
4646
self.path = path
4747
#if os(Windows)
4848
self.dylib = try dlopen(path.pathString, mode: [])
49-
#elseif os(Android)
50-
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first])
5149
#else
52-
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first, .deepBind])
50+
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first])
5351
#endif
5452

5553
func dlsym_required<T>(_ handle: DLHandle, symbol: String) throws -> T {

Sources/sourcekit-lsp/main.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ let server = SourceKitServer(client: clientConnection, options: options.serverOp
121121
})
122122
clientConnection.start(receiveHandler: server, closeHandler: {
123123
server.prepareForExit()
124-
exit(0)
124+
// Use _Exit to avoid running static destructors due to SR-12668.
125+
_Exit(0)
125126
})
126127

127128
Logger.shared.addLogHandler { message, _ in

Utilities/build-script-helper.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ def delete_rpath(rpath, binary):
8686
subprocess.check_call(cmd)
8787

8888

89+
def should_test_parallel():
90+
if platform.system() == 'Linux':
91+
distro = platform.linux_distribution()
92+
if distro[0] != 'Ubuntu':
93+
# Workaround hang in Process.run() that hasn't been tracked down yet.
94+
return False
95+
return True
96+
97+
8998
def handle_invocation(swift_exec, args):
9099
swiftpm_args = get_swiftpm_options(args)
91100

@@ -114,7 +123,10 @@ def handle_invocation(swift_exec, args):
114123
tests = os.path.join(bin_path, 'sk-tests')
115124
print('Cleaning ' + tests)
116125
shutil.rmtree(tests, ignore_errors=True)
117-
swiftpm('test', swift_exec, swiftpm_args, env)
126+
test_args = swiftpm_args
127+
if should_test_parallel():
128+
test_args += ['--parallel']
129+
swiftpm('test', swift_exec, test_args, env)
118130
elif args.action == 'install':
119131
bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
120132
swiftpm('build', swift_exec, swiftpm_args, env)

0 commit comments

Comments
 (0)