Add swiftCore library

This patch hooks up the swiftCore library build and gets it installing.
This means that we have library evolution hooked up and vector types.

Building it dynamically found that we had duplicate symbols, so fixed
the swiftDemanglingCR library.

Needed to hook up the availability macros.

The flag configuration is for macOS, so we'll need to go through and
figure out what it should look like for the other platforms too.
This commit is contained in:
Evan Wilde
2024-10-16 17:14:23 -07:00
parent f3b5fcdc15
commit 03ba118bf3
11 changed files with 479 additions and 5 deletions

2
.gitignore vendored
View File

@@ -93,3 +93,5 @@ Runtimes/**/*.gyb
Runtimes/**/*.apinotes Runtimes/**/*.apinotes
Runtimes/**/*.yaml Runtimes/**/*.yaml
Runtimes/**/*.inc Runtimes/**/*.inc
Runtimes/**/*.json
Runtimes/**/*.modulemap

View File

@@ -32,6 +32,7 @@
cmake_minimum_required(VERSION 3.26...3.29) cmake_minimum_required(VERSION 3.26...3.29)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
include(CMakeWorkarounds)
project(SwiftCore LANGUAGES C CXX Swift VERSION 6.1) 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 # The Swift standard library is not intended for use as a sub-library as part of
@@ -46,19 +47,27 @@ set(SwiftCore_SWIFTC_SOURCE_DIR
"${PROJECT_SOURCE_DIR}/../../" "${PROJECT_SOURCE_DIR}/../../"
CACHE FILEPATH "Path to the root source directory of the Swift compiler") CACHE FILEPATH "Path to the root source directory of the Swift compiler")
include(GNUInstallDirs)
include(AvailabilityMacros)
include(CompilerSettings) include(CompilerSettings)
include(DefaultSettings) include(DefaultSettings)
include(EmitSwiftInterface)
include(PlatformInfo) include(PlatformInfo)
include(gyb) include(gyb)
option(SwiftCore_ENABLE_LIBRARY_EVOLUTION "Generate ABI resilient runtime libraries" OFF)
option(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT "Enable Apple CrashReporter integration" OFF) option(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT "Enable Apple CrashReporter integration" OFF)
option(SwiftCore_ENABLE_OBJC_INTEROP "Enable runtime ObjC interop" OFF) option(SwiftCore_ENABLE_OBJC_INTEROP "Enable runtime ObjC interop" OFF)
option(SwiftCore_ENABLE_TYPE_PRINTING "Enable printing type names" OFF) option(SwiftCore_ENABLE_TYPE_PRINTING "Enable printing type names" OFF)
option(SwiftCore_ENABLE_VECTOR_TYPES "Enable vector support" OFF)
option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" ${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS_default}) option(SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS "" ${SwiftCore_ENABLE_CLOBBER_FREED_OBJECTS_default})
option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" ${SwiftCore_ENABLE_RIUNTIME_LEAK_CHECKER_default}) option(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER "" ${SwiftCore_ENABLE_RIUNTIME_LEAK_CHECKER_default})
option(SwiftCore_ENABLE_REFLECTION "" OFF) option(SwiftCore_ENABLE_REFLECTION "" OFF)
option(SwiftCore_ENABLE_COMMANDLINE_SUPPORT "Enable command line argument support" OFF)
option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime support" OFF) option(SwiftCore_ENABLE_BACKTRACING "Enable backtracing runtime support" OFF)
set(SwiftCore_BACKTRACER_PATH "" CACHE STRING "Set a fixed path to the Swift backtracer") set(SwiftCore_BACKTRACER_PATH "" CACHE STRING "Set a fixed path to the Swift backtracer")
@@ -69,6 +78,8 @@ add_compile_definitions(
$<$<COMPILE_LANGUAGE:C,CXX>:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$<BOOL:${SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER}>> $<$<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}>>) $<$<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) include_directories(include)
add_subdirectory(LLVMSupport) add_subdirectory(LLVMSupport)
@@ -77,3 +88,4 @@ add_subdirectory(Demangling)
add_subdirectory(Threading) add_subdirectory(Threading)
add_subdirectory(runtime) add_subdirectory(runtime)
add_subdirectory(stubs) add_subdirectory(stubs)
add_subdirectory(core)

View File

