├── Makefile ├── README.md ├── WindowsSDKVFSOverlay.yaml.in ├── cmake ├── caches │ ├── swift-corelibs-foundation-Linux-x86_64.cmake │ ├── swift-corelibs-foundation-Windows-x86_64.cmake │ ├── swift-corelibs-libdispatch-Linux-x86_64.cmake │ ├── swift-corelibs-libdispatch-Windows-x86_64.cmake │ ├── swift-stdlib-common.cmake │ ├── swift-stdlib-linux.cmake │ ├── swift-stdlib-windows.cmake │ ├── toolchain-Linux-x86_64.cmake │ ├── toolchain-Windows-aarch64.cmake │ ├── toolchain-Windows-x86_64.cmake │ ├── toolchain-common.cmake │ └── toolchain.cmake ├── modules │ ├── WindowsCompileRules.cmake │ └── WindowsSDK.cmake ├── scripts │ └── GetLLVMVersion.cmake └── toolchains │ ├── Toolchain-Linux-x86_64.cmake │ └── Toolchain-bootstrap.cmake └── scripts └── rebase.bash /Makefile: -------------------------------------------------------------------------------- 1 | need := 3.82 2 | ifneq ($(need), $(firstword $(sort $(MAKE_VERSION) $(need)))) 3 | $(error You need at least make version >= $(need)) 4 | endif 5 | 6 | BuildOS := $(shell uname -s) 7 | BuildArch := $(shell uname -m) 8 | ifeq ($(BuildArch),amd64) 9 | BuildArch := x86_64 10 | endif 11 | Build := $(BuildOS)-$(BuildArch) 12 | 13 | # BuildType | CMake Build Type | Debug | Strip | Asserts 14 | # -----------+------------------+-------+-------+--------- 15 | # Debug | Debug | -g | N | Y 16 | # Release | RelWithDebInfo | -g | Y | Y 17 | 18 | BuildType := Debug 19 | 20 | Host := $(Build) 21 | HostOS := $(firstword $(subst -, ,$(Host))) 22 | HostArch := $(lastword $(subst -, ,$(Host))) 23 | 24 | ifeq ($(BuildType),Debug) 25 | CMakeBuildType := Debug 26 | AssertsEnabled := YES 27 | AssertsVariant := Asserts 28 | InstallVariant := 29 | else ifeq ($(BuildType),Release) 30 | CMakeBuildType := RelWithDebInfo 31 | AssertsEnabled := YES 32 | AssertsVariant := Asserts 33 | InstallVariant := -stripped 34 | else 35 | $(error BuildType should be either Debug or Release) 36 | endif 37 | 38 | SourceCache := $(abspath $(dir $(realpath $(lastword $(MAKEFILE_LIST))))..) 39 | BinaryCache := $(dir $(SourceCache))BinaryCache 40 | 41 | CMakeCaches := $(SourceCache)/infrastructure/cmake/caches 42 | CMakeScripts := $(SourceCache)/infrastructure/cmake/scripts 43 | 44 | CMake := $(shell which cmake) 45 | Ninja := $(shell which ninja) 46 | 47 | CMakeFlags := -G Ninja \ 48 | -DCMAKE_MAKE_PROGRAM=$(Ninja) \ 49 | -DCMAKE_BUILD_TYPE=$(CMakeBuildType) \ 50 | -DCMAKE_INSTALL_PREFIX= # DESTDIR will set the actual path 51 | 52 | # inform the build where the source tree resides 53 | CMakeFlags += -DTOOLCHAIN_SOURCE_DIR=$(SourceCache) 54 | # CMakeFlags += -DCMAKE_SYSTEM_NAME=$(HostOS) -DCMAKE_SYSTEM_PROCESSOR=$(HostArch) 55 | 56 | Vendor := unknown 57 | Version := Default 58 | 59 | XCToolchain = $(Vendor)-$(AssertsVariant)-$(Version).xctoolchain 60 | SwiftStandardLibraryTarget := swift-stdlib-$(shell echo $(HostOS) | tr '[A-Z]' '[a-z]') 61 | 62 | DESTDIR := $(or $(DESTDIR),$(BinaryCache)/Library/Developer/Toolchains/$(XCToolchain)/usr) 63 | 64 | # --- toolchain-tools --- 65 | $(BinaryCache)/Release/$(Build)/toolchain-tools/build.ninja: 66 | $(CMake) \ 67 | -G Ninja \ 68 | -B $(BinaryCache)/Release/$(Build)/toolchain-tools \ 69 | -D CMAKE_BUILD_TYPE=Release \ 70 | -D CMAKE_MAKE_PROGRAM=$(Ninja) \ 71 | -D LLDB_DISABLE_PYTHON=YES \ 72 | -D LLVM_USE_HOST_TOOLS=NO \ 73 | -D LLVM_ENABLE_ASSERTIONS=NO \ 74 | -D LLVM_ENABLE_PROJECTS="clang;lldb" \ 75 | -S $(SourceCache)/llvm-project/llvm 76 | 77 | $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/llvm-tblgen: $(BinaryCache)/Release/$(Build)/toolchain-tools/build.ninja 78 | $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/llvm-tblgen: 79 | $(Ninja) -C $(BinaryCache)/Release/$(Build)/toolchain-tools llvm-tblgen 80 | 81 | $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/clang-tblgen: $(BinaryCache)/Release/$(Build)/toolchain-tools/build.ninja 82 | $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/clang-tblgen: 83 | $(Ninja) -C $(BinaryCache)/Release/$(Build)/toolchain-tools clang-tblgen 84 | 85 | $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/lldb-tblgen: $(BinaryCache)/Release/$(Build)/toolchain-tools/build.ninja 86 | $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/lldb-tblgen: 87 | $(Ninja) -C $(BinaryCache)/Release/$(Build)/toolchain-tools lldb-tblgen 88 | 89 | # --- toolchain --- 90 | .PHONY: toolchain 91 | toolchain: $(BinaryCache)/$(BuildType)/$(Host)/toolchain/build.ninja 92 | toolchain: 93 | DESTDIR=$(DESTDIR) $(Ninja) -C $(BinaryCache)/$(BuildType)/$(Host)/toolchain install-distribution$(InstallVariant) 94 | 95 | $(BinaryCache)/$(BuildType)/$(Host)/toolchain/build.ninja: $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/llvm-tblgen 96 | $(BinaryCache)/$(BuildType)/$(Host)/toolchain/build.ninja: $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/clang-tblgen 97 | $(BinaryCache)/$(BuildType)/$(Host)/toolchain/build.ninja: $(BinaryCache)/Release/$(Build)/toolchain-tools/bin/lldb-tblgen 98 | $(BinaryCache)/$(BuildType)/$(Host)/toolchain/build.ninja: 99 | $(CMake) $(CMakeFlags) \ 100 | -B $(BinaryCache)/$(BuildType)/$(Host)/toolchain \ 101 | -C $(CMakeCaches)/toolchain-common.cmake \ 102 | -C $(CMakeCaches)/toolchain.cmake \ 103 | -C $(CMakeCaches)/toolchain-$(Host).cmake \ 104 | -D LLVM_ENABLE_ASSERTIONS=$(AssertsEnabled) \ 105 | -D LLVM_USE_HOST_TOOLS=NO \ 106 | -D LLVM_TABLEGEN=$(BinaryCache)/Release/$(Build)/toolchain-tools/bin/llvm-tblgen \ 107 | -D CLANG_TABLEGEN=$(BinaryCache)/Release/$(Build)/toolchain-tools/bin/clang-tblgen \ 108 | -D LLDB_TABLEGEN=$(BinaryCache)/Release/$(Build)/toolchain-tools/bin/lldb-tblgen \ 109 | -D SWIFT_PATH_TO_LIBDISPATCH_SOURCE=$(SourceCache)/swift-corelibs-libdispatch \ 110 | -S $(SourceCache)/llvm-project/llvm 111 | 112 | # --- swift-stdlib --- 113 | define build-swift-stdlib 114 | $$(BinaryCache)/Release/$(1)/llvm/build.ninja: 115 | $$(CMake) $$(CMakeFlags) \ 116 | -B $$(BinaryCache)/Release/$(1)/llvm \ 117 | -D CMAKE_BUILD_TYPE=Release \ 118 | -G Ninja \ 119 | -S $$(SourceCache)/llvm-project/llvm 120 | 121 | swift-stdlib-$(1): $$(BinaryCache)/$$(BuildType)/swift-stdlib-$(1)/build.ninja 122 | swift-stdlib-$(1): 123 | DESTDIR=$(DESTDIR) $(Ninja) -C $$(BinaryCache)/$$(BuildType)/swift-stdlib-$(1) install 124 | 125 | $$(BinaryCache)/$$(BuildType)/swift-stdlib-$(1)/build.ninja: $$(BinaryCache)/Release/$(1)/llvm/build.ninja 126 | $$(BinaryCache)/$$(BuildType)/swift-stdlib-$(1)/build.ninja: 127 | $$(CMake) $$(CMakeFlags) \ 128 | -B $$(BinaryCache)/$$(BuildType)/swift-stdlib-$(1) \ 129 | -C $$(CMakeCaches)/swift-stdlib-common.cmake \ 130 | -C $$(CMakeCaches)/swift-stdlib-$(1).cmake \ 131 | -D LLVM_DIR=$$(BinaryCache)/Release/$(1)/llvm/lib/cmake/llvm \ 132 | -D SWIFT_NATIVE_SWIFT_TOOLS_PATH=$(BinaryCache)/Release/$(Build)/toolchain/bin \ 133 | -S $$(SourceCache)/llvm-project/swift 134 | endef 135 | 136 | swift-stdlib-targets := linux windows android 137 | $(foreach target,$(swift-stdlib-targets),$(eval $(call build-swift-stdlib,$(target)))) 138 | 139 | # --- libdispatch --- 140 | .PHONY: swift-corelibs-libdispatch 141 | swift-corelibs-libdispatch: $(BuildDir)/swift-corelibs-libdispatch/build.ninja 142 | DESTDIR=$(DESTDIR) $(Ninja) -C $(BuildDir)/swift-corelibs-libdispatch install 143 | 144 | .ONESHELL: $(BuildDir)/swift-corelibs-libdispatch/build.ninja 145 | $(BuildDir)/swift-corelibs-libdispatch/build.ninja: bootstrap-toolchain bootstrap-target-swift 146 | $(BuildDir)/swift-corelibs-libdispatch/build.ninja: 147 | mkdir -p $(BuildDir)/swift-corelibs-libdispatch 148 | cd $(BuildDir)/swift-corelibs-libdispatch 149 | $(CMake) $(CMakeFlags) \ 150 | -C $(CMakeCaches)/swift-corelibs-libdispatch-$(Host).cmake \ 151 | -DSwift_DIR=$(SourceDir)/build/$(BuildType)/$(SwiftStandardLibraryTarget)/lib/cmake/swift \ 152 | $(SourceDir)/swift-corelibs-libdispatch 153 | 154 | # --- foundation --- 155 | .PHONY: swift-corelibs-foundation 156 | swift-corelibs-foundation: bootstrap-target-swift 157 | swift-corelibs-foundation: $(BuildDir)/swift-corelibs-foundation/build.ninja 158 | swift-corelibs-foundation: 159 | DESTDIR=$(DESTDIR) $(Ninja) -C $(BuildDir)/swift-corelibs-foundation install 160 | 161 | .ONESHELL: $(BuildDir)/swift-corelibs-foundation/build.ninja 162 | $(BuildDir)/swift-corelibs-foundation/build.ninja: bootstrap-toolchain 163 | $(BuildDir)/swift-corelibs-foundation/build.ninja: swift-corelibs-libdispatch 164 | $(BuildDir)/swift-corelibs-foundation/build.ninja: 165 | mkdir -p $(BuildDir)/swift-corelibs-foundation 166 | cd $(BuildDir)/swift-corelibs-foundation 167 | $(CMake) $(CMakeFlags) \ 168 | -C $(CMakeCaches)/swift-corelibs-foundation-$(Host).cmake \ 169 | -DFOUNDATION_PATH_TO_LIBDISPATCH_SOURCE=$(SourceDir)/swift-corelibs-libdispatch \ 170 | -DFOUNDATION_PATH_TO_LIBDISPATCH_BUILD=$(BuildDir)/swift-corelibs-libdispatch \ 171 | $(SourceDir)/swift-corelibs-foundation 172 | 173 | # --- default --- 174 | .DEFAULT_GOAL := default 175 | default: 176 | 177 | # --- distclean --- 178 | distclean: 179 | rm -rf $(BuildDir) 180 | 181 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # toolchain-infrastructure 2 | infrastructure for building a complete swift, clang, llvm toolchain 3 | 4 | This enables a two stage build of a complete toolchain with C/C++/Swift support and associated tooling. 5 | -------------------------------------------------------------------------------- /WindowsSDKVFSOverlay.yaml.in: -------------------------------------------------------------------------------- 1 | 2 | version: 0 3 | case-sensitive: false 4 | roots: 5 | - name: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared" 6 | type: directory 7 | contents: 8 | - name: Bcrypt.h 9 | type: file 10 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/bcrypt.h" 11 | - name: DriverSpecs.h 12 | type: file 13 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/driverspecs.h" 14 | - name: SpecStrings.h 15 | type: file 16 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/specstrings.h" 17 | - name: wtypesbase.h 18 | type: file 19 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/WTypesbase.h" 20 | - name: ConcurrencySal.h 21 | type: file 22 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/concurrencysal.h" 23 | - name: Rpc.h 24 | type: file 25 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/rpc.h" 26 | - name: Security.h 27 | type: file 28 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/shared/security.h" 29 | - name: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um" 30 | type: directory 31 | contents: 32 | - name: commctrl.h 33 | type: file 34 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/CommCtrl.h" 35 | - name: dbghelp.h 36 | type: file 37 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/DbgHelp.h" 38 | - name: docobj.h 39 | type: file 40 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/DocObj.h" 41 | - name: exdisp.h 42 | type: file 43 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ExDisp.h" 44 | - name: Fibersapi.h 45 | type: file 46 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/fibersapi.h" 47 | - name: isguids.h 48 | type: file 49 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/IsGuids.h" 50 | - name: knownfolders.h 51 | type: file 52 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/KnownFolders.h" 53 | - name: oaidl.h 54 | type: file 55 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/OAIdl.h" 56 | - name: ocidl.h 57 | type: file 58 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/OCIdl.h" 59 | - name: objidl.h 60 | type: file 61 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ObjIdl.h" 62 | - name: objidlbase.h 63 | type: file 64 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ObjIdlbase.h" 65 | - name: ole2.h 66 | type: file 67 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/Ole2.h" 68 | - name: oleauto.h 69 | type: file 70 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/OleAuto.h" 71 | - name: propidl.h 72 | type: file 73 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/PropIdl.h" 74 | - name: propidlbase.h 75 | type: file 76 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/PropIdlBase.h" 77 | - name: psapi.h 78 | type: file 79 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/Psapi.h" 80 | - name: Shellapi.h 81 | type: file 82 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/shellapi.h" 83 | - name: shldisp.h 84 | type: file 85 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlDisp.h" 86 | - name: shlguid.h 87 | type: file 88 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlGuid.h" 89 | - name: shlobj.h 90 | type: file 91 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlObj.h" 92 | - name: shlobj_core.h 93 | type: file 94 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShlObj_core.h" 95 | - name: shobjidl.h 96 | type: file 97 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShObjIdl.h" 98 | - name: shobjidl_core.h 99 | type: file 100 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/ShObjIdl_core.h" 101 | - name: tlhelp32.h 102 | type: file 103 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/TlHelp32.h" 104 | - name: unknwn.h 105 | type: file 106 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/Unknwn.h" 107 | - name: unknwnbase.h 108 | type: file 109 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/Unknwnbase.h" 110 | - name: winbase.h 111 | type: file 112 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/WinBase.h" 113 | - name: windows.h 114 | type: file 115 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/Windows.h" 116 | - name: WinIoCtl.h 117 | type: file 118 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/winioctl.h" 119 | - name: winnls.h 120 | type: file 121 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/WinNls.h" 122 | - name: winsock2.h 123 | type: file 124 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/WinSock2.h" 125 | - name: winuser.h 126 | type: file 127 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/WinUser.h" 128 | - name: ws2tcpip.h 129 | type: file 130 | external-contents: "@UniversalCRTSdkDir@/Include/@UCRTVersion@/um/WS2tcpip.h" 131 | 132 | -------------------------------------------------------------------------------- /cmake/caches/swift-corelibs-foundation-Linux-x86_64.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-linux-gnu CACHE STRING "") 3 | 4 | -------------------------------------------------------------------------------- /cmake/caches/swift-corelibs-foundation-Windows-x86_64.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-windows-msvc CACHE STRING "") 3 | 4 | # TODO(compnerd) figure out how to break the cycle between XCTest and Foundation 5 | set(ENABLE_TESTING NO CACHE BOOL "") 6 | 7 | # --- libraries to use --- 8 | 9 | # TODO(compnerd) build these from source 10 | set(ICU_INCLUDE_DIR ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/include CACHE STRING "") 11 | set(ICU_I18N_LIBRARY ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/lib/icuin.lib CACHE STRING "") 12 | set(ICU_UC_LIBRARY ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/lib/icuuc.lib CACHE STRING "") 13 | set(ICU_LIBRARY ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/lib/icuin.lib;${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/lib/icuuc.lib CACHE STRING "") 14 | 15 | set(LIBXML2_INCLUDE_DIR ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/libxml2/include CACHE STRING "") 16 | set(LIBXML2_LIBRARY ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/libxml2/lib/libxml2.lib CACHE STRING "") 17 | 18 | set(CURL_INCLUDE_DIR ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/curl/include CACHE STRING "") 19 | set(CURL_LIBRARY ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/curl/lib/libcurl.lib CACHE STRING "") 20 | 21 | set(CMAKE_FIND_ROOT_PATH "/var/empty" CACHE STRING "") 22 | 23 | -------------------------------------------------------------------------------- /cmake/caches/swift-corelibs-libdispatch-Linux-x86_64.cmake: -------------------------------------------------------------------------------- 1 | # NOTE(compnerd) always build using the lld linker 2 | set(USE_LLD_LINKER YES CACHE BOOL "") 3 | 4 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-linux-gnu CACHE STRING "") 5 | 6 | set(ENABLE_SWIFT YES CACHE BOOL "") 7 | 8 | -------------------------------------------------------------------------------- /cmake/caches/swift-corelibs-libdispatch-Windows-x86_64.cmake: -------------------------------------------------------------------------------- 1 | # NOTE(compnerd) always build using the lld linker 2 | set(USE_LLD_LINKER YES CACHE BOOL "") 3 | 4 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-windows-msvc CACHE STRING "") 5 | 6 | # NOTE(compnerd) we need to override the include order for the Windows SDK to 7 | # accomodate the conflicts with the compiler resource dir and promote the SDK to 8 | # system level. The include ordering is important to the construction of the 9 | # modules for building libdispatch. Note that `-internal-isystem` is not a 10 | # driver level flag, so we need to pass that through the C compiler frontend 11 | # (which is guaranteed to be clang). So, we end up using `-Xcc` to pass a flag 12 | # to the driver that passes through the C driver to the compiler (`-Xclang`). 13 | set(CMAKE_SWIFT_FLAGS -Xcc -Xclang -Xcc -internal-isystem -Xcc -Xclang -Xcc $ENV{VCToolsInstallDir}/include -Xcc -Xclang -Xcc -internal-isystem -Xcc -Xclang -Xcc $ENV{UniversalCRTSdkDir}/Include/$ENV{UCRTVersion}/ucrt CACHE STRING "") 14 | 15 | set(ENABLE_SWIFT YES CACHE BOOL "") 16 | 17 | # TODO(compnerd) port the unit tests to Windows 18 | set(ENABLE_TESTING NO CACHE BOOL "") 19 | 20 | -------------------------------------------------------------------------------- /cmake/caches/swift-stdlib-common.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(SWIFT_PATH_TO_LLVM_SOURCE ${TOOLCHAIN_SOURCE_DIR}/llvm CACHE STRING "") 3 | set(SWIFT_PATH_TO_CLANG_SOURCE ${TOOLCHAIN_SOURCE_DIR}/clang CACHE STRING "") 4 | 5 | # TODO(compnerd) figure out why CMAKE_HOST_SYSTEM_PROCSSOR is not set here 6 | set(SWIFT_PATH_TO_LLVM_BUILD ${TOOLCHAIN_SOURCE_DIR}/build/Release/${CMAKE_HOST_SYSTEM_NAME}-x86_64/toolchain CACHE STRING "") 7 | set(SWIFT_PATH_TO_CMARK_BUILD ${TOOLCHAIN_SOURCE_DIR}/build/Release/${CMAKE_HOST_SYSTEM_NAME}-x86_64/toolchain/tools/cmark CACHE STRING "") 8 | set(SWIFT_NATIVE_SWIFT_TOOLS_PATH ${TOOLCHAIN_SOURCE_DIR}/build/Release/${CMAKE_HOST_SYSTEM_NAME}-x86_64/toolchain/bin CACHE STRING "") 9 | 10 | set(SWIFT_INCLUDE_TOOLS NO CACHE BOOL "") 11 | 12 | set(SWIFT_INCLUDE_TESTS NO CACHE BOOL "") 13 | 14 | set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") 15 | 16 | set(SWIFT_BUILD_DYNAMIC_STDLIB YES CACHE BOOL "") 17 | set(SWIFT_BUILD_STATIC_STDLIB YES CACHE BOOL "") 18 | 19 | set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY YES CACHE BOOL "") 20 | set(SWIFT_BUILD_STATIC_SDK_OVERLAY YES CACHE BOOL "") 21 | 22 | set(SWIFT_BUILD_REMOTE_MIRROR YES CACHE BOOL "") 23 | 24 | set(SWIFT_BUILD_SOURCEKIT NO CACHE BOOL "") 25 | 26 | set(SWIFT_INSTALL_COMPONENTS 27 | stdlib 28 | sdk-overlay 29 | CACHE STRING "") 30 | 31 | -------------------------------------------------------------------------------- /cmake/caches/swift-stdlib-linux.cmake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/compnerd/toolchain-infrastructure/fd9fb005fd5292b1b066864cba2f7317d9fa210f/cmake/caches/swift-stdlib-linux.cmake -------------------------------------------------------------------------------- /cmake/caches/swift-stdlib-windows.cmake: -------------------------------------------------------------------------------- 1 | 2 | # --- target --- 3 | # TODO(compnerd) mark primary builds because the build system is not ready for 4 | # cross-compilation 5 | set(SWIFT_PRIMARY_VARIANT_SDK WINDOWS CACHE STRING "") 6 | set(SWIFT_PRIMARY_VARIANT_ARCH x86_64 CACHE STRING "") 7 | 8 | # TODO(compnerd) define the SWIFT_HOST_VARIANT_* since the build system is not 9 | # ready to disable tools 10 | set(SWIFT_HOST_VARIANT_SDK NONE CACHE STRING "") 11 | set(SWIFT_HOST_VARIANT_ARCH x86_64 CACHE STRING "") 12 | 13 | # TODO(compnerd) specify a single architecture because the build system is not 14 | # ready for the multi-architecture setup 15 | set(SWIFT_SDK_WINDOWS_ARCHITECTURES x86_64 CACHE STRING "") 16 | 17 | # --- libraries to use --- 18 | set(SWIFT_WINDOWS_x86_64_ICU_UC_INCLUDE ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/include/unicode CACHE STRING "") 19 | set(SWIFT_WINDOWS_x86_64_ICU_UC ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/lib/icuuc.lib CACHE STRING "") 20 | set(SWIFT_WINDOWS_x86_64_ICU_I18N_INCLUDE ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/include CACHE STRING "") 21 | set(SWIFT_WINDOWS_x86_64_ICU_I18N ${TOOLCHAIN_SOURCE_DIR}/build/thirdparty/icu/lib/icuin.lib CACHE STRING "") 22 | 23 | # --- SDKs --- 24 | set(SWIFT_SDKS 25 | WINDOWS 26 | CACHE STRING "") 27 | 28 | -------------------------------------------------------------------------------- /cmake/caches/toolchain-Linux-x86_64.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-stack-protector -fno-common" CACHE STRING "" FORCE) 3 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector -fno-common" CACHE STRING "" FORCE) 4 | 5 | -------------------------------------------------------------------------------- /cmake/caches/toolchain-Windows-aarch64.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -GS" CACHE STRING "" FORCE) 3 | set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -GS -Wno-c++98-compat -Wno-c++98-compat-pedantic" CACHE STRING "" FORCE) 4 | 5 | set(CROSS_TOOLCHAIN_FLAGS_NATIVE "-DLLVM_TOOL_LLDB_BUILD=OFF" CACHE STRING "") 6 | 7 | 8 | -------------------------------------------------------------------------------- /cmake/caches/toolchain-Windows-x86_64.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -GS" CACHE STRING "" FORCE) 3 | set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -GS -Wno-c++98-compat -Wno-c++98-compat-pedantic" CACHE STRING "" FORCE) 4 | 5 | set(CROSS_TOOLCHAIN_FLAGS_NATIVE "-DLLVM_TOOL_LLDB_BUILD=OFF" CACHE STRING "") 6 | 7 | -------------------------------------------------------------------------------- /cmake/caches/toolchain-common.cmake: -------------------------------------------------------------------------------- 1 | 2 | # --- global --- 3 | 4 | set(LLVM_ENABLE_PROJECTS 5 | clang 6 | clang-tools-extra 7 | lld 8 | lldb 9 | cmark 10 | swift 11 | CACHE STRING "") 12 | 13 | set(LLVM_EXTERNAL_PROJECTS 14 | cmark 15 | swift 16 | CACHE STRING "") 17 | 18 | # --- LLVM --- 19 | 20 | if(CMAKE_BUILD_TYPE MATCHES Debug) 21 | set(PACKAGE_VENDOR "" CACHE STRING "") 22 | else() 23 | set(PACKAGE_VENDOR "compnerd.org" CACHE STRING "") 24 | endif() 25 | 26 | # NOTE(compnerd) LLVM appends a VCS revision string to its package version, 27 | # which we do not want. We do not want the "svn" suffix on development 28 | # toolchains to avoid churn. 29 | set(LLVM_APPEND_VC_REV NO CACHE BOOL "") 30 | set(LLVM_VERSION_SUFFIX "" CACHE STRING "") 31 | 32 | # NOTE(compnerd) currently the x86 and ARM targets are the ones that we are 33 | # building, so only enable the backends for those architectures. 34 | set(LLVM_TARGETS_TO_BUILD AArch64 ARM WebAssembly X86 CACHE STRING "") 35 | 36 | set(LLVM_INCLUDE_DOCS NO CACHE BOOL "") 37 | set(LLVM_INCLUDE_EXAMPLES NO CACHE BOOL "") 38 | 39 | # NOTE(compnerd) we do not use the GO bindings and the tests require additional 40 | # dependencies which can cause the tests to not always work properly. 41 | set(LLVM_INCLUDE_GO_TESTS NO CACHE BOOL "") 42 | 43 | # NOTE(compnerd) we do not use the OCaml bindings 44 | set(LLVM_ENABLE_OCAMLDOC NO CACHE BOOL "") 45 | 46 | # NOTE(compnerd) disable the gold plugin as we currently use ld64 and lld. 47 | # Eventually, it would be ideal to only have the lld linker as the universal 48 | # linker. 49 | set(LLVM_TOOL_GOLD_BUILD NO CACHE BOOL "") 50 | 51 | # NOTE(compnerd) disable libxml2 usage. This is needed for the manifest tool 52 | # (llvm-mt). Since this tool is not being used currently, avoid the setup for 53 | # libxml2 54 | set(LLVM_ENABLE_LIBXML2 NO CACHE BOOL "") 55 | 56 | # FIXME(compnerd) we want to build compiler-rt as a runtimes project 57 | set(LLVM_BUILD_EXTERNAL_COMPILER_RT NO) 58 | 59 | # NOTE(compnerd) we use a shared version of LLVM across clang and swift. 60 | # However, swift does not link the full version of LLVMSupport in the runtime, 61 | # and thus we need to disable the ABI breaking checks. 62 | set(LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING FORCE_OFF CACHE BOOL "") 63 | 64 | # NOTE(compnerd) provide the handy symlinks for the toolnames without the llvm- 65 | # prefix to make developers happy. 66 | set(LLVM_INSTALL_BINUTILS_SYMLINKS YES CACHE BOOL "") 67 | 68 | # NOTE(compnerd) we do not currently use the benchmark targets. Disable target 69 | # generation for now. 70 | set(LLVM_INCLUDE_BENCHMARKS NO CACHE BOOL "") 71 | 72 | # TODO(compnerd) setup the toolchain to ensure that the libedit that we use is 73 | # available on all the targets and is reproducible. 74 | set(LLVM_ENABLE_LIBEDIT YES CACHE BOOL "") 75 | 76 | # XXX(compnerd) is libpfm useful for our builds? 77 | set(LLVM_ENABLE_LIBPFM NO CACHE BOOL "") 78 | 79 | # TODO(compnerd) setup the toolchain to ensure that the zlib that we use is 80 | # available on all the targets and is reproducible. 81 | set(LLVM_ENABLE_ZLIB YES CACHE BOOL "") 82 | 83 | # NOTE(compnerd) use the modules build which can be a bit faster in practice. 84 | if(CMAKE_C_COMPILER_ID MATCHES clang) 85 | set(LLVM_ENABLE_MODULES YES CACHE BOOL "") 86 | endif() 87 | 88 | # NOTE(compnerd) fission is significantly faster to link, so we should prefer to 89 | # enable it. This would be better if we could package it into a DWP. 90 | # 91 | # Disable it on Windows to avoid the unknown argument warning 92 | if(CMAKE_SYSTEM_NAME STREQUAL Windows) 93 | set(LLVM_USE_SPLIT_DWARF NO CACHE BOOL "") 94 | else() 95 | set(LLVM_USE_SPLIT_DWARF YES CACHE BOOL "") 96 | endif() 97 | 98 | # FIXME(compnerd) we do not enable polyhedra optimizations currently 99 | set(LLVM_POLLY_LINK_INTO_TOOLS NO CACHE BOOL "") 100 | set(LLVM_POLLY_BUILD NO CACHE BOOL "") 101 | 102 | set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "") 103 | 104 | # --- clang --- 105 | 106 | if(CMAKE_BUILD_TYPE MATCHES Debug) 107 | set(CLANG_VENDOR "" CACHE STRING "") 108 | set(CLANG_VENDOR_UTI "" CACHE STRING "") 109 | else() 110 | set(CLANG_VENDOR "compnerd.org" CACHE STRING "") 111 | set(CLANG_VENDOR_UTI org.compnerd.clang CACHE STRING "") 112 | endif() 113 | 114 | # NOTE(compnerd) create the symlinks for the traditional Unix C/C++/C 115 | # Preprocessor drivers (cc, c++, cpp). Create expected entries for clang, 116 | # clang++, and clang-cpp to mirror GCC's behaviour. Create the clang-cl driver 117 | # link to allow cross-compilation to Windows. 118 | set(CLANG_LINKS_TO_CREATE cc c++ cpp clang++ clang-cpp clang-cl CACHE STRING "") 119 | 120 | # NOTE(compnerd) support loading plugins into the compiler to enable additional 121 | # tooling when using the toolchain. 122 | set(CLANG_PLUGIN_SUPPORT ON CACHE BOOL "") 123 | 124 | # NOTE(compnerd) embed a build id by default in the artifacts generated by the 125 | # compiler. This allows for production builds to save the debug information and 126 | # tie it to the version. 127 | set(ENABLE_LINKER_BUILD_ID YES CACHE BOOL "") 128 | 129 | # NOTE(compnerd) releax relocations by default. This can allow fewer 130 | # relocations which in turn results in faster links. 131 | set(ENABLE_X86_RELAX_RELOCATIONS YES CACHE BOOL "") 132 | 133 | # NOTE(compnerd) this controls the versions of python that are populated for the 134 | # libclang python bindings 135 | set(CLANG_PYTHON_BINDINGS_VERSIONS 2.7 CACHE STRING "") 136 | 137 | # TODO(compnerd) setup the toolchain to ensure that the Z3 that we use is 138 | # available on all the targets and is reproducible 139 | set(CLANG_ANALYZER_ENABLE_Z3_SOLVER NO CACHE BOOL "") 140 | 141 | # TODO(compnerd) ensure that we get the revisions for all components to identify 142 | # the build sufficiently to know that the build is different 143 | # set(CLANG_REPOSITORY_STRING "llvm: ${LLVM_REVISION}, cfe: ${CFE_REVISION}, lld: ${LLD_REVISION}" CACHE STRING "") 144 | 145 | # --- lld --- 146 | 147 | # NOTE(compnerd) build similarly across all hosts 148 | set(LLD_USE_VTUNE NO CACHE BOOL "") 149 | 150 | # --- lldb --- 151 | 152 | # TODO(compnerd) setup the toolchain to ensure that the libedit that we use is 153 | # available on all the targets and is reproducible. 154 | set(LLDB_DISABLE_LIBEDIT YES CACHE BOOL "") 155 | 156 | if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin) 157 | set(LLDB_BUILD_FRAMEWORK YES CACHE BOOL "") 158 | else() 159 | set(LLDB_BUILD_FRAMEWORK NO CACHE BOOL "") 160 | endif() 161 | 162 | # TODO(compnerd) setup the toolchain to ensure that the python and swig that we 163 | # use is available on all the targets and is reproducible. 164 | set(LLDB_DISABLE_PYTHON YES CACHE BOOL "") 165 | 166 | # TODO(compnerd) setup the toolchain to ensure that the ncurses that we use is 167 | # available on all the targets and is reproducible. 168 | set(LLDB_DISABLE_CURSES YES CACHE BOOL "") 169 | 170 | # NOTE(compnerd) allow PYTHONHOME to be used to find python for lldb 171 | set(LLDB_RELOCATABLE_PYTHON YES CACHE BOOL "") 172 | 173 | # NOTE(compnerd) do not provide a new six.py package in the toolchain 174 | set(LLDB_USE_SYSTEM_SIX YES CACHE BOOL "") 175 | 176 | # NOTE(compnerd) use the pre-generated swig bindings rather than building it 177 | set(LLDB_ALLOW_STATIC_BINDINGS YES CACHE BOOL "") 178 | set(LLDB_USE_STATIC_BINDINGS YES CACHE BOOL "") 179 | 180 | # --- swift --- 181 | 182 | # NOTE(compnerd) build with the lld linker rather than the gold linker. 183 | set(SWIFT_ENABLE_GOLD_LINKER NO CACHE BOOL "") 184 | set(SWIFT_ENABLE_LLD_LINKER YES CACHE BOOL "") 185 | 186 | # NOTE(compnerd) build the swift tools to populate them into the toolchain. 187 | set(SWIFT_INCLUDE_TOOLS YES CACHE BOOL "") 188 | 189 | # NOTE(compnerd) disable building the documentation as we do not wish to push 190 | # tht into the toolchain. 191 | set(SWIFT_INCLUDE_DOCS NO CACHE BOOL "") 192 | 193 | # NOTE(compnerd) disable the standard library, this is part of the target which 194 | # will be built separately. 195 | set(SWIFT_BUILD_DYNAMIC_STDLIB NO CACHE BOOL "") 196 | set(SWIFT_BUILD_STATIC_STDLIB NO CACHE BOOL "") 197 | 198 | # NOTE(compnerd) disable the SDK overlay, this is part of the target which will 199 | # be built separately. 200 | set(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY NO CACHE BOOL "") 201 | set(SWIFT_BUILD_STATIC_SDK_OVERLAY NO CACHE BOOL "") 202 | 203 | # NOTE(compnerd) we need to build the remote mirror for the debugger 204 | set(SWIFT_BUILD_REMOTE_MIRROR YES CACHE BOOL "") 205 | 206 | # NOTE(compnerd) build SourceKit to enable IDE integration tools. 207 | set(SWIFT_BUILD_SOURCEKIT YES CACHE BOOL "") 208 | 209 | -------------------------------------------------------------------------------- /cmake/caches/toolchain.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(LLVM_TOOLCHAIN_TOOLS 3 | addr2line 4 | ar 5 | c++filt 6 | dsymutil 7 | dwp 8 | # lipo 9 | llvm-ar 10 | llvm-cov 11 | llvm-cvtres 12 | llvm-cxxfilt 13 | llvm-dlltool 14 | llvm-dwarfdump 15 | llvm-dwp 16 | llvm-lib 17 | llvm-lipo 18 | llvm-mt 19 | llvm-nm 20 | llvm-objcopy 21 | llvm-objdump 22 | llvm-pdbutil 23 | llvm-profdata 24 | llvm-ranlib 25 | llvm-readobj 26 | llvm-size 27 | llvm-strings 28 | llvm-strip 29 | llvm-symbolizer 30 | llvm-undname 31 | nm 32 | objcopy 33 | objdump 34 | ranlib 35 | readelf 36 | size 37 | strings 38 | CACHE STRING "") 39 | 40 | set(CLANG_TOOLS 41 | clang 42 | clangd 43 | # clangd-indexer 44 | clang-format 45 | clang-headers 46 | # clang-rename 47 | # clang-reorder-fields 48 | clang-tidy 49 | # modularize 50 | CACHE STRING "") 51 | 52 | set(LLD_TOOLS 53 | lld 54 | CACHE STRING "") 55 | 56 | set(LLDB_TOOLS 57 | liblldb 58 | lldb 59 | lldb-argdumper 60 | lldb-server 61 | lldb-vscode 62 | repl_swift 63 | CACHE STRING "") 64 | 65 | set(SWIFT_INSTALL_COMPONENTS 66 | autolink-driver 67 | compiler 68 | clang-resource-dir-symlink 69 | editor-integration 70 | sourcekit-inproc 71 | CACHE STRING "") 72 | 73 | set(LLVM_DISTRIBUTION_COMPONENTS 74 | LTO 75 | IndexStore 76 | libclang 77 | libclang-headers 78 | libclang-python-bindings 79 | #libtapi 80 | #tapi-headers 81 | ${LLVM_TOOLCHAIN_TOOLS} 82 | ${CLANG_TOOLS} 83 | ${LLD_TOOLS} 84 | ${LLDB_TOOLS} 85 | ${SWIFT_INSTALL_COMPONENTS} 86 | CACHE STRING "") 87 | -------------------------------------------------------------------------------- /cmake/modules/WindowsCompileRules.cmake: -------------------------------------------------------------------------------- 1 | # macOS paths usually start with /Users/*. Unfortunately, clang-cl interprets 2 | # paths starting with /U as macro undefines, so we need to put a -- before the 3 | # input file path to force it to be treated as a path. CMake's compilation rules 4 | # should be tweaked accordingly, but until that's done, and to support older 5 | # CMake versions, overriding compilation rules works well enough. This file will 6 | # be included by cmake after the default compilation rules have already been set 7 | # up, so we can just modify them instead of duplicating them entirely. 8 | string(REPLACE "-c " "-c -- " CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}") 9 | string(REPLACE "-c " "-c -- " CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}") 10 | string(REPLACE "-c " "-c -- " CMAKE_ASM_COMPILE_OBJECT "${CMAKE_ASM_COMPILE_OBJECT}") 11 | 12 | -------------------------------------------------------------------------------- /cmake/modules/WindowsSDK.cmake: -------------------------------------------------------------------------------- 1 | 2 | function(windows_arch_spelling arch var) 3 | if(${arch} STREQUAL i686) 4 | set(${var} x86 PARENT_SCOPE) 5 | elseif(${arch} STREQUAL x86_64) 6 | set(${var} x64 PARENT_SCOPE) 7 | elseif(${arch} STREQUAL armv7) 8 | set(${var} arm PARENT_SCOPE) 9 | elseif(${arch} STREQUAL aarch64) 10 | set(${var} arm64 PARENT_SCOPE) 11 | else() 12 | message(FATAL_ERROR "do not know MSVC spelling for ARCH: `${arch}`") 13 | endif() 14 | endfunction() 15 | 16 | function(windows_include_path_for_arch arch var) 17 | set(${var} 18 | "${VCToolsInstallDir}/include" 19 | "${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt" 20 | "${UniversalCRTSdkDir}/Include/${UCRTVersion}/shared" 21 | "${UniversalCRTSdkDir}/Include/${UCRTVersion}/um" 22 | PARENT_SCOPE) 23 | endfunction() 24 | 25 | function(windows_library_path_for_arch arch var) 26 | set(paths) 27 | 28 | # NOTE(compnerd) provide compatibility with VS2015 which had the libraries in 29 | # a directory called "Lib" rather than VS2017 which normalizes the layout and 30 | # places them in a directory named "lib". 31 | if(IS_DIRECTORY "${VCToolsInstallDir}/Lib") 32 | if(${arch} STREQUAL x86) 33 | list(APPEND paths "${VCToolsInstallDir}/Lib/") 34 | else() 35 | list(APPEND paths "${VCToolsInstallDir}/Lib/${arch}") 36 | endif() 37 | else() 38 | list(APPEND paths "${VCToolsInstallDir}/lib/${arch}") 39 | endif() 40 | 41 | list(APPEND paths 42 | "${UniversalCRTSdkDir}/Lib/${UCRTVersion}/ucrt/${arch}" 43 | "${UniversalCRTSdkDir}/Lib/${UCRTVersion}/um/${arch}") 44 | 45 | set(${var} "${paths}" PARENT_SCOPE) 46 | endfunction() 47 | 48 | function(windows_compute_compile_flags variable) 49 | windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} arch) 50 | windows_include_path_for_arch(${arch} paths) 51 | 52 | set(compile_flags "-D_CRT_SECURE_NO_WARNINGS --target=${CMAKE_SYSTEM_PROCESSOR}-unknown-windows-msvc ") 53 | foreach(path ${paths}) 54 | list(APPEND compile_flags "-imsvc ${path} ") 55 | endforeach() 56 | 57 | string(REPLACE ";" " " compile_flags ${compile_flags}) 58 | set(${variable} "${compile_flags}" PARENT_SCOPE) 59 | endfunction() 60 | 61 | function(windows_compute_link_flags variable) 62 | windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} arch) 63 | windows_library_path_for_arch(${arch} paths) 64 | 65 | set(link_flags) 66 | foreach(path ${paths}) 67 | list(APPEND link_flags "-libpath:${path} ") 68 | endforeach() 69 | 70 | string(REPLACE ";" " " link_flags ${link_flags}) 71 | set(${variable} "${link_flags}" PARENT_SCOPE) 72 | endfunction() 73 | 74 | function(windows_create_vfs_overlay flags) 75 | # TODO(compnerd) use a target to avoid re-creating this file all the time 76 | configure_file("${TOOLCHAIN_SOURCE_DIR}/infrastructure/WindowsSDKVFSOverlay.yaml.in" 77 | "${CMAKE_BINARY_DIR}/windows-sdk-vfs-overlay.yaml" 78 | @ONLY) 79 | 80 | set(${flags} 81 | "-Xclang -ivfsoverlay -Xclang ${CMAKE_BINARY_DIR}/windows-sdk-vfs-overlay.yaml" 82 | PARENT_SCOPE) 83 | endfunction() 84 | 85 | function(windows_create_lib_overlay flags) 86 | set(overlay ${CMAKE_BINARY_DIR}/WindowsSDKLibraryOverlay) 87 | 88 | execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${overlay}) 89 | 90 | windows_arch_spelling(${CMAKE_SYSTEM_PROCESSOR} arch) 91 | set(from ${UniversalCRTSdkDir}/Lib/${UCRTVersion}/um/${arch}) 92 | file(GLOB libraries RELATIVE "${from}" "${from}/*") 93 | foreach(library ${libraries}) 94 | string(TOLOWER ${library} library_downcase) 95 | if(NOT library STREQUAL library_downcase) 96 | execute_process(COMMAND 97 | ${CMAKE_COMMAND} -E create_symlink ${from}/${library} ${overlay}/${library_downcase}) 98 | endif() 99 | 100 | get_filename_component(name_we ${library} NAME_WE) 101 | get_filename_component(ext ${library} EXT) 102 | string(TOLOWER ${ext} ext_downcase) 103 | set(library_ext_downcase ${name_we}${ext_downcase}) 104 | if(NOT library STREQUAL library_ext_downcase AND 105 | NOT library_downcase STREQUAL library_ext_downcase) 106 | execute_process(COMMAND 107 | ${CMAKE_COMMAND} -E create_symlink ${from}/${library} ${overlay}/${library_ext_downcase}) 108 | endif() 109 | endforeach() 110 | 111 | set(${flags} -libpath:${overlay} PARENT_SCOPE) 112 | endfunction() 113 | 114 | -------------------------------------------------------------------------------- /cmake/scripts/GetLLVMVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(${BUILD_DIR}/lib/cmake/llvm/LLVMConfigVersion.cmake) 3 | 4 | # NOTE(compnerd) message(STATUS ...) prints a `-- ` before the message, and 5 | # message() writes to stderr instead of stdout, so just echo manually 6 | execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${PACKAGE_VERSION}) 7 | -------------------------------------------------------------------------------- /cmake/toolchains/Toolchain-Linux-x86_64.cmake: -------------------------------------------------------------------------------- 1 | 2 | if($ENV{EXHERBO}) 3 | set(CMAKE_AR /usr/x86_64-unknown-linux-gnu/bin/llvm-ar CACHE FILEPATH "") 4 | set(CMAKE_C_COMPILER /usr/x86_64-unknown-linux-gnu/bin/clang CACHE FILEPATH "") 5 | set(CMAKE_CXX_COMPILER /usr/x86_64-unknown-linux-gnu/bin/clang++ CACHE FILEPATH "") 6 | set(CMAKE_LINKER /usr/x86_64-unknown-linux-gnu/bin/ld.lld CACHE FILEPATH "") 7 | set(CMAKE_RANLIB /usr/x86_64-unknown-linux-gnu/bin/llvm-ranlib CACHE FILEPATH "") 8 | else() 9 | set(CMAKE_AR /usr/bin/llvm-ar CACHE FILEPATH "") 10 | set(CMAKE_C_COMPILER /usr/bin/clang CACHE FILEPATH "") 11 | set(CMAKE_CXX_COMPILER /usr/bin/clang++ CACHE FILEPATH "") 12 | set(CMAKE_LINKER /usr/bin/ld.lld CACHE FILEPATH "") 13 | set(CMAKE_RANLIB /usr/bin/llvm-ranlib CACHE FILEPATH "") 14 | endif() 15 | 16 | -------------------------------------------------------------------------------- /cmake/toolchains/Toolchain-bootstrap.cmake: -------------------------------------------------------------------------------- 1 | 2 | get_filename_component(TOOLCHAIN_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR} REALPATH) 3 | get_filename_component(TOOLCHAIN_SOURCE_DIR ${TOOLCHAIN_SOURCE_DIR} DIRECTORY) 4 | get_filename_component(TOOLCHAIN_SOURCE_DIR ${TOOLCHAIN_SOURCE_DIR} DIRECTORY) 5 | get_filename_component(TOOLCHAIN_SOURCE_DIR ${TOOLCHAIN_SOURCE_DIR} DIRECTORY) 6 | get_filename_component(TOOLCHAIN_SOURCE_DIR ${TOOLCHAIN_SOURCE_DIR} DIRECTORY CACHE) 7 | 8 | list(APPEND CMAKE_MODULE_PATH 9 | ${TOOLCHAIN_SOURCE_DIR}/infrastructure/cmake/modules) 10 | 11 | set(toolchain 12 | ${TOOLCHAIN_SOURCE_DIR}/build/Release/${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_PROCESSOR}/Developer/Toolchains/unknown-Asserts-bootstrap.xctoolchain) 13 | 14 | if(CMAKE_SYSTEM_NAME MATCHES Windows) 15 | set(CMAKE_C_COMPILER ${toolchain}/usr/bin/clang-cl CACHE FILEPATH "") 16 | set(CMAKE_CXX_COMPILER ${toolchain}/usr/bin/clang-cl CACHE FILEPATH "") 17 | set(CMAKE_LINKER ${toolchain}/usr/bin/lld-link CACHE FILEPATH "") 18 | else() 19 | set(CMAKE_C_COMPILER ${toolchain}/usr/bin/clang CACHE FILEPATH "") 20 | set(CMAKE_CXX_COMPILER ${toolchain}/usr/bin/clang++ CACHE FILEPATH "") 21 | set(CMAKE_LINKER ${toolchain}/usr/bin/ld.lld CACHE FILEPATH "") 22 | endif() 23 | 24 | set(CMAKE_SWIFT_COMPILER ${toolchain}/usr/bin/swiftc CACHE FILEPATH "") 25 | 26 | set(CMAKE_AR ${toolchain}/usr/bin/llvm-ar CACHE FILEPATH "") 27 | set(CMAKE_RANLIB ${toolchain}/usr/bin/llvm-ranlib CACHE FILEPATH "") 28 | 29 | function(verify_windows_VCVAR var) 30 | if (NOT DEFINED "${var}" AND NOT DEFINED "ENV{${var}}") 31 | message(FATAL_ERROR "${var} environment variable must be set") 32 | endif() 33 | endfunction() 34 | 35 | if(CMAKE_SYSTEM_NAME STREQUAL Windows) 36 | 37 | verify_windows_VCVAR(VCToolsInstallDir) 38 | verify_windows_VCVAR(UniversalCRTSdkDir) 39 | verify_windows_VCVAR(UCRTVersion) 40 | 41 | set(VCToolsInstallDir $ENV{VCToolsInstallDir} CACHE STRING "") 42 | set(UniversalCRTSdkDir $ENV{UniversalCRTSdkDir} CACHE STRING "") 43 | set(UCRTVersion $ENV{UCRTVersion} CACHE STRING "") 44 | 45 | include(WindowsSDK) 46 | 47 | foreach(v CMAKE_C_FLAGS CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS 48 | CMAKE_SHARED_LINKER_FLAGS CMAKE_STATIC_LINKER_FLAGS) 49 | set(_${v}_INITIAL "${${v}}" CACHE STRING "") 50 | endforeach() 51 | 52 | windows_compute_compile_flags(flags) 53 | windows_create_vfs_overlay(overlay_flags) 54 | set(CMAKE_C_FLAGS "${_CMAKE_C_FLAGS_INITIAL} ${flags} ${overlay_flags}" CACHE STRING "" FORCE) 55 | set(CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS_INITIAL} ${flags} ${overlay_flags}" CACHE STRING "" FORCE) 56 | 57 | windows_compute_link_flags(flags) 58 | windows_create_lib_overlay(overlay_flags) 59 | set(CMAKE_EXE_LINKER_FLAGS "${_CMAKE_EXE_LINKER_FLAGS_INITIAL} -fuse-ld=lld /MANIFEST:NO ${flags} ${overlay_flags}" CACHE STRING "" FORCE) 60 | set(CMAKE_SHARED_LINKER_FLAGS "${_CMAKE_SHARED_LINKER_FLAGS_INITIAL} -fuse-ld=lld /MANIFEST:NO ${flags} ${overlay_flags}" CACHE STRING "" FORCE) 61 | set(CMAKE_STATIC_LINKER_FLAGS "${_CMAKE_STATIC_LINKER_FLAGS_INITIAL} ${flags} ${overlay_flags}" CACHE STRING "" FORCE) 62 | 63 | # CMake populates these with a bunch of unnecessary libraries. Ensure that 64 | # projects explicitly control which libraries they require. 65 | set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) 66 | set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "" FORCE) 67 | 68 | set(CMAKE_USER_MAKE_RULES_OVERRIDE "${TOOLCHAIN_SOURCE_DIR}/infrastructure/cmake/modules/WindowsCompileRules.cmake") 69 | endif() 70 | 71 | if(NOT CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME) 72 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 73 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 74 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 75 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 76 | endif() 77 | 78 | -------------------------------------------------------------------------------- /scripts/rebase.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function main() { 4 | local multiple_master_repositories=( llvm clang lldb ) 5 | local single_master_repositories=( clang-tools-extra lld cmark swift swift-corelibs-foundation swift-corelibs-libdispatch swift-corelibs-xctest swift-llbuild swift-package-manager swift-syntax ) 6 | local runtime_repositories=( compiler-rt libunwind libcxxabi libcxx openmp ) 7 | local toolchain_source=$(realpath -q $(dirname $(readlink -f ${0}))/../..) 8 | 9 | for repo in ${multiple_master_repositories[@]} ${single_master_repositories[@]} ; do 10 | local GIT_DIR=${toolchain_source}/${repo} 11 | if ! git -C ${GIT_DIR} diff --no-ext-diff --quiet || 12 | ! git -C ${GIT_DIR} diff --no-ext-diff --quiet --cached ; then 13 | echo "${repo} is dirty, aborting rebase" 14 | exit -1 15 | fi 16 | done 17 | 18 | for repo in ${multiple_master_repositories[@]} ; do 19 | local GIT_DIR=${toolchain_source}/${repo} 20 | 21 | git -C ${GIT_DIR} fetch -q upstream 22 | git -C ${GIT_DIR} fetch -q swift 23 | 24 | local master=$(git -C ${GIT_DIR} rev-parse HEAD) 25 | local swift_merge_point=$(git -C ${GIT_DIR} merge-base upstream/master swift/upstream-with-swift) 26 | local local_merge_point=$(git -C ${GIT_DIR} log --reverse --no-merges --grep 'git-svn-id' --invert-grep --oneline --pretty=%H $(git -C ${GIT_DIR} merge-base HEAD upstream/master)..HEAD ^swift/upstream-with-swift | head -n 1) 27 | [[ -n ${local_merge_point} ]] && echo "local changes: ${local_merge_point}..$(git -C ${GIT_DIR} rev-parse HEAD)" 28 | 29 | git -C ${GIT_DIR} checkout swift/upstream-with-swift || exit 253 30 | git -C ${GIT_DIR} rebase --no-stat --onto HEAD ${swift_merge_point}^ upstream/master || { 31 | sh -c "cd ${GIT_DIR}; exec /bin/sh" 32 | } 33 | if [[ -n ${local_merge_point} ]] ; then 34 | git -C ${GIT_DIR} rebase --onto HEAD ${local_merge_point}^ ${master} || { 35 | sh -c "cd ${GIT_DIR}; exec /bin/sh" 36 | } 37 | fi 38 | done 39 | 40 | for repo in ${single_master_repositories[@]} ; do 41 | local GIT_DIR=${toolchain_source}/${repo} 42 | git -C ${GIT_DIR} fetch -q upstream 43 | git -C ${GIT_DIR} rebase --no-stat upstream/master || exit 253 44 | done 45 | } 46 | 47 | main "${@}" 48 | 49 | --------------------------------------------------------------------------------