Skip to content

Commit 47abc58

Browse files
committed
SwiftCore: CMake: Hook up filesystem flag
This hooks up the SWIFT_STDLIB_HAS_FILESYSTEM, which then requires setting SWIFT_ARCH and SWIFT_LIB_SUBDIR macros for the backtracer. Note: `FILESYSTEM` in this case does not refer to the C++ filesystem header, but whether the platform you're building for has a filesystem.
1 parent 57657c6 commit 47abc58

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Runtimes/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ defaulted_option(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT "Add symbols for runtim
9595
defaulted_option(SwiftCore_ENABLE_STDLIB_TRACING "Enable tracing in the runtime. Assumes the presence of os_log(3) and the os_signpost(3) API.")
9696
option(SwiftCore_ENABLE_UNICODE_DATA "Include unicode data in Swift runtimes" ON)
9797
option(SwiftCore_ENABLE_SHORT_MANGLING_LOOKUPS "Build with fast-path context descriptor lookups based on well-known short manglings." ON)
98+
option(SwiftCore_ENABLE_FILESYSTEM_SUPPORT "Build for systems that have a filesystem" ON)
9899

99100
defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime support")
100101
defaulted_set(SwiftCore_BACKTRACER_PATH STRING "Set a fixed path to the Swift backtracer")

Runtimes/Core/runtime/CMakeLists.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ if(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER)
7272
Leaks.mm)
7373
endif()
7474

75+
# runtime/Paths.cpp uses `SWIFT_ARCH` and `SWIFT_LIB_SUBDIR` to find the
76+
# subdirectory under `libexec` in which to find the backtracer.
77+
# Fail the configuration if it isn't set appropriately.
78+
# TODO: In the future, we might consider moving the backtracer up to
79+
# `libexec/swift` and drop the platform/architecture specific subdirectories
80+
if(SwiftCore_ENABLE_FILESYSTEM_SUPPORT AND (NOT SwiftCore_ARCH_SUBDIR OR NOT SwiftCore_PLATFORM_SUBDIR))
81+
message(SEND_ERROR "Filesystem support requires setting `SwiftCore_ARCH_SUBDIR` and `SwiftCore_PLATFORM_SUBDIR`")
82+
endif()
83+
7584
# TODO: Probably worth considering putting half of these in a RuntimeConfig.h.in
7685
# file rather than pushing them through macro flags.
7786
target_compile_definitions(swiftRuntime
@@ -86,7 +95,10 @@ target_compile_definitions(swiftRuntime
8695
$<$<BOOL:${SwiftCore_ENABLE_STDLIB_TRACING}>:-DSWIFT_STDLIB_TRACING>
8796
$<$<BOOL:${SwiftCore_ENABLE_SHORT_MANGLING_LOOKUPS}>:-DSWIFT_STDLIB_SHORT_MANGLING_LOOKUPS>
8897
$<$<BOOL:${SwiftCore_HAS_DLADDR}>:-DSWIFT_STDLIB_HAS_DLADDR>
89-
$<$<BOOL:${SwiftCore_HAS_DLSYM}>:-DSWIFT_STDLIB_HAS_DLSYM>)
98+
$<$<BOOL:${SwiftCore_HAS_DLSYM}>:-DSWIFT_STDLIB_HAS_DLSYM>
99+
$<$<BOOL:${SwiftCore_ENABLE_FILESYSTEM_SUPPORT}>:-DSWIFT_STDLIB_HAS_FILESYSTEM>
100+
$<$<AND:$<BOOL:${SwiftCore_ENABLE_FILESYSTEM_SUPPORT}>,$<COMPILE_LANGUAGE:C,CXX>>:-DSWIFT_ARCH="${SwiftCore_ARCH_SUBDIR}">
101+
$<$<AND:$<BOOL:${SwiftCore_ENABLE_FILESYSTEM_SUPPORT}>,$<COMPILE_LANGUAGE:C,CXX>>:-DSWIFT_LIB_SUBDIR="${SwiftCore_PLATFORM_SUBDIR}">)
90102

91103
target_include_directories(swiftRuntime PRIVATE
92104
"${PROJECT_BINARY_DIR}/include"

0 commit comments

Comments
 (0)