@@ -19,10 +19,13 @@ target_include_directories(swiftDemangling
"${SwiftCore_SWIFTC_SOURCE_DIR}/include" "${SwiftCore_SWIFTC_SOURCE_DIR}/include"
"${PROJECT_BINARY_DIR}/include") "${PROJECT_BINARY_DIR}/include")
target_link_libraries(swiftDemangling PRIVATE swiftShims)
if(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT) if(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT)
target_compile_definitions(swiftDemangling PRIVATE SWIFT_HAVE_CRASHREPORTERCLIENT) # We could likely pull the copy from the runtime sources
target_sources(swiftDemangling PRIVATE add_library(swiftDemanglingCR OBJECT
"${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/CrashReporter.cpp") "${SwiftCore_SWIFTC_SOURCE_DIR}/lib/Demangling/CrashReporter.cpp")
target_link_libraries(swiftDemanglingCR PRIVATE swiftShims)
endif() endif()
if(SwiftCore_ENABLE_OBJC_INTEROP) if(SwiftCore_ENABLE_OBJC_INTEROP)

View File

@@ -34,4 +34,4 @@ target_include_directories(swiftShims INTERFACE
$<$<COMPILE_LANGUAGE:C,CXX>:${CMAKE_CURRENT_SOURCE_DIR}/../../> $<$<COMPILE_LANGUAGE:C,CXX>:${CMAKE_CURRENT_SOURCE_DIR}/../../>
$<$<COMPILE_LANGUAGE:Swift>:${CMAKE_CURRENT_SOURCE_DIR}>) $<$<COMPILE_LANGUAGE:Swift>:${CMAKE_CURRENT_SOURCE_DIR}>)
target_compile_options(swiftShims INTERFACE target_compile_options(swiftShims INTERFACE
$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc$<SEMICOLON>-fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap>) "$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap>")

View File

@@ -0,0 +1,5 @@
file(STRINGS "${PROJECT_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()

View File

@@ -0,0 +1,31 @@
# This file contains workarounds for dealing with bugs between CMake and the
# Swift compiler.
# FIXME: This is a workaround for the broken Swift compiler that cannot
# typecheck the Swift stdlib without crashing. <ADD RADAR HERE>.
# This is manipulating undocumented CMake-internal variables that may
# change behavior at any time and should not be relied on.
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_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
else()
set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -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> -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> -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 "")
add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-wmo>)
endif()

View File

@@ -1,3 +1,6 @@
include(CheckSourceCompiles)
include(CheckCompilerFlag)
# Use C+17 # Use C+17
set(SwiftCore_MIN_CXX_STANDARD 17) set(SwiftCore_MIN_CXX_STANDARD 17)
# Unset CMAKE_CXX_STANDARD if it's too low and in the CMakeCache.txt # Unset CMAKE_CXX_STANDARD if it's too low and in the CMakeCache.txt
@@ -15,3 +18,39 @@ endif()
set(CMAKE_CXX_STANDARD ${SwiftCore_MIN_CXX_STANDARD} CACHE STRING "C++ standard to conform to") set(CMAKE_CXX_STANDARD ${SwiftCore_MIN_CXX_STANDARD} CACHE STRING "C++ standard to conform to")
set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO) 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()

View File

