Skip to content

Commit e54bcef

Browse files
authored
Merge pull request #77403 from etcwilde/ewilde/stdlib-rebuild-swiftcore
[CMake] Get SwiftCore building with the new build system
2 parents 8feb497 + 12fb294 commit e54bcef

19 files changed

+1019
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,6 @@ Runtimes/**/*.def
9292
Runtimes/**/*.gyb
9393
Runtimes/**/*.apinotes
9494
Runtimes/**/*.yaml
95+
Runtimes/**/*.inc
96+
Runtimes/**/*.json
97+
Runtimes/**/*.modulemap

CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,3 +1579,48 @@ if(XCODE)
15791579
add_custom_target(Miscellaneous
15801580
SOURCES ${SWIFT_TOPLEVEL_HEADERS})
15811581
endif()
1582+
1583+
# New standard library build
1584+
option(SWIFT_ENABLE_NEW_RUNTIME_BUILD "Build Swift runtimes with new build system" OFF)
1585+
if(SWIFT_ENABLE_NEW_RUNTIME_BUILD)
1586+
1587+
add_custom_target(PopulateRuntimeSourceDir
1588+
COMMAND "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Resync.cmake"
1589+
COMMENT "Copying sources into new runtime build")
1590+
1591+
foreach(sdk ${SWIFT_SDKS})
1592+
foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
1593+
# Provide a mechanism to skip building one of these runtimes
1594+
if(SWIFT_SKIP_${sdk}_${arch}_RUNTIME)
1595+
message(STATUS "Skipping: ${arch}-${sdk} runtime build")
1596+
continue()
1597+
endif()
1598+
set(stdlib_target "swift-stdlib-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
1599+
if(${SWIFT_SDK_${sdk}_${arch}_CACHE})
1600+
set(stdlib_cache_file_flag -C ${SWIFT_SDK_${sdk}_${arch}_CACHE})
1601+
endif()
1602+
ExternalProject_Add("${stdlib_target}-core"
1603+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Runtimes/Core"
1604+
# TODO: Add this once we're ready to start swapping out the libraries
1605+
# for testing
1606+
# INSTALL_DIR "${CMAKE_BINARY_DIR}/"
1607+
1608+
DEPENDS PopulateRuntimeSourceDir
1609+
CMAKE_ARGS
1610+
-DCMAKE_INSTALL_LIBDIR:FILEPATH=lib/swift/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${arch}
1611+
# Compiler will see mismatched swift modules and fail initial checks
1612+
-DCMAKE_Swift_COMPILER_WORKS:BOOLEAN=YES
1613+
-DBUILD_SHARED_LIBS:BOOLEAN=YES # TODO: Make this configurable
1614+
${stdlib_cache_file_flag}
1615+
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
1616+
-DCMAKE_INSTALL_PREFIX:FILEPATH=<INSTALL_DIR>
1617+
-DCMAKE_Swift_COMPILER:FILEPATH=$<IF:$<BOOL:${CMAKE_CROSSCOMPILING}>,${CMAKE_Swift_COMPILER},$<PATH:REPLACE_FILENAME,$<TARGET_FILE:swift-frontend>,swiftc>>
1618+
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
1619+
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
1620+
-DCMAKE_COLOR_DIAGNOSTICS:BOOLEAN=${CMAKE_COLOR_DIAGNOSTICS})
1621+
if(NOT ${CMAKE_CROSSCOMPILING})
1622+
add_dependencies("${stdlib_target}" swift-frontend)
1623+
endif()
1624+
endforeach()
1625+
endforeach()
1626+
endif()

Runtimes/Core/CMakeLists.txt

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Notes:
2+
#
3+
# The Demangling library uses `#if SWIFT_HAVE_CRASHREPORTERCLIENT` while the
4+
# runtime library uses `#ifdef SWIFT_HAVE_CRASHREPORTERCLIENT` to toggle that
5+
# functionality. When building the demangling library, the macro should be set
6+
# to 0 or 1 to indicate the presence of the crashreporter.
7+
# When building the runtime library, the existence of the macro indicates the
8+
# presence of the crashreporter.
9+
#
10+
# Runtime library pulls sources and headers from compiler sources (ThreadSanitizer)
11+
# Demangling library pulls sources and headers from compiler sources (all)
12+
#
13+
#
14+
# gyb pulls sources from compiler sources
15+
#
16+
# Stubs:
17+
# Pulls in headers from compiler
18+
# - include/swift/Basic
19+
# - include/swift/Runtime
20+
# - include/swift/Threading
21+
22+
# TODO:
23+
# Platform support:
24+
# - Work on/Verify cross-compiling
25+
# - Work on/Verify Windows and Linux native builds
26+
# Embedded
27+
# -- -Xfrontend -emit-empty-object-file
28+
# Catalyst Support
29+
# -- Will need shadow invocations to generate swiftmodules for Swift parts
30+
# Install *.abi.json, swiftdoc, and swiftsourceinfo
31+
32+
cmake_minimum_required(VERSION 3.26...3.29)
33+
34+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
35+
include(CMakeWorkarounds)
36+
project(SwiftCore LANGUAGES C CXX Swift VERSION 6.1)
37+
38+
# The Swift standard library is not intended for use as a sub-library as part of
39+
# another project. It is tightly coupled with the compiler version.
40+
if(NOT PROJECT_IS_TOP_LEVEL)
41+
message(FATAL_ERROR "Swift Core must build as a standalone project")
42+
endif()
43+
44+
# FIXME: We should not need to refer back into the compiler sources. This is
45+
# needed by gyb, Demangling, Threading, the runtime (ThreadSanitizer.cpp)
46+
set(SwiftCore_SWIFTC_SOURCE_DIR
47+
"${PROJECT_SOURCE_DIR}/../../"
48+
CACHE FILEPATH "Path to the root source directory of the Swift compiler")
49+
50+
include(GNUInstallDirs)
51+
include(AvailabilityMacros)
52+
include(CompilerSettings)
53+
include(DefaultSettings)
54+
include(EmitSwiftInterface)
55+
include(PlatformInfo)
56+
include(gyb)
57+
58+
defaulted_option(SwiftCore_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries")
59+
60+
defaulted_option(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT "Enable Apple CrashReporter integration")
61+
defaulted_option(SwiftCore_ENABLE_OBJC_INTEROP "Enable runtime ObjC interop")
62+
defaulted_option(SwiftCore_ENABLE_TYPE_PRINTING "Enable printing type names")
63+
defaulted_option(SwiftCore_ENABLE_VECTOR_TYPES "Enable vector support")
64+
defaulted_option(SwiftCore_ENABLE_REFLECTION "Enable runtime support for mirrors and reflection support")
65+
defaulted_option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support")
66+
67+
defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime support")
68+
set(SwiftCore_BACKTRACER_PATH ${SwiftCore_BACKTRACER_PATH_default} CACHE STRING "Set a fixed path to the Swift backtracer")
69+
70+
option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF)
71+
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF)
72+
73+
set(SwiftCore_OBJECT_FORMAT "${SwiftCore_OBJECT_FORMAT_default}" CACHE STRING "Object format")
74+
75+
add_compile_definitions(
76+
$<$<BOOL:${SwiftCore_ENABLE_OBJC_INTEROP}>:-DSWIFT_OBJC_INTEROP>
77+
$<$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>:-DSWIFT_LIBRARY_EVOLUTION>
78+
$<$<BOOL:${SwiftCore_ENABLE_CRASH_REPORTER_CLIENT}>:-DSWIFT_HAVE_CRASHREPORTERCLIENT>
79+
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>
80+
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$<BOOL:${SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER}>>
81+
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=$<BOOL:${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS}>>)
82+
83+
add_compile_options( $<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>>:-enable-library-evolution>)
84+
85+
include_directories(include)
86+
87+
add_subdirectory(LLVMSupport)
88+
add_subdirectory(SwiftShims/swift/shims)
89+
add_subdirectory(Demangling)
90+
add_subdirectory(Threading)
91+
add_subdirectory(runtime)
92+
add_subdirectory(stubs)
93+
add_subdirectory(core)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# FIXME: Refactor demangling library so that we aren't pulling sources from
2+
# the compiler.
3+
add_library(swiftDemangling OBJECT
4+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Context.cpp"
5+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Demangler.cpp"
6+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/ManglingUtils.cpp"
7+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/NodePrinter.cpp"
8+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Punycode.cpp"
9+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Remangler.cpp"
10+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/NodeDumper.cpp"
11+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Errors.cpp")
12+
target_compile_definitions(swiftDemangling PRIVATE swiftCore_EXPORTS
13+
$<$<BOOL:${SwiftCore_ENABLE_OBJC_INTEROP}>:-DSWIFT_SUPPORT_OLD_MANGLING>
14+
$<$<BOOL:${SwiftCore_ENABLE_TYPE_PRINTING}>:-DSWIFT_STDLIB_HAS_TYPE_PRINTING>
15+
$<$<BOOL:${SwiftCore_ENABLE_CRASH_REPORTER_CLIENT}>:-DSWIFT_HAVE_CRASHREPORTERCLIENT>)
16+
17+
target_include_directories(swiftDemangling
18+
PRIVATE
19+
"${SwiftCore_SWIFTC_SOURCE_DIR}/include"
20+
"${PROJECT_BINARY_DIR}/include")
21+
22+
target_link_libraries(swiftDemangling PRIVATE swiftShims)
23+
24+
if(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT)
25+
# We could likely pull the copy from the runtime sources
26+
add_library(swiftDemanglingCR OBJECT
27+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/CrashReporter.cpp")
28+
target_link_libraries(swiftDemanglingCR PRIVATE swiftShims)
29+
endif()
30+
31+
if(SwiftCore_ENABLE_OBJC_INTEROP)
32+
target_sources(swiftDemangling PRIVATE
33+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/OldDemangler.cpp"
34+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/OldRemangler.cpp")
35+
endif()
36+
37+
if(LINUX OR BSD)
38+
target_compile_options(swiftDemangling PRIVATE -fno-lto)
39+
endif()
40+
41+
if(NOT BUILD_SHARED_LIBS)
42+
install(TARGETS swiftDemangling)
43+
endif()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
add_library(swiftLLVMSupport OBJECT
2+
ErrorHandling.cpp
3+
Hashing.cpp
4+
MemAlloc.cpp
5+
SmallPtrSet.cpp
6+
SmallVector.cpp
7+
StringRef.cpp)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Swift shim header files
2+
install(FILES
3+
AssertionReporting.h
4+
CoreFoundationShims.h
5+
EmbeddedShims.h
6+
FoundationShims.h
7+
GlobalObjects.h
8+
HeapObject.h
9+
KeyPath.h
10+
LibcOverlayShims.h
11+
LibcShims.h
12+
MetadataSections.h
13+
Random.h
14+
RefCount.h
15+
Reflection.h
16+
RuntimeShims.h
17+
RuntimeStubs.h
18+
SwiftStdbool.h
19+
SwiftStddef.h
20+
SwiftStdint.h
21+
System.h
22+
Target.h
23+
ThreadLocalStorage.h
24+
UnicodeData.h
25+
Visibility.h
26+
_SwiftConcurrency.h
27+
_SwiftDistributed.h
28+
_SynchronizationShims.h
29+
module.modulemap
30+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/shims")
31+
32+
add_library(swiftShims INTERFACE)
33+
target_include_directories(swiftShims INTERFACE
34+
$<$<COMPILE_LANGUAGE:C,CXX>:${CMAKE_CURRENT_SOURCE_DIR}/../../>
35+
$<$<COMPILE_LANGUAGE:Swift>:${CMAKE_CURRENT_SOURCE_DIR}>)
36+
target_compile_options(swiftShims INTERFACE
37+
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap>")
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# TODO: I think we can build the one that actually matters based on the
2+
# platform we're building, rather than relying just on macro definitions
3+
# and linking empty objects.
4+
# https://github.com/swiftlang/swift/issues/77435
5+
add_library(swiftThreading OBJECT
6+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/C11.cpp"
7+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/Linux.cpp"
8+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/Pthreads.cpp"
9+
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/Win32.cpp")
10+
target_link_libraries(swiftThreading PRIVATE swiftShims)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
file(STRINGS "${SwiftCore_SWIFTC_SOURCE_DIR}/utils/availability-macros.def" availability_defs)
2+
list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$")
3+
foreach(def ${availability_defs})
4+
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">")
5+
endforeach()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# This file contains workarounds for dealing with bugs between CMake and the
2+
# Swift compiler.
3+
4+
# This is a workaround to avoid crashing the Swift compiler while typechecking
5+
# swiftCore. The Swift compiler must be run num-threads=0 with WMO in all build
6+
# configurations.
7+
# These must be set in CMake _before_ the Swift language is enabled.
8+
# This is manipulating undocumented CMake-internal variables that may change
9+
# behavior at any time and should not be relied on.
10+
# Otherwise CMake will generate the build graph incorrectly for this setup.
11+
# Ideally this file should not need to exist.
12+
13+
set(CMAKE_Swift_NUM_THREADS 0)
14+
if(POLICY CMP0157)
15+
set(CMAKE_Swift_COMPILE_OBJECT "<CMAKE_Swift_COMPILER> -num-threads ${CMAKE_Swift_NUM_THREADS} -c <DEFINES> <FLAGS> <INCLUDES> <SOURCE>")
16+
17+
set(CMAKE_Swift_COMPILATION_MODE wholemodule)
18+
19+
if(NOT SwiftStdlib_NUM_LINK_JOBS MATCHES "^[0-9]+$")
20+
cmake_host_system_information(RESULT SwiftStdlib_NUM_LINK_JOBS QUERY NUMBER_OF_LOGICAL_CORES)
21+
endif()
22+
23+
set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -num-threads ${SwiftStdlib_NUM_LINK_JOBS} -emit-executable -o <TARGET> <FLAGS> <OBJECTS> <LINK_FLAGS> <LINK_LIBRARIES>")
24+
set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -num-threads ${SwiftStdlib_NUM_LINK_JOBS} -emit-library <CMAKE_SHARED_LIBRARY_Swift_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
25+
else()
26+
set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -wmo -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
27+
28+
set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -wmo -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
29+
30+
set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -wmo -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
31+
32+
set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>")
33+
set(CMAKE_Swift_ARCHIVE_FINISH "")
34+
endif()
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
include(CheckSourceCompiles)
2+
include(CheckCompilerFlag)
3+
4+
# Use C+17
5+
set(SwiftCore_MIN_CXX_STANDARD 17)
6+
# Unset CMAKE_CXX_STANDARD if it's too low and in the CMakeCache.txt
7+
if($CACHE{CMAKE_CXX_STANDARD} AND $CACHE{CMAKE_CXX_STANDARD} LESS ${SwiftCore_MIN_CXX_STANDARD})
8+
message(WARNING "Resetting cache value for CMAKE_CXX_STANDARD to ${SwiftCore_MIN_CXX_STANDARD}")
9+
unset(CMAKE_CXX_STANDARD CACHE)
10+
endif()
11+
12+
# Allow manually specified CMAKE_CXX_STANDARD if it's greater than the minimum
13+
# required C++ version
14+
if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD LESS ${SwiftCore_MIN_CXX_STANDARD})
15+
message(FATAL_ERROR "Requested CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} which is less than the minimum C++ standard ${SwiftCore_MIN_CXX_STANDARD}")
16+
endif()
17+
18+
set(CMAKE_CXX_STANDARD ${SwiftCore_MIN_CXX_STANDARD} CACHE STRING "C++ standard to conform to")
19+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
20+
set(CMAKE_CXX_EXTENSIONS NO)
21+
22+
check_source_compiles(CXX
23+
"#if !(__has_attribute(swiftcall) && \
24+
__has_attribute(swift_context) && \
25+
__has_attribute(swift_error_result) && \
26+
__has_attribute(swift_indirect_result))
27+
#error CXX compiler must support Swift calling conventions
28+
#endif
29+
int main(void) { return 0; }"
30+
HAVE_SWIFTCALL)
31+
32+
if(NOT HAVE_SWIFTCALL)
33+
message(SEND_ERROR "CXX Compiler must support Swift calling conventions")
34+
endif()
35+
36+
check_source_compiles(CXX
37+
"#if !(__has_attribute(swiftasynccall) && \
38+
__has_attribute(swift_async_context))
39+
#error CXX compiler must support Swift async calling conventions
40+
#endif
41+
int main(void) { return 0; }"
42+
HAVE_SWIFT_ASYNC_CALL)
43+
44+
if(NOT HAVE_SWIFT_ASYNC_CALL)
45+
message(SEND_ERROR "CXX Compiler must support Swift async calling conventions")
46+
endif()
47+
48+
check_compiler_flag(Swift "-color-diagnostics" HAVE_SWIFT_COLOR_DIAGNOSTICS)
49+
if(HAVE_SWIFT_COLOR_DIAGNOSTICS)
50+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-color-diagnostics>)
51+
endif()
52+
53+
check_compiler_flag(Swift "-diagnostic-style swift" HAVE_SWIFT_DIAGNOSTIC_STYLE)
54+
if(HAVE_SWIFT_DIAGNOSTIC_STYLE)
55+
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-diagnostic-style$<SEMICOLON>swift>)
56+
endif()
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This file is designed to setup reasonable defaults for the various settings so
2+
# that configuring a build for a given platform is likely to build
3+
# out-of-the-box without customization. This does not mean that it is the only
4+
# way that will work, or that it represents a shipping configuration.
5+
6+
set(SwiftCore_ENABLE_BACKTRACING_default OFF) # TODO: enable this by default
7+
set(SwiftCore_ENABLE_COMMANDLINE_SUPPORT_default OFF) # TODO: enable this by default
8+
9+
set(SwiftCore_ENABLE_TYPE_PRINTING_default ON)
10+
11+
set(SwiftCore_BACKTRACER_PATH_default "")
12+
13+
macro(defaulted_option variable helptext)
14+
if(NOT DEFINED ${variable}_default)
15+
set(${variable}_default OFF)
16+
endif()
17+
option(${variable} ${helptext} ${${variable}_default})
18+
endmacro()
19+
20+
if(APPLE)
21+
set(SwiftCore_ENABLE_LIBRARY_EVOLUTION_default ON)
22+
set(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT_default ON)
23+
set(SwiftCore_ENABLE_OBJC_INTEROP_default ON)
24+
set(SwiftCore_ENABLE_REFLECTION_default ON)
25+
elseif(CMAKE_SYSTEM_NAME STREQUAL "WASM")
26+
set(SwiftCore_OBJECT_FORMAT_default "elf")
27+
elseif(LINUX)
28+
set(SwiftCore_OBJECT_FORMAT_default "elf")
29+
elseif(WIN32)
30+
set(SwiftCore_OBJECT_FORMAT_default "coff")
31+
endif()

0 commit comments

Comments
 (0)