From 03ba118bf3795fe790e406bf0650abc07d64ac57 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Wed, 16 Oct 2024 17:14:23 -0700 Subject: [PATCH] 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. --- .gitignore | 2 + Runtimes/Core/CMakeLists.txt | 12 + Runtimes/Core/Demangling/CMakeLists.txt | 7 +- .../SwiftShims/swift/shims/CMakeLists.txt | 2 +- .../cmake/modules/AvailabilityMacros.cmake | 5 + .../Core/cmake/modules/CMakeWorkarounds.cmake | 31 ++ .../Core/cmake/modules/CompilerSettings.cmake | 39 ++ .../cmake/modules/EmitSwiftInterface.cmake | 30 ++ Runtimes/Core/core/CMakeLists.txt | 341 ++++++++++++++++++ Runtimes/Core/runtime/CMakeLists.txt | 5 + Runtimes/Resync.cmake | 10 +- 11 files changed, 479 insertions(+), 5 deletions(-) create mode 100644 Runtimes/Core/cmake/modules/AvailabilityMacros.cmake create mode 100644 Runtimes/Core/cmake/modules/CMakeWorkarounds.cmake create mode 100644 Runtimes/Core/cmake/modules/EmitSwiftInterface.cmake create mode 100644 Runtimes/Core/core/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 3a10217f189..78d80f2c357 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,5 @@ Runtimes/**/*.gyb Runtimes/**/*.apinotes Runtimes/**/*.yaml Runtimes/**/*.inc +Runtimes/**/*.json +Runtimes/**/*.modulemap diff --git a/Runtimes/Core/CMakeLists.txt b/Runtimes/Core/CMakeLists.txt index ebcfafe8845..2b3cb34526f 100644 --- a/Runtimes/Core/CMakeLists.txt +++ b/Runtimes/Core/CMakeLists.txt @@ -32,6 +32,7 @@ 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 @@ -46,19 +47,27 @@ 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) +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_OBJC_INTEROP "Enable runtime ObjC interop" 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_RUNTIME_LEAK_CHECKER "" ${SwiftCore_ENABLE_RIUNTIME_LEAK_CHECKER_default}) 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) set(SwiftCore_BACKTRACER_PATH "" CACHE STRING "Set a fixed path to the Swift backtracer") @@ -69,6 +78,8 @@ add_compile_definitions( $<$:-DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER=$> $<$:-DSWIFT_RUNTIME_CLOBBER_FREED_OBJECTS=$>) +add_compile_options( $<$,$>:-enable-library-evolution>) + include_directories(include) add_subdirectory(LLVMSupport) @@ -77,3 +88,4 @@ add_subdirectory(Demangling) add_subdirectory(Threading) add_subdirectory(runtime) add_subdirectory(stubs) +add_subdirectory(core) diff --git a/Runtimes/Core/Demangling/CMakeLists.txt b/Runtimes/Core/Demangling/CMakeLists.txt index 6ed6abb9ef6..519f0d1c740 100644 --- a/Runtimes/Core/Demangling/CMakeLists.txt +++ b/Runtimes/Core/Demangling/CMakeLists.txt @@ -19,10 +19,13 @@ target_include_directories(swiftDemangling "${SwiftCore_SWIFTC_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") +target_link_libraries(swiftDemangling PRIVATE swiftShims) + if(SwiftCore_ENABLE_CRASH_REPORTER_CLIENT) - target_compile_definitions(swiftDemangling PRIVATE SWIFT_HAVE_CRASHREPORTERCLIENT) - target_sources(swiftDemangling PRIVATE + # 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) diff --git a/Runtimes/Core/SwiftShims/swift/shims/CMakeLists.txt b/Runtimes/Core/SwiftShims/swift/shims/CMakeLists.txt index 12108497402..bace4b75bb1 100644 --- a/Runtimes/Core/SwiftShims/swift/shims/CMakeLists.txt +++ b/Runtimes/Core/SwiftShims/swift/shims/CMakeLists.txt @@ -34,4 +34,4 @@ target_include_directories(swiftShims INTERFACE $<$:${CMAKE_CURRENT_SOURCE_DIR}/../../> $<$:${CMAKE_CURRENT_SOURCE_DIR}>) target_compile_options(swiftShims INTERFACE - $<$:SHELL:-Xcc$-fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap>) + "$<$:SHELL:-Xcc -fmodule-map-file=${CMAKE_CURRENT_SOURCE_DIR}/module.modulemap>") diff --git a/Runtimes/Core/cmake/modules/AvailabilityMacros.cmake b/Runtimes/Core/cmake/modules/AvailabilityMacros.cmake new file mode 100644 index 00000000000..43d1c42179c --- /dev/null +++ b/Runtimes/Core/cmake/modules/AvailabilityMacros.cmake @@ -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("$<$:SHELL:-Xfrontend -define-availability -Xfrontend \"${def}\">") +endforeach() diff --git a/Runtimes/Core/cmake/modules/CMakeWorkarounds.cmake b/Runtimes/Core/cmake/modules/CMakeWorkarounds.cmake new file mode 100644 index 00000000000..20e0de73dc4 --- /dev/null +++ b/Runtimes/Core/cmake/modules/CMakeWorkarounds.cmake @@ -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. . +# 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 " -num-threads ${CMAKE_Swift_NUM_THREADS} -c ") + + 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 " -num-threads ${SwiftStdlib_NUM_LINK_JOBS} -emit-executable -o ") + set(CMAKE_Swift_CREATE_SHARED_LIBRARY " -num-threads ${SwiftStdlib_NUM_LINK_JOBS} -emit-library ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} -o ") +else() + set(CMAKE_Swift_CREATE_SHARED_LIBRARY " -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o -module-name -module-link-name -emit-module -emit-module-path -emit-dependencies ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} ") + + set(CMAKE_Swift_LINK_EXECUTABLE " -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o -emit-dependencies ") + + set(CMAKE_Swift_CREATE_STATIC_LIBRARY " -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o -module-name -module-link-name -emit-module -emit-module-path -emit-dependencies ") + + set(CMAKE_Swift_ARCHIVE_CREATE " crs ") + set(CMAKE_Swift_ARCHIVE_FINISH "") + + add_compile_options($<$:-wmo>) +endif() diff --git a/Runtimes/Core/cmake/modules/CompilerSettings.cmake b/Runtimes/Core/cmake/modules/CompilerSettings.cmake index f4b26cd2089..1ff594db063 100644 --- a/Runtimes/Core/cmake/modules/CompilerSettings.cmake +++ b/Runtimes/Core/cmake/modules/CompilerSettings.cmake @@ -1,3 +1,6 @@ +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 @@ -15,3 +18,39 @@ 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($<$:-color-diagnostics>) +endif() + +check_compiler_flag(Swift "-diagnostic-style swift" HAVE_SWIFT_DIAGNOSTIC_STYLE) +if(HAVE_SWIFT_DIAGNOSTIC_STYLE) + add_compile_options($<$:-diagnostic-style$swift>) +endif() diff --git a/Runtimes/Core/cmake/modules/EmitSwiftInterface.cmake b/Runtimes/Core/cmake/modules/EmitSwiftInterface.cmake new file mode 100644 index 00000000000..026f7530d68 --- /dev/null +++ b/Runtimes/Core/cmake/modules/EmitSwiftInterface.cmake @@ -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 + $<$:-emit-module-interface-path$${CMAKE_CURRENT_BINARY_DIR}/$.swiftinterface> + $<$:-emit-private-module-interface-path$${CMAKE_CURRENT_BINARY_DIR}/$.private.swiftinterface> + $<$:-library-level$api> + $<$:-Xfrontend$-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}/$.swiftinterface" + RENAME "${SwiftCore_MODULE_TRIPLE}.swiftinterface" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$.swiftmodule") + + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/$.private.swiftinterface" + RENAME "${SwiftCore_MODULE_TRIPLE}.private.swiftinterface" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/$.swiftmodule") + endif() +endfunction() diff --git a/Runtimes/Core/core/CMakeLists.txt b/Runtimes/Core/core/CMakeLists.txt new file mode 100644 index 00000000000..700bcdb341e --- /dev/null +++ b/Runtimes/Core/core/CMakeLists.txt @@ -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 + $<$:-parse-stdlib> + $<$:-nostdimport> + $<$:-explicit-module-build> + "$<$:SHELL:-enable-experimental-feature NoncopyableGenerics2>" + "$<$:SHELL:-enable-experimental-feature SuppressedAssociatedTypes>" + "$<$:SHELL:-enable-experimental-feature SE427NoInferenceOnExtension>" + "$<$:SHELL:-enable-experimental-feature AllowUnsafeAttribute>" + "$<$:SHELL:-enable-experimental-feature NonescapableTypes>" + "$<$:SHELL:-enable-experimental-feature MemberImportVisibility>" + "$<$:SHELL:-enable-experimental-feature TypedThrows>" + "$<$:SHELL:-enable-experimental-feature Macros>" + "$<$:SHELL:-enable-experimental-feature FreestandingMacros>" + "$<$:SHELL:-enable-experimental-feature BitwiseCopyable>" + "$<$:SHELL:-enable-experimental-feature Extern>" + "$<$:SHELL:-enable-experimental-feature DebugDescriptionMacro>" + "$<$:SHELL:-Xcc -DswiftCore_EXPORTS>" + "$<$:SHELL:-Xfrontend -group-info-path -Xfrontend ${CMAKE_CURRENT_SOURCE_DIR}/GroupInfo.json>" + "$<$:SHELL:-Xfrontend -enable-experimental-concise-pound-file>" + "$<$:SHELL:-Xfrontend -disable-autolinking-runtime-compatibility-concurrency>" + "$<$:SHELL:-Xfrontend -disable-objc-attr-requires-foundation-module>" + "$<$:SHELL:-Xfrontend -require-explicit-availability=ignore>" + "$<$:SHELL:-Xfrontend -enforce-exclusivity=unchecked>" + "$<$:-disable-autolinking-runtime-compatibility-dynamic-replacements>" + "$<$:-no-link-objc-runtime>" + "$<$:SHELL:-library-level api>" + "$<$:SHELL:-Xfrontend -enable-ossa-modules>" + "$<$:SHELL:-Xfrontend -target-min-inlining-version -Xfrontend min>" + "$<$:SHELL:-Xfrontend -enable-lexical-lifetimes=false>" + "$<$:SHELL:-Xfrontend -empty-abi-descriptor>" + "$<$:SHELL:-Xfrontend -disable-implicit-concurrency-module-import>" + "$<$:SHELL:-Xfrontend -disable-implicit-backtracing-module-import>" + "$<$:SHELL:-Xfrontend -disable-implicit-string-processing-module-import>" + "$<$:SHELL:-Xfrontend -prespecialize-generic-metadata>" + "$<$:SHELL:-runtime-compatibility-version none>" + "$<$:-warn-implicit-overrides>" + "$<$:SHELL:-Xllvm -sil-inline-generics>" + "$<$:SHELL:-Xllvm -sil-partial-specialization>") + +target_compile_definitions(swiftCore PRIVATE + $<$:-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 + $ + $ + $ + $ + $) +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. diff --git a/Runtimes/Core/runtime/CMakeLists.txt b/Runtimes/Core/runtime/CMakeLists.txt index c04c456517c..8638532ec3b 100644 --- a/Runtimes/Core/runtime/CMakeLists.txt +++ b/Runtimes/Core/runtime/CMakeLists.txt @@ -67,6 +67,11 @@ add_library(swiftRuntime OBJECT AccessibleFunction.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 # file rather than pushing them through macro flags. target_compile_definitions(swiftRuntime diff --git a/Runtimes/Resync.cmake b/Runtimes/Resync.cmake index 0f26d35bcf6..5fc2c863781 100644 --- a/Runtimes/Resync.cmake +++ b/Runtimes/Resync.cmake @@ -29,7 +29,9 @@ function(copy_library_sources name from_prefix to_prefix) "${StdlibSources}/${from_prefix}/${name}/*.gyb" "${StdlibSources}/${from_prefix}/${name}/*.apinotes" "${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}) # Get and create the directory @@ -52,12 +54,16 @@ endfunction() # Copy shared core headers copy_library_sources(include "" "Core") +# Copy magic linker symbols +copy_library_sources("linker-support" "" "Core") + set(CoreLibs LLVMSupport SwiftShims runtime CompatibilityOverride - stubs) + stubs + core) # Add these as we get them building # core