Skip to content

[linux] Re-enable parallel testing after avoiding static destructors #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ let package = Package(
]
),

.target(
name: "CSKTestSupport",
dependencies: []),
.target(
name: "SKTestSupport",
dependencies: [
"CSKTestSupport",
"ISDBTestSupport",
"LSPTestSupport",
"SourceKit",
Expand Down
19 changes: 19 additions & 0 deletions Sources/CSKTestSupport/CSKTestSupport.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//

#ifdef __linux__
// For testing, override __cxa_atexit to prevent registration of static
// destructors due to SR-12668.
int __cxa_atexit(void (*f) (void *), void *arg, void *dso_handle) {
return 0;
}
#endif
Empty file.
4 changes: 0 additions & 4 deletions Sources/SKSupport/dlopen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,8 @@ public struct DLOpenFlags: RawRepresentable, OptionSet {
// Platform-specific flags.
#if os(macOS)
public static let first: DLOpenFlags = DLOpenFlags(rawValue: RTLD_FIRST)
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: 0)
#else
public static let first: DLOpenFlags = DLOpenFlags(rawValue: 0)
#if !os(Android)
public static let deepBind: DLOpenFlags = DLOpenFlags(rawValue: RTLD_DEEPBIND)
#endif
#endif
#endif

Expand Down
4 changes: 1 addition & 3 deletions Sources/SourceKit/sourcekitd/SwiftSourceKitFramework.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ final class SwiftSourceKitFramework {
self.path = path
#if os(Windows)
self.dylib = try dlopen(path.pathString, mode: [])
#elseif os(Android)
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first])
#else
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first, .deepBind])
self.dylib = try dlopen(path.pathString, mode: [.lazy, .local, .first])
#endif

func dlsym_required<T>(_ handle: DLHandle, symbol: String) throws -> T {
Expand Down
3 changes: 2 additions & 1 deletion Sources/sourcekit-lsp/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ let server = SourceKitServer(client: clientConnection, options: options.serverOp
})
clientConnection.start(receiveHandler: server, closeHandler: {
server.prepareForExit()
exit(0)
// Use _Exit to avoid running static destructors due to SR-12668.
_Exit(0)
})

Logger.shared.addLogHandler { message, _ in
Expand Down
14 changes: 13 additions & 1 deletion Utilities/build-script-helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ def delete_rpath(rpath, binary):
subprocess.check_call(cmd)


def should_test_parallel():
if platform.system() == 'Linux':
distro = platform.linux_distribution()
if distro[0] != 'Ubuntu':
# Workaround hang in Process.run() that hasn't been tracked down yet.
return False
return True


def handle_invocation(swift_exec, args):
swiftpm_args = get_swiftpm_options(args)

Expand Down Expand Up @@ -114,7 +123,10 @@ def handle_invocation(swift_exec, args):
tests = os.path.join(bin_path, 'sk-tests')
print('Cleaning ' + tests)
shutil.rmtree(tests, ignore_errors=True)
swiftpm('test', swift_exec, swiftpm_args, env)
test_args = swiftpm_args
if should_test_parallel():
test_args += ['--parallel']
swiftpm('test', swift_exec, test_args, env)
elif args.action == 'install':
bin_path = swiftpm_bin_path(swift_exec, swiftpm_args, env)
swiftpm('build', swift_exec, swiftpm_args, env)
Expand Down