Skip to content

Commit

Permalink
Merge pull request #77566 from etcwilde/ewilde/stdlib-rebuild-all-the…
Browse files Browse the repository at this point in the history
…-defines

[CMake] Cleaning up macOS symbol list
  • Loading branch information
etcwilde authored Nov 13, 2024
2 parents 391277c + d87a293 commit af58e6e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
25 changes: 25 additions & 0 deletions Runtimes/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@
# Catalyst Support
# -- Will need shadow invocations to generate swiftmodules for Swift parts
# Install *.abi.json, swiftdoc, and swiftsourceinfo
# Pointer bounds (SWIFT_ENABLE_EXPERIMENTAL_POINTER_BOUNDS)

cmake_minimum_required(VERSION 3.26...3.29)

set(CMAKE_C_VISIBILITY_PRESET "hidden")
set(CMAKE_CXX_VISIBILITY_PRESET "hidden")

set(SwiftCore_CMAKE_MODULES_DIR "${CMAKE_SOURCE_DIR}/cmake/modules")
list(APPEND CMAKE_MODULE_PATH ${SwiftCore_CMAKE_MODULES_DIR})

include(CMakeWorkarounds)
project(SwiftCore LANGUAGES C CXX Swift VERSION 6.1)

Expand Down Expand Up @@ -74,22 +79,42 @@ 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_RUNTIME_FUNCTION_COUNTERS "Enable runtime function counter support")
defaulted_option(SwiftCore_ENABLE_STDIN "Enable functions that use stdin support")
defaulted_option(SwiftCore_ENABLE_ENVIRONMENT "Enable environment variable support")
defaulted_option(SwiftCore_ENABLE_OVERRIDABLE_RETAIN_RELEASE "Enable override hooks for retain/release")
defaulted_option(SwiftCore_ENABLE_MALLOC_TYPE "Enable malloc type information")
defaulted_option(SwiftCore_ENABLE_RUNTIME_OS_VERSIONING "Enable runtime OS version detection")
defaulted_option(SwiftCore_ENABLE_STATIC_PRINT "Disable full print")
defaulted_option(SwiftCore_ENABLE_UNICODE_DATA "Embed Unicode info in Swift Core")
defaulted_option(SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS "Resolve absolute function pointer as identity")
defaulted_option(SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT "Add symbols for runtime backdeployment")

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

option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" OFF)
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" OFF)
option(SwiftCore_ENABLE_INTERNAL_CHECKS "" OFF)

defaulted_set(SwiftCore_OBJECT_FORMAT STRING "Object format: ELF COFF")

# TODO: Most of these should be attached to specific targets rather than applied
# globally. They can be applied as part of the library interface if they
# affect the behavior of libraries that build against a given target.
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_VECTOR_TYPES}>:-DSWIFT_STDLIB_ENABLE_VECTOR_TYPES>
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>
$<$<BOOL:${SwiftCore_ENABLE_RUNTIME_FUNCTION_COUNTERS}>:-DSWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS>
$<$<BOOL:${SwiftCore_ENABLE_STDIN}>:-DSWIFT_STDLIB_HAS_STDIN> # core + stubs
$<$<BOOL:${SwiftCore_ENABLE_RUNTIME_OS_VERSIONING}>:-DSWIFT_RUNTIME_OS_VERSIONING> # core + stubs
$<$<BOOL:${SwiftCore_ENABLE_INTERNAL_CHECKS}>:-DINTERNAL_CHECKS_ENABLED> # core
$<$<BOOL:${SwiftCore_ENABLE_STATIC_PRINT}>:-DSWIFT_STDLIB_STATIC_PRINT> # core + concurrency
$<$<BOOL:${SwiftCore_ENABLE_UNICODE_DATA}>:-DSWIFT_STDLIB_ENABLE_UNICODE_DATA> # Stubs
$<$<BOOL:${SwiftCore_ENABLE_ENVIRONMENT}>:-DSWIFT_STDLIB_HAS_ENVIRON> # Concurrency, runtime, shims, platform overlay
$<$<BOOL:${SwiftCore_ENABLE_BACKDEPLOYMENT_SUPPORT}>:-DSWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT> # Concurrency, Compatibility override, magic symbols
$<$<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}>>)

Expand Down
3 changes: 3 additions & 0 deletions Runtimes/Core/cmake/modules/DefaultSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
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_STDIN_default ON)
set(SwiftCore_ENABLE_TYPE_PRINTING_default ON)

set(SwiftCore_BACKTRACER_PATH_default "")
Expand Down Expand Up @@ -36,6 +37,8 @@ if(APPLE)
set(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT_default ON)
set(SwiftCore_ENABLE_OBJC_INTEROP_default ON)
set(SwiftCore_ENABLE_REFLECTION_default ON)
set(SwiftCore_ENABLE_RUNTIME_OS_VERSIONING ON)
set(SwiftCore_ENABLE_OVERRIDABLE_RETAIN_RELEASE ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL "WASM")
set(SwiftCore_OBJECT_FORMAT_default "elf")
elseif(LINUX OR ANDROID OR BSD)
Expand Down
4 changes: 3 additions & 1 deletion Runtimes/Core/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ target_compile_options(swiftCore PRIVATE
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xllvm -sil-partial-specialization>")

target_compile_definitions(swiftCore PRIVATE
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>)
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>
$<$<BOOL:${SwiftCore_ENABLE_COMPACT_ABSOLUTE_FUNCTION_POINTERS}>:-DSWIFT_COMPACT_ABSOLUTE_FUNCTION_POINTER>
$<$<COMPILE_LANGUAGE:C,CX>:-DSWIFT_TARGET_LIBRARY_NAME=swiftCore>)
target_compile_options(swiftCore PRIVATE
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -DswiftCore_EXPORTS>")

Expand Down
2 changes: 2 additions & 0 deletions Runtimes/Core/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ target_compile_definitions(swiftRuntime
-DSWIFT_RUNTIME
-DSWIFT_TARGET_LIBRARY_NAME=swiftRuntime
$<$<BOOL:${SwiftCore_ENABLE_BACKTRACING}>:-DSWIFT_ENABLE_BACKTRACING>
$<$<BOOL:${SwiftCore_ENABLE_OVERRIDABLE_RETAIN_RELEASE}>:-DSWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE>
$<$<BOOL:${SwiftCore_ENABLE_MALLOC_TYPE}>:-DSWIFT_STDLIB_HAS_MALLOC_TYPE>
$<$<BOOL:${SwiftCore_BACKTRACER_PATH}>:-DSWIFT_RUNTIME_FIXED_BACKTRACER_PATH="${SwiftCore_BACKTRACER_PATH}">)

target_include_directories(swiftRuntime PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/runtime/HeapObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ WeakReference *swift::swift_weakTakeAssign(WeakReference *dest,
return dest;
}

#ifndef NDEBUG
#ifndef NDEBUG // "not not debug", or "debug-able configurations"

/// Returns true if the "immutable" flag is set on \p object.
///
Expand Down

0 comments on commit af58e6e

Please sign in to comment.