Skip to content

Commit 863d4c4

Browse files
Merge pull request #5490 from swiftwasm/release/5.8
[pull] swiftwasm-release/5.8 from release/5.8
2 parents da5911d + 3f5029f commit 863d4c4

File tree

7 files changed

+74
-34
lines changed

7 files changed

+74
-34
lines changed

CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,6 @@ if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}")
624624
message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE")
625625
endif()
626626

627-
# Use dispatch as the system scheduler by default.
628-
# For convenience, we set this to false when concurrency is disabled.
629-
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
630-
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
631-
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
632-
endif()
633-
634627
set(SWIFT_BUILD_HOST_DISPATCH FALSE)
635628
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
636629
# Only build libdispatch for the host if the host tools are being built and
@@ -639,9 +632,9 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
639632
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
640633
endif()
641634

642-
if(SWIFT_BUILD_HOST_DISPATCH OR SWIFT_CONCURRENCY_USES_DISPATCH)
635+
if(SWIFT_BUILD_HOST_DISPATCH)
643636
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
644-
message(SEND_ERROR "SourceKit and concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
637+
message(SEND_ERROR "SourceKit requires libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
645638
endif()
646639
endif()
647640
endif()

lib/DriverTool/autolink_extract_main.cpp

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,50 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
213213
std::vector<std::string> LinkerFlags;
214214

215215
// Keep track of whether we've already added the common
216-
// Swift libraries that ususally have autolink directives
217-
// in most object fiels
218-
std::unordered_map<std::string, bool> SwiftRuntimeLibraries = {
219-
{"-lswiftSwiftOnoneSupport", false},
220-
{"-lswiftCore", false},
221-
{"-lswift_Concurrency", false},
222-
{"-lswift_StringProcessing", false},
223-
{"-lswift_RegexParser", false}
216+
// Swift libraries that usually have autolink directives
217+
// in most object files
218+
219+
std::vector<std::string> SwiftRuntimeLibsOrdered = {
220+
// Common Swift runtime libs
221+
"-lswiftSwiftOnoneSupport",
222+
"-lswiftCore",
223+
"-lswift_Concurrency",
224+
"-lswift_StringProcessing",
225+
"-lswift_RegexBuilder",
226+
"-lswift_RegexParser",
227+
"-lswift_Backtracing",
228+
"-lswiftGlibc",
229+
"-lBlocksRuntime",
230+
// Dispatch-specific Swift runtime libs
231+
"-ldispatch",
232+
"-lDispatchStubs",
233+
"-lswiftDispatch",
234+
// CoreFoundation and Foundation Swift runtime libs
235+
"-lCoreFoundation",
236+
"-lFoundation",
237+
"-lFoundationNetworking",
238+
"-lFoundationXML",
239+
// Foundation support libs
240+
"-lcurl",
241+
"-lxml2",
242+
"-luuid",
243+
// XCTest runtime libs (must be first due to http://github.com/apple/swift-corelibs-xctest/issues/432)
244+
"-lXCTest",
245+
// ICU Swift runtime libs
246+
"-licui18nswift",
247+
"-licuucswift",
248+
"-licudataswift",
249+
// Common-use ordering-agnostic Linux system libs
250+
"-lm",
251+
"-lpthread",
252+
"-lutil",
253+
"-ldl",
254+
"-lz",
224255
};
256+
std::unordered_map<std::string, bool> SwiftRuntimeLibraries;
257+
for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
258+
SwiftRuntimeLibraries[RuntimeLib] = false;
259+
}
225260

226261
// Extract the linker flags from the objects.
227262
for (const auto &BinaryFileName : Invocation.getInputFilenames()) {
@@ -258,9 +293,11 @@ int autolink_extract_main(ArrayRef<const char *> Args, const char *Argv0,
258293
OutOS << Flag << '\n';
259294
}
260295

261-
for (const auto &RuntimeLib : SwiftRuntimeLibraries) {
262-
if (RuntimeLib.second)
263-
OutOS << RuntimeLib.first << '\n';
296+
for (const auto &RuntimeLib : SwiftRuntimeLibsOrdered) {
297+
auto entry = SwiftRuntimeLibraries.find(RuntimeLib);
298+
if (entry != SwiftRuntimeLibraries.end() && entry->second) {
299+
OutOS << entry->first << '\n';
300+
}
264301
}
265302

266303

stdlib/cmake/modules/StdlibOptions.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,16 @@ option(SWIFT_STDLIB_CONCURRENCY_TRACING
228228
"Enable concurrency tracing in the runtime; assumes the presence of os_log(3)
229229
and the os_signpost(3) API."
230230
"${SWIFT_STDLIB_CONCURRENCY_TRACING_default}")
231+
232+
# Use dispatch as the system scheduler by default.
233+
# For convenience, we set this to false when concurrency is disabled.
234+
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
235+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
236+
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
237+
endif()
238+
239+
if(SWIFT_CONCURRENCY_USES_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
240+
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
241+
message(SEND_ERROR "Concurrency requires libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
242+
endif()
243+
endif()

test/Driver/static-stdlib-autolink-linux.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
// RUN: echo 'public func asyncFunc() async { print("Hello") }' > %t/asyncModule.swift
88

99
// RUN: %target-swiftc_driver -emit-library -emit-module -module-name asyncModule -module-link-name asyncModule %t/asyncModule.swift -static -static-stdlib -o %t/libasyncModule.a
10-
// TODO: "-ldispatch -lBlocksRuntime" should be told by asyncModule.swiftmodule transitively
11-
// RUN: %target-swiftc_driver -parse-as-library -static -static-stdlib -module-name main %s %import-static-libdispatch -I%t -L%t -ldispatch -lBlocksRuntime -o %t/main
10+
// RUN: %target-swiftc_driver -parse-as-library -static -static-stdlib -module-name main %s %import-static-libdispatch -I%t -L%t -o %t/main
1211

1312
// RUN: %t/main | %FileCheck %s
1413
// CHECK: Hello

test/Driver/static-stdlib-linux.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// REQUIRES: static_stdlib
44
print("hello world!")
55
// RUN: %empty-directory(%t)
6-
// RUN: %target-swiftc_driver -static-stdlib -o %t/static-stdlib %s
6+
// RUN: %target-swiftc_driver %import-static-libdispatch -static-stdlib -o %t/static-stdlib %s
77
// RUN: %t/static-stdlib | %FileCheck %s
88
// RUN: ldd %t/static-stdlib | %FileCheck %s --check-prefix=LDD
99
// CHECK: hello world!

test/lit.cfg

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,19 +1482,13 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
14821482
config.import_libdispatch = ('-I %s -I %s -L %s'
14831483
% (libdispatch_source_dir, libdispatch_swift_module_dir, libdispatch_artifact_dir))
14841484

1485-
libdispatch_static_artifact_dir = config.libdispatch_static_build_path
1486-
libdispatch_swift_static_module_dir = make_path(libdispatch_static_artifact_dir, 'src', 'swift', 'swift')
1485+
libdispatch_static_artifact_dir = os.path.join(config.libdispatch_static_build_path, 'lib')
14871486
libdispatch_static_artifacts = [
1488-
make_path(libdispatch_static_artifact_dir, 'src', 'libdispatch.a'),
1489-
make_path(libdispatch_static_artifact_dir, 'src', 'swift', 'libswiftDispatch.a'),
1490-
make_path(libdispatch_swift_static_module_dir, 'Dispatch.swiftmodule')]
1487+
make_path(libdispatch_static_artifact_dir, 'libdispatch.a'),
1488+
make_path(libdispatch_static_artifact_dir, 'libBlocksRuntime.a')]
14911489
if (all(os.path.exists(p) for p in libdispatch_static_artifacts)):
14921490
config.available_features.add('libdispatch_static')
1493-
config.import_libdispatch_static = ('-I %s -I %s -L %s -L %s -L %s'
1494-
% (libdispatch_source_dir, libdispatch_swift_static_module_dir,
1495-
make_path(libdispatch_static_artifact_dir, 'src'),
1496-
make_path(libdispatch_static_artifact_dir, 'src', 'BlocksRuntime'),
1497-
make_path(libdispatch_static_artifact_dir, 'src', 'swift')))
1491+
config.import_libdispatch_static = '-L %s' % libdispatch_static_artifact_dir
14981492

14991493
config.target_build_swift = (
15001494
'%s -target %s -toolchain-stdlib-rpath %s %s %s %s %s'
@@ -2552,6 +2546,10 @@ run_filecheck = '%s %s --allow-unused-prefixes --sanitize BUILD_DIR=%s --sanitiz
25522546
config.substitutions.append(('%FileCheck', run_filecheck))
25532547
config.substitutions.append(('%raw-FileCheck', shell_quote(config.filecheck)))
25542548
config.substitutions.append(('%import-libdispatch', getattr(config, 'import_libdispatch', '')))
2549+
# WARNING: the order of components in a substitution name has to be different from the previous one, as lit does
2550+
# a pure string substitution without understanding that these components are grouped together. That is, the following
2551+
# subsitution name can't be `%import-libdispatch-static`, otherwise the first two components will be substituted with
2552+
# the value of `%import-libdispatch` substitution with `-static` string appended to it.
25552553
config.substitutions.append(('%import-static-libdispatch', getattr(config, 'import_libdispatch_static', '')))
25562554

25572555
# Disable COW sanity checks in the swift runtime by default.

utils/build-script-impl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ for host in "${ALL_HOSTS[@]}"; do
20262026
-DSWIFT_PATH_TO_CMARK_BUILD:PATH="$(build_directory ${host} cmark)"
20272027
-DSWIFT_PATH_TO_LIBDISPATCH_SOURCE:PATH="${LIBDISPATCH_SOURCE_DIR}"
20282028
-DSWIFT_PATH_TO_LIBDISPATCH_BUILD:PATH="$(build_directory ${host} libdispatch)"
2029-
-DSWIFT_PATH_TO_LIBDISPATCH_STATIC_BUILD:PATH="$(build_directory ${host} libdispatch_static)"
2029+
-DSWIFT_PATH_TO_LIBDISPATCH_STATIC_BUILD:PATH="$(build_directory ${host} swift)/$(basename $(build_directory ${host} libdispatch))-static-prefix"
20302030
)
20312031

20322032
if [[ "${SWIFT_SDKS}" ]] ; then

0 commit comments

Comments
 (0)