-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CMake] Get SwiftCore building with the new build system #77403
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
etcwilde
merged 17 commits into
swiftlang:main
from
etcwilde:ewilde/stdlib-rebuild-swiftcore
Nov 7, 2024
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
46dfee2
Get swiftLLVMSupport building
etcwilde bfb7596
Add SwiftShims as an interface library
etcwilde b95e3cb
Add SwiftDemangling
etcwilde 8dd5e50
Build threading library
etcwilde 9642995
Build runtime library
etcwilde f3b5fcd
Add stubs library to build
etcwilde 03ba118
Add swiftCore library
etcwilde e2b878b
Setup reasonable defaults
etcwilde db233bc
Hook new build into existing Swift project
etcwilde 2a3e6d5
Moving compiler-src-dir refs
etcwilde 4f6489f
Fixing comments
etcwilde 50871f9
Get Android building
etcwilde 8385137
Auto populate runtime source directory
etcwilde 1aeab07
Fix rpath flag
etcwilde dad1ea8
Shuffle definitions around
etcwilde 2c07a23
Cleanup WMO forcing
etcwilde 12fb294
Remove SwiftCore_SWIFTC_CLANGIMPORTER_RESOURCE_DIR
etcwilde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Notes: | ||
# | ||
# The Demangling library uses `#if SWIFT_HAVE_CRASHREPORTERCLIENT` while the | ||
# runtime library uses `#ifdef SWIFT_HAVE_CRASHREPORTERCLIENT` to toggle that | ||
# functionality. When building the demangling library, the macro should be set | ||
# to 0 or 1 to indicate the presence of the crashreporter. | ||
# When building the runtime library, the existence of the macro indicates the | ||
# presence of the crashreporter. | ||
# | ||
# Runtime library pulls sources and headers from compiler sources (ThreadSanitizer) | ||
# Demangling library pulls sources and headers from compiler sources (all) | ||
# | ||
# | ||
# gyb pulls sources from compiler sources | ||
# | ||
# Stubs: | ||
# Pulls in headers from compiler | ||
# - include/swift/Basic | ||
# - include/swift/Runtime | ||
# - include/swift/Threading | ||
|
||
# TODO: | ||
# Platform support: | ||
# - Work on/Verify cross-compiling | ||
# - Work on/Verify Windows and Linux native builds | ||
# Embedded | ||
# -- -Xfrontend -emit-empty-object-file | ||
# Catalyst Support | ||
# -- Will need shadow invocations to generate swiftmodules for Swift parts | ||
# Install *.abi.json, swiftdoc, and swiftsourceinfo | ||
|
||
cmake_minimum_required(VERSION 3.26...3.29) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") | ||
include(CMakeWorkarounds) | ||
project(SwiftCore LANGUAGES C CXX Swift VERSION 6.1) | ||
|
||
# The Swift standard library is not intended for use as a sub-library as part of | ||
# another project. It is tightly coupled with the compiler version. | ||
if(NOT PROJECT_IS_TOP_LEVEL) | ||
message(FATAL_ERROR "Swift Core must build as a standalone project") | ||
endif() | ||
|
||
# FIXME: We should not need to refer back into the compiler sources. This is | ||
# needed by gyb, Demangling, Threading, the runtime (ThreadSanitizer.cpp) | ||
set(SwiftCore_SWIFTC_SOURCE_DIR | ||
"${PROJECT_SOURCE_DIR}/../../" | ||
CACHE FILEPATH "Path to the root source directory of the Swift compiler") | ||
|
||
include(GNUInstallDirs) | ||
include(AvailabilityMacros) | ||
include(CompilerSettings) | ||
include(DefaultSettings) | ||
include(EmitSwiftInterface) | ||
include(PlatformInfo) | ||
include(gyb) | ||
|
||
defaulted_option(SwiftCore_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries") | ||
|
||
defaulted_option(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT "Enable Apple CrashReporter integration") | ||
defaulted_option(SwiftCore_ENABLE_OBJC_INTEROP "Enable runtime ObjC interop") | ||
defaulted_option(SwiftCore_ENABLE_TYPE_PRINTING "Enable printing type names") | ||
defaulted_option(SwiftCore_ENABLE_VECTOR_TYPES "Enable vector support") | ||
defaulted_option(SwiftCore_ENABLE_REFLECTION "Enable runtime support for mirrors and reflection support") | ||
defaulted_option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support") | ||
|
||
defaulted_option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime support") | ||
set(SwiftCore_BACKTRACER_PATH ${SwiftCore_BACKTRACER_PATH_default} CACHE STRING "Set a fixed path to the Swift backtracer") | ||
|
||
option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF) | ||
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF) | ||
|
||
set(SwiftCore_OBJECT_FORMAT "${SwiftCore_OBJECT_FORMAT_default}" CACHE STRING "Object format") | ||
|
||
add_compile_definitions( | ||
$<$<BOOL:${SwiftCore_ENABLE_OBJC_INTEROP}>:-DSWIFT_OBJC_INTEROP> | ||
$<$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>:-DSWIFT_LIBRARY_EVOLUTION> | ||
$<$<BOOL:${SwiftCore_ENABLE_CRASH_REPORTER_CLIENT}>:-DSWIFT_HAVE_CRASHREPORTERCLIENT> | ||
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION> | ||
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$<BOOL:${SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER}>> | ||
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=$<BOOL:${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS}>>) | ||
|
||
add_compile_options( $<$<AND:$<COMPILE_LANGUAGE:Swift>,$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>>:-enable-library-evolution>) | ||
|
||
include_directories(include) | ||
|
||
add_subdirectory(LLVMSupport) | ||
add_subdirectory(SwiftShims/swift/shims) | ||
add_subdirectory(Demangling) | ||
add_subdirectory(Threading) | ||
add_subdirectory(runtime) | ||
add_subdirectory(stubs) | ||
add_subdirectory(core) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# FIXME: Refactor demangling library so that we aren't pulling sources from | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we reference a swiftlang/swift issue here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll add it in a separate PR, but here's the issue: #77462 |
||
# the compiler. | ||
add_library(swiftDemangling OBJECT | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Context.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Demangler.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/ManglingUtils.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/NodePrinter.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Punycode.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Remangler.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/NodeDumper.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/Errors.cpp") | ||
target_compile_definitions(swiftDemangling PRIVATE swiftCore_EXPORTS | ||
$<$<BOOL:${SwiftCore_ENABLE_OBJC_INTEROP}>:-DSWIFT_SUPPORT_OLD_MANGLING> | ||
$<$<BOOL:${SwiftCore_ENABLE_TYPE_PRINTING}>:-DSWIFT_STDLIB_HAS_TYPE_PRINTING> | ||
$<$<BOOL:${SwiftCore_ENABLE_CRASH_REPORTER_CLIENT}>:-DSWIFT_HAVE_CRASHREPORTERCLIENT>) | ||
|
||
target_include_directories(swiftDemangling | ||
PRIVATE | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/include" | ||
"${PROJECT_BINARY_DIR}/include") | ||
|
||
target_link_libraries(swiftDemangling PRIVATE swiftShims) | ||
|
||
if(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT) | ||
# We could likely pull the copy from the runtime sources | ||
add_library(swiftDemanglingCR OBJECT | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/CrashReporter.cpp") | ||
target_link_libraries(swiftDemanglingCR PRIVATE swiftShims) | ||
endif() | ||
|
||
if(SwiftCore_ENABLE_OBJC_INTEROP) | ||
target_sources(swiftDemangling PRIVATE | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/OldDemangler.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/OldRemangler.cpp") | ||
endif() | ||
|
||
if(LINUX OR BSD) | ||
target_compile_options(swiftDemangling PRIVATE -fno-lto) | ||
endif() | ||
|
||
if(NOT BUILD_SHARED_LIBS) | ||
install(TARGETS swiftDemangling) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
add_library(swiftLLVMSupport OBJECT | ||
ErrorHandling.cpp | ||
Hashing.cpp | ||
MemAlloc.cpp | ||
SmallPtrSet.cpp | ||
SmallVector.cpp | ||
StringRef.cpp) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Swift shim header files | ||
install(FILES | ||
AssertionReporting.h | ||
CoreFoundationShims.h | ||
EmbeddedShims.h | ||
FoundationShims.h | ||
GlobalObjects.h | ||
HeapObject.h | ||
KeyPath.h | ||
LibcOverlayShims.h | ||
LibcShims.h | ||
MetadataSections.h | ||
Random.h | ||
RefCount.h | ||
Reflection.h | ||
RuntimeShims.h | ||
RuntimeStubs.h | ||
SwiftStdbool.h | ||
SwiftStddef.h | ||
SwiftStdint.h | ||
System.h | ||
Target.h | ||
ThreadLocalStorage.h | ||
UnicodeData.h | ||
Visibility.h | ||
_SwiftConcurrency.h | ||
_SwiftDistributed.h | ||
_SynchronizationShims.h | ||
module.modulemap | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/shims") | ||
|
||
add_library(swiftShims INTERFACE) | ||
target_include_directories(swiftShims INTERFACE | ||
$<$<COMPILE_LANGUAGE:C,CXX>:${CMAKE_CURRENT_SOURCE_DIR}/../../> | ||
$<$<COMPILE_LANGUAGE:Swift>:${CMAKE_CURRENT_SOURCE_DIR}>) | ||
target_compile_options(swiftShims INTERFACE | ||
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap>") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# TODO: I think we can build the one that actually matters based on the | ||
# platform we're building, rather than relying just on macro definitions | ||
# and linking empty objects. | ||
compnerd marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# https://github.com/swiftlang/swift/issues/77435 | ||
add_library(swiftThreading OBJECT | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/C11.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/Linux.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/Pthreads.cpp" | ||
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Threading/Win32.cpp") | ||
target_link_libraries(swiftThreading PRIVATE swiftShims) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
file(STRINGS "${SwiftCore_SWIFTC_SOURCE_DIR}/utils/availability-macros.def" availability_defs) | ||
list(FILTER availability_defs EXCLUDE REGEX "^\\s*(#.*)?$") | ||
foreach(def ${availability_defs}) | ||
add_compile_options("$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">") | ||
endforeach() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# This file contains workarounds for dealing with bugs between CMake and the | ||
# Swift compiler. | ||
|
||
# This is a workaround to avoid crashing the Swift compiler while typechecking | ||
# swiftCore. The Swift compiler must be run num-threads=0 with WMO in all build | ||
# configurations. | ||
# These must be set in CMake _before_ the Swift language is enabled. | ||
# This is manipulating undocumented CMake-internal variables that may change | ||
# behavior at any time and should not be relied on. | ||
# Otherwise CMake will generate the build graph incorrectly for this setup. | ||
# Ideally this file should not need to exist. | ||
|
||
set(CMAKE_Swift_NUM_THREADS 0) | ||
if(POLICY CMP0157) | ||
set(CMAKE_Swift_COMPILE_OBJECT "<CMAKE_Swift_COMPILER> -num-threads ${CMAKE_Swift_NUM_THREADS} -c <DEFINES> <FLAGS> <INCLUDES> <SOURCE>") | ||
|
||
set(CMAKE_Swift_COMPILATION_MODE wholemodule) | ||
|
||
if(NOT SwiftStdlib_NUM_LINK_JOBS MATCHES "^[0-9]+$") | ||
cmake_host_system_information(RESULT SwiftStdlib_NUM_LINK_JOBS QUERY NUMBER_OF_LOGICAL_CORES) | ||
endif() | ||
|
||
set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -num-threads ${SwiftStdlib_NUM_LINK_JOBS} -emit-executable -o <TARGET> <FLAGS> <OBJECTS> <LINK_FLAGS> <LINK_LIBRARIES>") | ||
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>") | ||
else() | ||
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>") | ||
|
||
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>") | ||
|
||
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>") | ||
|
||
set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>") | ||
set(CMAKE_Swift_ARCHIVE_FINISH "") | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
include(CheckSourceCompiles) | ||
include(CheckCompilerFlag) | ||
|
||
# Use C+17 | ||
set(SwiftCore_MIN_CXX_STANDARD 17) | ||
# Unset CMAKE_CXX_STANDARD if it's too low and in the CMakeCache.txt | ||
if($CACHE{CMAKE_CXX_STANDARD} AND $CACHE{CMAKE_CXX_STANDARD} LESS ${SwiftCore_MIN_CXX_STANDARD}) | ||
message(WARNING "Resetting cache value for CMAKE_CXX_STANDARD to ${SwiftCore_MIN_CXX_STANDARD}") | ||
unset(CMAKE_CXX_STANDARD CACHE) | ||
endif() | ||
|
||
# Allow manually specified CMAKE_CXX_STANDARD if it's greater than the minimum | ||
# required C++ version | ||
if(DEFINED CMAKE_CXX_STANDARD AND CMAKE_CXX_STANDARD LESS ${SwiftCore_MIN_CXX_STANDARD}) | ||
message(FATAL_ERROR "Requested CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} which is less than the minimum C++ standard ${SwiftCore_MIN_CXX_STANDARD}") | ||
endif() | ||
|
||
set(CMAKE_CXX_STANDARD ${SwiftCore_MIN_CXX_STANDARD} CACHE STRING "C++ standard to conform to") | ||
set(CMAKE_CXX_STANDARD_REQUIRED YES) | ||
set(CMAKE_CXX_EXTENSIONS NO) | ||
|
||
check_source_compiles(CXX | ||
"#if !(__has_attribute(swiftcall) && \ | ||
__has_attribute(swift_context) && \ | ||
__has_attribute(swift_error_result) && \ | ||
__has_attribute(swift_indirect_result)) | ||
#error CXX compiler must support Swift calling conventions | ||
#endif | ||
int main(void) { return 0; }" | ||
HAVE_SWIFTCALL) | ||
|
||
if(NOT HAVE_SWIFTCALL) | ||
message(SEND_ERROR "CXX Compiler must support Swift calling conventions") | ||
endif() | ||
|
||
check_source_compiles(CXX | ||
"#if !(__has_attribute(swiftasynccall) && \ | ||
__has_attribute(swift_async_context)) | ||
#error CXX compiler must support Swift async calling conventions | ||
#endif | ||
int main(void) { return 0; }" | ||
HAVE_SWIFT_ASYNC_CALL) | ||
|
||
if(NOT HAVE_SWIFT_ASYNC_CALL) | ||
message(SEND_ERROR "CXX Compiler must support Swift async calling conventions") | ||
endif() | ||
|
||
check_compiler_flag(Swift "-color-diagnostics" HAVE_SWIFT_COLOR_DIAGNOSTICS) | ||
if(HAVE_SWIFT_COLOR_DIAGNOSTICS) | ||
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-color-diagnostics>) | ||
endif() | ||
|
||
check_compiler_flag(Swift "-diagnostic-style swift" HAVE_SWIFT_DIAGNOSTIC_STYLE) | ||
if(HAVE_SWIFT_DIAGNOSTIC_STYLE) | ||
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-diagnostic-style$<SEMICOLON>swift>) | ||
endif() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This file is designed to setup reasonable defaults for the various settings so | ||
# that configuring a build for a given platform is likely to build | ||
# out-of-the-box without customization. This does not mean that it is the only | ||
# way that will work, or that it represents a shipping configuration. | ||
|
||
set(SwiftCore_ENABLE_BACKTRACING_default OFF) # TODO: enable this by default | ||
set(SwiftCore_ENABLE_COMMANDLINE_SUPPORT_default OFF) # TODO: enable this by default | ||
|
||
set(SwiftCore_ENABLE_TYPE_PRINTING_default ON) | ||
|
||
set(SwiftCore_BACKTRACER_PATH_default "") | ||
|
||
macro(defaulted_option variable helptext) | ||
if(NOT DEFINED ${variable}_default) | ||
set(${variable}_default OFF) | ||
endif() | ||
option(${variable} ${helptext} ${${variable}_default}) | ||
endmacro() | ||
|
||
if(APPLE) | ||
set(SwiftCore_ENABLE_LIBRARY_EVOLUTION_default ON) | ||
set(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT_default ON) | ||
set(SwiftCore_ENABLE_OBJC_INTEROP_default ON) | ||
set(SwiftCore_ENABLE_REFLECTION_default ON) | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "WASM") | ||
set(SwiftCore_OBJECT_FORMAT_default "elf") | ||
elseif(LINUX) | ||
set(SwiftCore_OBJECT_FORMAT_default "elf") | ||
elseif(WIN32) | ||
set(SwiftCore_OBJECT_FORMAT_default "coff") | ||
endif() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set it to 1 when enabled and un-set it when disabled? That should work for both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, C/C++ defines it so that if a
-DFOO
is passed without a value, it's given the value of1
, and#if FOO
will see undefined an0
the same way. We might be able to get away with just setting it. I'll have to compare the symbol lists though.