# 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 " -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 " -wmo -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 " -wmo -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o -emit-dependencies ") set(CMAKE_Swift_CREATE_STATIC_LIBRARY " -wmo -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 "") endif()