@@ -0,0 +1,30 @@
# Generate and install swift interface files
# TODO: CMake should learn how to model library evolution and generate this
# stuff automatically.
# Generate a swift interface file for the target if library evolution is enabled
function(emit_swift_interface target)
if(SwiftCore_ENABLE_LIBRARY_EVOLUTION)
target_compile_options(${target} PRIVATE
$<$<COMPILE_LANGUAGE:Swift>:-emit-module-interface-path$<SEMICOLON>${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftinterface>
$<$<COMPILE_LANGUAGE:Swift>:-emit-private-module-interface-path$<SEMICOLON>${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.private.swiftinterface>
$<$<COMPILE_LANGUAGE:Swift>:-library-level$<SEMICOLON>api>
$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend$<SEMICOLON>-require-explicit-availability=ignore>)
endif()
endfunction()
# Install the generated swift interface file for the target if library evolution
# is enabled.
function(install_swift_interface target)
if(SwiftCore_ENABLE_LIBRARY_EVOLUTION)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftinterface"
RENAME "${SwiftCore_MODULE_TRIPLE}.swiftinterface"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.private.swiftinterface"
RENAME "${SwiftCore_MODULE_TRIPLE}.private.swiftinterface"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$<TARGET_PROPERTY:${target},Swift_MODULE_NAME>.swiftmodule")
endif()
endfunction()

View File

@@ -0,0 +1,341 @@
# TODO: Hook up the CommandLine support sources
gyb_expand(AtomicInt.swift.gyb AtomicInt.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(FloatingPointParsing.swift.gyb FloatingPointParsing.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(FloatingPointTypes.swift.gyb FloatingPointTypes.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(IntegerTypes.swift.gyb IntegerTypes.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(LegacyInt128.swift.gyb LegacyInt128.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(UnsafeBufferPointer.swift.gyb UnsafeBufferPointer.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(UnsafeRawBufferPointer.swift.gyb UnsafeRawBufferPointer.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(Tuple.swift.gyb Tuple.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
# These sources are not strictly sorted alphabetically because the compiler
# crashes if they are.
add_library(swiftCore
Algorithm.swift
ArrayBody.swift
ArrayBuffer.swift
ArrayBufferProtocol.swift
ArrayCast.swift
Array.swift
ArrayShared.swift
ArraySlice.swift
ArrayType.swift
ASCII.swift
Assert.swift
AssertCommon.swift
BidirectionalCollection.swift
Bitset.swift
Bool.swift
BridgeObjectiveC.swift
BridgeStorage.swift
BridgingBuffer.swift
Builtin.swift
BuiltinMath.swift
Character.swift
CocoaArray.swift
Codable.swift
Collection.swift
CollectionAlgorithms.swift
Comparable.swift
CompilerProtocols.swift
Sendable.swift
ContiguousArray.swift
ContiguouslyStored.swift
ClosedRange.swift
ContiguousArrayBuffer.swift
CString.swift
CTypes.swift
DebuggerSupport.swift
Dictionary.swift
DictionaryBridging.swift
DictionaryBuilder.swift
DictionaryCasting.swift
DictionaryStorage.swift
DictionaryVariant.swift
DiscontiguousSlice.swift
DropWhile.swift
Dump.swift
EmptyCollection.swift
Equatable.swift
ErrorType.swift
ExistentialCollection.swift
Filter.swift
FlatMap.swift
Flatten.swift
FloatingPoint.swift
Hashable.swift
AnyHashable.swift # ORDER DEPENDENCY
Hasher.swift
Hashing.swift
HashTable.swift
Identifiable.swift
Indices.swift
InputStream.swift
IntegerParsing.swift
Integers.swift
Join.swift
KeyPath.swift
KeyValuePairs.swift
LazyCollection.swift
LazySequence.swift
LegacyABI.swift
LifetimeManager.swift
Macros.swift
ManagedBuffer.swift
Map.swift
MemoryLayout.swift
UnicodeScalar.swift # ORDER DEPENDENCY: Must precede Mirrors.swift
Mirrors.swift
Misc.swift
MutableCollection.swift
NativeDictionary.swift
NativeSet.swift
NewtypeWrapper.swift
NFC.swift
NFD.swift
ObjectIdentifier.swift
Optional.swift
OptionSet.swift
OutputStream.swift
Pointer.swift
Policy.swift
PrefixWhile.swift
Prespecialize.swift
Print.swift
PtrAuth.swift
Random.swift
RandomAccessCollection.swift
Range.swift
RangeReplaceableCollection.swift
RangeSet.swift
RangeSetRanges.swift
ReflectionMirror.swift
Repeat.swift
REPL.swift
Result.swift
Reverse.swift
Runtime.swift
RuntimeFunctionCounters.swift
SipHash.swift
Sequence.swift
SequenceAlgorithms.swift
Set.swift
SetAlgebra.swift
SetAnyHashableExtensions.swift
SetBridging.swift
SetBuilder.swift
SetCasting.swift
SetStorage.swift
SetVariant.swift
ShadowProtocols.swift
Shims.swift
Slice.swift
SmallString.swift
Sort.swift
StaticString.swift
StaticPrint.swift
Stride.swift
StringHashable.swift # ORDER DEPENDENCY: Must precede String.swift
String.swift
StringBreadcrumbs.swift
StringBridge.swift
StringCharacterView.swift
StringComparable.swift
StringComparison.swift
StringCreate.swift
StringGuts.swift
StringGutsSlice.swift
StringGutsRangeReplaceable.swift
StringObject.swift
StringProtocol.swift
StringIndex.swift
StringIndexConversions.swift
StringIndexValidation.swift
StringInterpolation.swift
StringLegacy.swift
StringNormalization.swift
StringRangeReplaceableCollection.swift
StringStorage.swift
StringStorageBridge.swift
StringSwitch.swift
StringTesting.swift
StringUnicodeScalarView.swift
StringUTF16View.swift
StringUTF8View.swift
StringUTF8Validation.swift
StringWordBreaking.swift
Substring.swift
SwiftNativeNSArray.swift
TemporaryAllocation.swift
ThreadLocalStorage.swift
UIntBuffer.swift
UnavailableStringAPIs.swift
UnicodeData.swift
UnicodeEncoding.swift
UnicodeBreakProperty.swift
UnicodeHelpers.swift
UnicodeParser.swift
UnicodeScalarProperties.swift
CharacterProperties.swift # ORDER DEPENDENCY: UnicodeScalarProperties.swift
UnicodeSPI.swift
Unmanaged.swift
UnmanagedOpaqueString.swift
UnmanagedString.swift
UnsafePointer.swift
UnsafeRawPointer.swift
UTFEncoding.swift
UTF8.swift
UTF16.swift
UTF32.swift
Unicode.swift # ORDER DEPENDENCY: must follow new unicode support
StringGraphemeBreaking.swift # ORDER DEPENDENCY: Must follow UTF16.swift
ValidUTF8Buffer.swift
WriteBackMutableSlice.swift
MigrationSupport.swift
Availability.swift
CollectionDifference.swift
CollectionOfOne.swift
Diffing.swift
Duration.swift
DurationProtocol.swift
FloatingPointRandom.swift
Instant.swift
Int128.swift
Mirror.swift
PlaygroundDisplay.swift
CommandLine.swift
SliceBuffer.swift
StaticBigInt.swift
UInt128.swift
UnfoldSequence.swift
UnsafeBufferPointerSlice.swift
VarArgs.swift
Zip.swift
"${PROJECT_SOURCE_DIR}/linker-support/magic-symbols-for-install-name.c"
"${CMAKE_CURRENT_BINARY_DIR}/AtomicInt.swift"
"${CMAKE_CURRENT_BINARY_DIR}/FloatingPointParsing.swift"
"${CMAKE_CURRENT_BINARY_DIR}/FloatingPointTypes.swift"
"${CMAKE_CURRENT_BINARY_DIR}/IntegerTypes.swift"
"${CMAKE_CURRENT_BINARY_DIR}/LegacyInt128.swift"
"${CMAKE_CURRENT_BINARY_DIR}/UnsafeBufferPointer.swift"
"${CMAKE_CURRENT_BINARY_DIR}/UnsafeRawBufferPointer.swift"
"${CMAKE_CURRENT_BINARY_DIR}/Tuple.swift")
set_target_properties(swiftCore PROPERTIES Swift_MODULE_NAME Swift)
if(SwiftCore_ENABLE_COMMANDLINE)
# TODO: Pull in the CommandLine C++ files too
target_sources(swiftCore PRIVATE CommandLine.swift)
endif()
if(SwiftCore_ENABLE_VECTOR_TYPES)
gyb_expand(SIMDConcreteOperations.swift.gyb
SIMDConcreteOperations.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
gyb_expand(SIMDVectorTypes.swift.gyb
SIMDVectorTypes.swift
FLAGS "-DCMAKE_SIZEOF_VOID_P=${SwiftCore_SIZEOF_POINTER}")
target_sources(swiftCore PRIVATE
SIMDVector.swift
"${CMAKE_CURRENT_BINARY_DIR}/SIMDConcreteOperations.swift"
"${CMAKE_CURRENT_BINARY_DIR}/SIMDVectorTypes.swift")
endif()
target_compile_options(swiftCore PRIVATE
$<$<COMPILE_LANGUAGE:Swift>:-parse-stdlib>
$<$<COMPILE_LANGUAGE:Swift>:-nostdimport>
$<$<COMPILE_LANGUAGE:Swift>:-explicit-module-build>
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NoncopyableGenerics2>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SuppressedAssociatedTypes>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature SE427NoInferenceOnExtension>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature AllowUnsafeAttribute>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature NonescapableTypes>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature MemberImportVisibility>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature TypedThrows>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature Macros>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature FreestandingMacros>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature BitwiseCopyable>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature Extern>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-enable-experimental-feature DebugDescriptionMacro>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xcc -DswiftCore_EXPORTS>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -group-info-path -Xfrontend ${CMAKE_CURRENT_SOURCE_DIR}/GroupInfo.json>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-experimental-concise-pound-file>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-autolinking-runtime-compatibility-concurrency>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-objc-attr-requires-foundation-module>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -require-explicit-availability=ignore>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enforce-exclusivity=unchecked>"
"$<$<COMPILE_LANGUAGE:Swift>:-disable-autolinking-runtime-compatibility-dynamic-replacements>"
"$<$<COMPILE_LANGUAGE:Swift>:-no-link-objc-runtime>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-library-level api>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-ossa-modules>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -target-min-inlining-version -Xfrontend min>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -enable-lexical-lifetimes=false>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -empty-abi-descriptor>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-concurrency-module-import>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-backtracing-module-import>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -disable-implicit-string-processing-module-import>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xfrontend -prespecialize-generic-metadata>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-runtime-compatibility-version none>"
"$<$<COMPILE_LANGUAGE:Swift>:-warn-implicit-overrides>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xllvm -sil-inline-generics>"
"$<$<COMPILE_LANGUAGE:Swift>:SHELL:-Xllvm -sil-partial-specialization>")
target_compile_definitions(swiftCore PRIVATE
$<$<BOOL:${SwiftCore_ENABLE_REFLECTION}>:-DSWIFT_ENABLE_REFLECTION>)
target_link_libraries(swiftCore PRIVATE swiftShims)
target_link_libraries(swiftCore
PRIVATE
swiftRuntime
swiftLLVMSupport
swiftDemangling
swiftStdlibStubs
swiftThreading)
if(NOT POLICY CMP0157)
target_compile_options(swiftCore PRIVATE
$<TARGET_OBJECTS:swiftRuntime>
$<TARGET_OBJECTS:swiftLLVMSupport>
$<TARGET_OBJECTS:swiftDemangling>
$<TARGET_OBJECTS:swiftStdlibStubs>
$<TARGET_OBJECTS:swiftThreading>)
endif()
if(WIN32)
target_link_libraries(swiftCore PRIVATE shell32 DbgHelp Synchronization)
elseif(NOT APPLE AND NOT LINUX AND UNIX)
find_library(EXECINFO_LIBRARY execinfo)
target_link_libraries(swiftCore PRIVATE "${EXECINFO_LIBRARY}")
endif()
install(TARGETS swiftCore)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/Swift.swiftmodule"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/Swift.swiftmodule"
RENAME "${SwiftCore_MODULE_TRIPLE}.swiftmodule")
emit_swift_interface(swiftCore)
install_swift_interface(swiftCore)
# TODO: Embedded SwiftCore builds
# FIXME: Embedded builds should be separate CMake invocations because they are
# building for a different environment. I'm not sure how CMake will
# handle their build model though, so we'll continue to cram them in here
# as they are for now, but should eventually tie into the rest of the
# build graph normally.

View File

@@ -67,6 +67,11 @@ add_library(swiftRuntime OBJECT
AccessibleFunction.cpp AccessibleFunction.cpp
Win32.cpp) Win32.cpp)
if(SwiftCore_ENABLE_RUNTIME_LEAK_CHECKER)
target_sources(swiftRuntime PRIVATE
Leaks.mm)
endif()
# TODO: Probably worth considering putting half of these in a RuntimeConfig.h.in # TODO: Probably worth considering putting half of these in a RuntimeConfig.h.in
# file rather than pushing them through macro flags. # file rather than pushing them through macro flags.
target_compile_definitions(swiftRuntime target_compile_definitions(swiftRuntime

View File

@@ -29,7 +29,9 @@ function(copy_library_sources name from_prefix to_prefix)
"${StdlibSources}/${from_prefix}/${name}/*.gyb" "${StdlibSources}/${from_prefix}/${name}/*.gyb"
"${StdlibSources}/${from_prefix}/${name}/*.apinotes" "${StdlibSources}/${from_prefix}/${name}/*.apinotes"
"${StdlibSources}/${from_prefix}/${name}/*.yaml" "${StdlibSources}/${from_prefix}/${name}/*.yaml"
"${StdlibSources}/${from_prefix}/${name}/*.inc") "${StdlibSources}/${from_prefix}/${name}/*.inc"
"${StdlibSources}/${from_prefix}/${name}/*.modulemap"
"${StdlibSources}/${from_prefix}/${name}/*.json")
foreach(file ${filenames}) foreach(file ${filenames})
# Get and create the directory # Get and create the directory
@@ -52,12 +54,16 @@ endfunction()
# Copy shared core headers # Copy shared core headers
copy_library_sources(include "" "Core") copy_library_sources(include "" "Core")
# Copy magic linker symbols
copy_library_sources("linker-support" "" "Core")
set(CoreLibs set(CoreLibs
LLVMSupport LLVMSupport
SwiftShims SwiftShims
runtime runtime
CompatibilityOverride CompatibilityOverride
stubs) stubs
core)
# Add these as we get them building # Add these as we get them building
# core # core