From a2c33ad22c971611050b071ca7e58b9d808b33ab Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 23 Feb 2024 13:44:05 +0000 Subject: [PATCH 1/4] [Runtime] Fix generation of .lnk files for static linking. Use the new `SWIFT_SDK__STATIC_LINKING_SUPPORTED` and `_STATIC_ONLY` flags instead of hardcoding support for Linux and WASI. Also, use the `_LIB_SUBDIR` variable rather than lowercasing the SDK. rdar://123504757 --- stdlib/public/runtime/CMakeLists.txt | 84 +++++++++++++++++----------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index 2bca14bbc2f32..be5bb9e352be7 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -114,39 +114,35 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags}) list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS) list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/stdlib/include/llvm/Support -I${SWIFT_SOURCE_DIR}/include) -if(SWIFT_BUILD_STATIC_STDLIB) - set(static_binary_lnk_file_list) +set(static_binary_lnk_file_list) - foreach(sdk ${SWIFT_SDKS}) - if(NOT "${sdk}" STREQUAL "LINUX" AND NOT "${sdk}" STREQUAL "WASI") - continue() - endif() +foreach(sdk ${SWIFT_SDKS}) + if(NOT SWIFT_SDK_${sdk}_STATIC_LINKING_SUPPORTED) + continue() + endif() - string(TOLOWER "${sdk}" lowercase_sdk) - set(static_binary_lnk_src "${SWIFT_SOURCE_DIR}/stdlib/public/Resources/${lowercase_sdk}/static-executable-args.lnk") + if(SWIFT_BUILD_STATIC_STDLIB OR SWIFT_SDK_${sdk}_STATIC_ONLY) + set(lib_dir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}") + set(static_binary_lnk_src "${SWIFT_SOURCE_DIR}/stdlib/public/Resources/${lib_dir}/static-executable-args.lnk") # Generate the static-executable-args.lnk file used for ELF systems (eg linux) - set(linkfile "${lowercase_sdk}/static-executable-args.lnk") + set(linkfile "${lib_dir}/static-executable-args.lnk") add_custom_command_target(swift_static_binary_${sdk}_args COMMAND - "${CMAKE_COMMAND}" -E copy - "${static_binary_lnk_src}" - "${SWIFTSTATICLIB_DIR}/${linkfile}" + "${CMAKE_COMMAND}" -E copy + "${static_binary_lnk_src}" + "${SWIFTSTATICLIB_DIR}/${linkfile}" OUTPUT - "${SWIFTSTATICLIB_DIR}/${linkfile}" + "${SWIFTSTATICLIB_DIR}/${linkfile}" DEPENDS - "${static_binary_lnk_src}") + "${static_binary_lnk_src}") list(APPEND static_binary_lnk_file_list ${swift_static_binary_${sdk}_args}) swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" - DESTINATION "lib/swift_static/${lowercase_sdk}" - COMPONENT stdlib) - endforeach() - if(static_binary_lnk_file_list) - add_dependencies(stdlib ${static_binary_lnk_file_list}) - add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list}) + DESTINATION "lib/swift_static/${lib_dir}" + COMPONENT stdlib) endif() -endif() +endforeach() add_swift_target_library(swiftRuntime OBJECT_LIBRARY ${swift_runtime_sources} @@ -248,7 +244,7 @@ foreach(sdk ${SWIFT_SDKS}) "${static_runtime_registrar}" DEPENDS "${swiftrtObject}") - if(SWIFT_BUILD_DYNAMIC_STDLIB) + if(SWIFT_BUILD_DYNAMIC_STDLIB AND NOT SWIFT_SDK_${sdk}_STATIC_ONLY) swift_install_in_component(FILES "${shared_runtime_registrar}" DESTINATION @@ -256,7 +252,7 @@ foreach(sdk ${SWIFT_SDKS}) COMPONENT stdlib) endif() - if(SWIFT_BUILD_STATIC_STDLIB) + if(SWIFT_BUILD_STATIC_STDLIB OR SWIFT_SDK_${sdk}_STATIC_ONLY) swift_install_in_component(FILES "${static_runtime_registrar}" DESTINATION @@ -273,10 +269,26 @@ foreach(sdk ${SWIFT_SDKS}) add_dependencies(stdlib swift-stdlib-${arch_suffix} swiftImageRegistration-${arch_suffix}) endif() - # Generate the static-stdlib-args.lnk file used by -static-stdlib option for - # 'GenericUnix' (eg linux) - if(SWIFT_SDK_${sdk}_OBJECT_FORMAT STREQUAL "ELF") - string(TOLOWER "${sdk}" lowercase_sdk) + endforeach() + + # Generate the static-stdlib-args.lnk file used by -static-stdlib option for + # 'GenericUnix' (eg linux) + if(SWIFT_SDK_${sdk}_OBJECT_FORMAT STREQUAL "ELF") + set(lib_dir "${SWIFT_SDK_${sdk}_LIB_SUBDIR}") + set(static_stdlib_lnk_src "${SWIFT_SOURCE_DIR}/stdlib/public/Resources/${lib_dir}/static-stdlib-args.lnk") + set(linkfile ${lib_dir}/static-stdlib-args.lnk) + if(EXISTS "${static_stdlib_lnk_src}") + add_custom_command_target(swift_static_stdlib_${sdk}_args + COMMAND + "${CMAKE_COMMAND}" -E copy + "${static_stdlib_lnk_src}" + "${SWIFTSTATICLIB_DIR}/${linkfile}" + OUTPUT + "${SWIFTSTATICLIB_DIR}/${linkfile}" + DEPENDS + "${static_stdlib_lnk_src}") + list(APPEND static_binary_lnk_file_list ${swift_static_stdlib_${sdk}_args}) + else() set(libpthread -lpthread) set(concurrency_libs) set(android_libraries) @@ -287,7 +299,6 @@ foreach(sdk ${SWIFT_SDKS}) set(concurrency_libs "-ldispatch -lBlocksRuntime") endif() - set(linkfile ${lowercase_sdk}/static-stdlib-args.lnk) file(WRITE "${SWIFTSTATICLIB_DIR}/${linkfile}" " -ldl ${libpthread} @@ -299,10 +310,17 @@ ${concurrency_libs} -Xlinker -export-dynamic -Xlinker --exclude-libs -Xlinker ALL") - - swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" - DESTINATION "lib/swift_static/${lowercase_sdk}" - COMPONENT stdlib) endif() - endforeach() + + swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}" + DESTINATION "lib/swift_static/${lib_dir}" + COMPONENT stdlib) + endif() + endforeach() + +if(static_binary_lnk_file_list) + add_dependencies(stdlib ${static_binary_lnk_file_list}) + add_custom_target(static_binary_magic ALL DEPENDS ${static_binary_lnk_file_list}) +endif() + From a25cd3775001a22148f079d98e979ca827d1e58d Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 23 Feb 2024 14:43:41 +0000 Subject: [PATCH 2/4] Add support to the compiler for musl and the LINUX_STATIC SDK. This is really just about setting appropriate defaults (such as making sure that the static Linux triple causes us to use lld). rdar://123506306 --- lib/Basic/Platform.cpp | 12 +++++++++++- lib/ClangImporter/ClangImporter.cpp | 2 +- lib/ClangImporter/ClangIncludePaths.cpp | 10 +++++++--- lib/Driver/UnixToolChains.cpp | 7 +++++-- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp index bb897f9ca64ec..256f5c02254ee 100644 --- a/lib/Basic/Platform.cpp +++ b/lib/Basic/Platform.cpp @@ -231,7 +231,17 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) { case llvm::Triple::XROS: return getPlatformNameForDarwin(getDarwinPlatformKind(triple)); case llvm::Triple::Linux: - return triple.isAndroid() ? "android" : "linux"; + if (triple.isAndroid()) + return "android"; + else if (triple.isMusl()) { + // The triple for linux-static is -swift-linux-musl, to distinguish + // it from a "normal" musl set-up (ala Alpine). + if (triple.getVendor() == llvm::Triple::Swift) + return "linux-static"; + else + return "musl"; + } else + return "linux"; case llvm::Triple::FreeBSD: return "freebsd"; case llvm::Triple::OpenBSD: diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index edb1aa4b53516..c0ae6472db04a 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -646,7 +646,7 @@ void importer::getNormalInvocationArguments( // using Glibc or a libc that respects that flag. This will cause some // source breakage however (specifically with strerror_r()) on Linux // without a workaround. - if (triple.isOSFuchsia() || triple.isAndroid()) { + if (triple.isOSFuchsia() || triple.isAndroid() || triple.isMusl()) { // Many of the modern libc features are hidden behind feature macros like // _GNU_SOURCE or _XOPEN_SOURCE. invocationArgStrs.insert(invocationArgStrs.end(), { diff --git a/lib/ClangImporter/ClangIncludePaths.cpp b/lib/ClangImporter/ClangIncludePaths.cpp index aed4700bd19ad..17b0156143057 100644 --- a/lib/ClangImporter/ClangIncludePaths.cpp +++ b/lib/ClangImporter/ClangIncludePaths.cpp @@ -180,7 +180,7 @@ createClangArgs(const ASTContext &ctx, clang::driver::Driver &clangDriver) { static bool shouldInjectLibcModulemap(const llvm::Triple &triple) { return triple.isOSGlibc() || triple.isOSOpenBSD() || triple.isOSFreeBSD() || - triple.isAndroid() || triple.isOSWASI(); + triple.isAndroid() || triple.isMusl() || triple.isOSWASI(); } static SmallVector, 2> @@ -254,8 +254,9 @@ static void getLibStdCxxFileMapping( // We currently only need this when building for Linux. if (!triple.isOSLinux()) return; - // Android uses libc++. - if (triple.isAndroid()) + // Android uses libc++, as does our fully static Linux config. + if (triple.isAndroid() + || (triple.isMusl() && triple.getVendor() == llvm::Triple::Swift)) return; // Extract the libstdc++ installation path from Clang driver. @@ -534,6 +535,9 @@ ClangInvocationFileMapping swift::getClangInvocationFileMapping( // WASI Mappings libcFileMapping = getLibcFileMapping(ctx, "wasi-libc.modulemap", std::nullopt, vfs); + } else if (triple.isMusl()) { + libcFileMapping = + getLibcFileMapping(ctx, "musl.modulemap", StringRef("SwiftMusl.h"), vfs); } else { // Android/BSD/Linux Mappings libcFileMapping = getLibcFileMapping(ctx, "glibc.modulemap", diff --git a/lib/Driver/UnixToolChains.cpp b/lib/Driver/UnixToolChains.cpp index 3452c1395ede1..1b58784c40a5a 100644 --- a/lib/Driver/UnixToolChains.cpp +++ b/lib/Driver/UnixToolChains.cpp @@ -127,7 +127,9 @@ bool isAmazonLinux2023Host() { } std::string toolchains::GenericUnix::getDefaultLinker() const { - if (getTriple().isAndroid() || isAmazonLinux2023Host()) + if (getTriple().isAndroid() || isAmazonLinux2023Host() + || (getTriple().isMusl() + && getTriple().getVendor() == llvm::Triple::Swift)) return "lld"; switch (getTriple().getArch()) { @@ -285,7 +287,8 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job, } SmallString<128> SharedResourceDirPath; - getResourceDirPath(SharedResourceDirPath, context.Args, /*Shared=*/true); + getResourceDirPath(SharedResourceDirPath, context.Args, + /*Shared=*/!(staticExecutable || staticStdlib)); SmallString<128> swiftrtPath = SharedResourceDirPath; llvm::sys::path::append(swiftrtPath, From 978169f02912e7dada7fea0ddc0d5138944bfb18 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 3 May 2024 13:20:01 +0100 Subject: [PATCH 3/4] [ClangImporter] Don't put built-in headers in system modules for musl. We only need this for WASI and Glibc. rdar://123506306 --- lib/ClangImporter/ClangIncludePaths.cpp | 37 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/ClangImporter/ClangIncludePaths.cpp b/lib/ClangImporter/ClangIncludePaths.cpp index 17b0156143057..11d95131b701b 100644 --- a/lib/ClangImporter/ClangIncludePaths.cpp +++ b/lib/ClangImporter/ClangIncludePaths.cpp @@ -530,11 +530,32 @@ ClangInvocationFileMapping swift::getClangInvocationFileMapping( const llvm::Triple &triple = ctx.LangOpts.Target; + // For modulemaps that have all the C standard library headers together in + // a single module, we end up with module cycles with the clang _Builtin_ + // modules. e.g. includes on these platforms. The + // clang builtin include-nexts . When both of those + // platform headers are in the SwiftLibc module, there's a module cycle + // SwiftLibc -> _Builtin_stdint -> SwiftLibc (i.e. inttypes.h (platform) -> + // stdint.h (builtin) -> stdint.h (platform)). + // + // Until these modulemaps can be fixed, the builtin headers need to join + // the system modules to avoid the cycle. + // + // Note that this does nothing to fix the same problem with C++ headers, + // and that this is generally a fragile solution. + // + // We start by assuming we do *not* need to do this, then enable it for + // affected modulemaps. + result.requiresBuiltinHeadersInSystemModules = false; + SmallVector, 2> libcFileMapping; if (triple.isOSWASI()) { // WASI Mappings libcFileMapping = getLibcFileMapping(ctx, "wasi-libc.modulemap", std::nullopt, vfs); + + // WASI's module map needs fixing + result.requiresBuiltinHeadersInSystemModules = true; } else if (triple.isMusl()) { libcFileMapping = getLibcFileMapping(ctx, "musl.modulemap", StringRef("SwiftMusl.h"), vfs); @@ -542,21 +563,11 @@ ClangInvocationFileMapping swift::getClangInvocationFileMapping( // Android/BSD/Linux Mappings libcFileMapping = getLibcFileMapping(ctx, "glibc.modulemap", StringRef("SwiftGlibc.h"), vfs); + + // glibc.modulemap needs fixing + result.requiresBuiltinHeadersInSystemModules = true; } result.redirectedFiles.append(libcFileMapping); - // Both libc module maps have the C standard library headers all together in a - // SwiftLibc module. That leads to module cycles with the clang _Builtin_ - // modules. e.g. includes on these platforms. The - // clang builtin include-nexts . When both of those - // platform headers are in the SwiftLibc module, there's a module cycle - // SwiftLibc -> _Builtin_stdint -> SwiftLibc (i.e. inttypes.h (platform) -> - // stdint.h (builtin) -> stdint.h (platform)). Until this can be fixed in - // these module maps, the clang builtin headers need to join the "system" - // modules (SwiftLibc). i.e. when the clang builtin stdint.h is in the - // SwiftLibc module too, the cycle goes away. Note that - // -fbuiltin-headers-in-system-modules does nothing to fix the same problem - // with C++ headers, and is generally fragile. - result.requiresBuiltinHeadersInSystemModules = !libcFileMapping.empty(); if (ctx.LangOpts.EnableCXXInterop) getLibStdCxxFileMapping(result, ctx, vfs); From f4bf27852fe3e6c7278d6d5a2870a4507084fcd8 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Fri, 23 Feb 2024 15:29:53 +0000 Subject: [PATCH 4/4] [Backtracing] Make the backtracer work for fully-static Linux. The backtracer and its build system need a couple of changes to make them work with the new fully-static Linux support. rdar://123507656 --- stdlib/public/Backtracing/CMakeLists.txt | 2 +- stdlib/public/Backtracing/Context.swift | 4 +-- .../libexec/swift-backtrace/CMakeLists.txt | 25 +++++++++++++------ .../libexec/swift-backtrace/TargetLinux.swift | 4 +++ .../libexec/swift-backtrace/Utils.swift | 2 ++ .../public/libexec/swift-backtrace/main.swift | 2 ++ stdlib/public/runtime/CrashHandlerLinux.cpp | 8 ++++++ stdlib/public/runtime/Paths.cpp | 12 +++++++++ 8 files changed, 49 insertions(+), 10 deletions(-) diff --git a/stdlib/public/Backtracing/CMakeLists.txt b/stdlib/public/Backtracing/CMakeLists.txt index 7382a0edc40bb..d4ed9446c022a 100644 --- a/stdlib/public/Backtracing/CMakeLists.txt +++ b/stdlib/public/Backtracing/CMakeLists.txt @@ -92,5 +92,5 @@ add_swift_target_library(swift_Backtracing ${SWIFT_STDLIB_LIBRARY_BUILD_TYPES} I INSTALL_IN_COMPONENT stdlib MACCATALYST_BUILD_FLAVOR "zippered" - TARGET_SDKS OSX LINUX + TARGET_SDKS OSX LINUX LINUX_STATIC ) diff --git a/stdlib/public/Backtracing/Context.swift b/stdlib/public/Backtracing/Context.swift index 7c35e48001d7a..bfb015e6d962c 100644 --- a/stdlib/public/Backtracing/Context.swift +++ b/stdlib/public/Backtracing/Context.swift @@ -708,10 +708,10 @@ extension arm_gprs { } } - to[31] = mctx.sp + to[31] = UInt64(mctx.sp) } } - gprs.pc = mctx.pc + gprs.pc = UInt64(mctx.pc) gprs.valid = 0x1ffffffff } diff --git a/stdlib/public/libexec/swift-backtrace/CMakeLists.txt b/stdlib/public/libexec/swift-backtrace/CMakeLists.txt index 75c18b64c7081..f06179e9d84c4 100644 --- a/stdlib/public/libexec/swift-backtrace/CMakeLists.txt +++ b/stdlib/public/libexec/swift-backtrace/CMakeLists.txt @@ -3,11 +3,13 @@ set(darwin) set(wincrt_sdk) set(glibc) +set(musl) if(SWIFT_BUILD_SDK_OVERLAY) set(darwin Darwin) set(wincrt_sdk CRT WinSDK) set(glibc Glibc) + set(musl Musl) endif() # Similarly, we only want the _Backtracing dependency if we're building @@ -41,9 +43,10 @@ add_swift_target_executable(swift-backtrace BUILD_WITH_LIBEXEC SWIFT_MODULE_DEPENDS ${backtracing} - SWIFT_MODULE_DEPENDS_OSX ${darwin} - SWIFT_MODULE_DEPENDS_WINDOWS ${wincrt_sdk} - SWIFT_MODULE_DEPENDS_LINUX ${glibc} + SWIFT_MODULE_DEPENDS_OSX ${darwin} + SWIFT_MODULE_DEPENDS_WINDOWS ${wincrt_sdk} + SWIFT_MODULE_DEPENDS_LINUX ${glibc} + SWIFT_MODULE_DEPENDS_LINUX_STATIC ${musl} INSTALL_IN_COMPONENT libexec COMPILE_FLAGS @@ -52,7 +55,14 @@ add_swift_target_executable(swift-backtrace BUILD_WITH_LIBEXEC TARGET_SDKS OSX LINUX) +set(static_target_sdks) if(SWIFT_BUILD_STATIC_STDLIB) + list(APPEND static_target_sdks "LINUX") +endif() +if("LINUX_STATIC" IN_LIST SWIFT_SDKS) + list(APPEND static_target_sdks "LINUX_STATIC") +endif() +if(static_target_sdks) add_swift_target_executable(swift-backtrace-static BUILD_WITH_LIBEXEC PREFER_STATIC @@ -60,14 +70,15 @@ if(SWIFT_BUILD_STATIC_STDLIB) SWIFT_MODULE_DEPENDS ${backtracing} - SWIFT_MODULE_DEPENDS_OSX ${darwin} - SWIFT_MODULE_DEPENDS_WINDOWS ${wincrt_sdk} - SWIFT_MODULE_DEPENDS_LINUX ${glibc} + SWIFT_MODULE_DEPENDS_OSX ${darwin} + SWIFT_MODULE_DEPENDS_WINDOWS ${wincrt_sdk} + SWIFT_MODULE_DEPENDS_LINUX ${glibc} + SWIFT_MODULE_DEPENDS_LINUX_STATIC ${musl} INSTALL_IN_COMPONENT libexec COMPILE_FLAGS ${BACKTRACING_COMPILE_FLAGS} -parse-as-library - TARGET_SDKS LINUX) + TARGET_SDKS ${static_target_sdks}) endif() diff --git a/stdlib/public/libexec/swift-backtrace/TargetLinux.swift b/stdlib/public/libexec/swift-backtrace/TargetLinux.swift index 04deff424448e..4f843873efae1 100644 --- a/stdlib/public/libexec/swift-backtrace/TargetLinux.swift +++ b/stdlib/public/libexec/swift-backtrace/TargetLinux.swift @@ -17,7 +17,11 @@ #if os(Linux) +#if canImport(Glibc) import Glibc +#elseif canImport(Musl) +import Musl +#endif import _Backtracing @_spi(Internal) import _Backtracing diff --git a/stdlib/public/libexec/swift-backtrace/Utils.swift b/stdlib/public/libexec/swift-backtrace/Utils.swift index 9d104a857f174..cf683c6da03ec 100644 --- a/stdlib/public/libexec/swift-backtrace/Utils.swift +++ b/stdlib/public/libexec/swift-backtrace/Utils.swift @@ -18,6 +18,8 @@ import Darwin.C #elseif canImport(Glibc) import Glibc +#elseif canImport(Musl) +import Musl #elseif canImport(CRT) import CRT #endif diff --git a/stdlib/public/libexec/swift-backtrace/main.swift b/stdlib/public/libexec/swift-backtrace/main.swift index d68e597cef669..f83e584639c99 100644 --- a/stdlib/public/libexec/swift-backtrace/main.swift +++ b/stdlib/public/libexec/swift-backtrace/main.swift @@ -16,6 +16,8 @@ import Darwin #elseif canImport(Glibc) import Glibc +#elseif canImport(Musl) +import Musl #elseif canImport(CRT) import CRT #endif diff --git a/stdlib/public/runtime/CrashHandlerLinux.cpp b/stdlib/public/runtime/CrashHandlerLinux.cpp index 42655597faf1d..1c188374bc544 100644 --- a/stdlib/public/runtime/CrashHandlerLinux.cpp +++ b/stdlib/public/runtime/CrashHandlerLinux.cpp @@ -16,6 +16,14 @@ #ifdef __linux__ +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 +#endif + +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE 1 +#endif + #include #include diff --git a/stdlib/public/runtime/Paths.cpp b/stdlib/public/runtime/Paths.cpp index bba1b6e2db7e4..131a24ed40502 100644 --- a/stdlib/public/runtime/Paths.cpp +++ b/stdlib/public/runtime/Paths.cpp @@ -525,6 +525,18 @@ _swift_initRuntimePath(void *) { int ret = ::dladdr((void *)_swift_initRuntimePath, &dli); if (!ret) { +#ifdef __linux__ + // If we don't find anything, try reading /proc/self/exe as a fallback; + // this is needed with Musl when statically linking because in that case + // dladdr() does nothing. + char pathBuf[4096]; + ssize_t len = readlink("/proc/self/exe", pathBuf, sizeof(pathBuf)); + if (len > 0 && len < sizeof(pathBuf)) { + runtimePath = ::strdup(pathBuf); + return; + } +#endif + swift::fatalError(/* flags = */ 0, "Unable to obtain Swift runtime path\n"); }