Skip to content

Commit e298a66

Browse files
authored
Merge branch 'apple:main' into fix-init-accessor-71578
2 parents faf1d2b + 03b0f0c commit e298a66

File tree

1,905 files changed

+64458
-23799
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,905 files changed

+64458
-23799
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
/include/swift/AST/*Substitution* @slavapestov
6363
/include/swift/AST/Evaluator* @CodaFi @slavapestov
6464
/include/swift/AST/DiagnosticsParse.def @ahoppen @bnbarham @CodaFi @DougGregor @hamishknight @rintaro
65-
/include/swift/ClangImporter @zoecarver @hyp @egorzhdan
65+
/include/swift/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder
6666
/include/swift/DependencyScan @artemcm
6767
/include/swift/Driver @artemcm
6868
# TODO: /include/swift/IRGen/
@@ -97,7 +97,7 @@
9797
/lib/AST/RequirementMachine/ @slavapestov
9898
/lib/ASTGen/ @ahoppen @bnbarham @CodaFi @hamishknight @rintaro
9999
/lib/Basic/Windows @compnerd
100-
/lib/ClangImporter @zoecarver @hyp @egorzhdan
100+
/lib/ClangImporter @zoecarver @hyp @egorzhdan @beccadax @ian-twilightcoder
101101
/lib/ClangImporter/DWARFImporter* @adrian-prantl
102102
/lib/DependencyScan @artemcm
103103
/lib/Driver @artemcm

CHANGELOG.md

Lines changed: 364 additions & 1 deletion
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,8 @@ option(SWIFT_TOOLS_LD64_LTO_CODEGEN_ONLY_FOR_SUPPORTING_TARGETS
341341
debugging Swift)"
342342
FALSE)
343343

344-
option(BOOTSTRAPPING_MODE [=[
344+
set(BOOTSTRAPPING_MODE HOSTTOOLS CACHE STRING [=[
345345
How to build the swift compiler modules. Possible values are
346-
OFF: build without swift modules
347346
HOSTTOOLS: build with a pre-installed toolchain
348347
BOOTSTRAPPING: build with a 2-stage bootstrapping process
349348
BOOTSTRAPPING-WITH-HOSTLIBS: build with a 2-stage bootstrapping process,
@@ -352,7 +351,7 @@ How to build the swift compiler modules. Possible values are
352351
`SWIFT_NATIVE_SWIFT_TOOLS_PATH` (non-Darwin only)
353352
CROSSCOMPILE-WITH-HOSTLIBS: build with a bootstrapping-with-hostlibs compiled
354353
compiler, provided in `SWIFT_NATIVE_SWIFT_TOOLS_PATH`
355-
]=] OFF)
354+
]=])
356355

357356
option(BRIDGING_MODE [=[
358357
How swift-C++ bridging code is compiled:
@@ -479,6 +478,21 @@ set(SWIFT_MIN_RUNTIME_VERSION "${DEFAULT_SWIFT_MIN_RUNTIME_VERSION}" CACHE STRIN
479478
the compiler itself. This is used on non-Darwin platforms to ensure \
480479
that it's possible to build the compiler using host tools.")
481480

481+
#
482+
# User-configurable Linux specific options.
483+
#
484+
485+
set(SWIFT_MUSL_PATH "/usr/local/musl" CACHE STRING
486+
"Path to the directory that contains the Musl headers and libraries. \
487+
This is only required if we have been asked to build the Musl SDK, and \
488+
defaults to the default install location for Musl.")
489+
490+
set(SWIFT_SDK_LINUX_STATIC_ARCHITECTURES "" CACHE STRING
491+
"The architectures to configure when using the static Linux SDK.")
492+
493+
set(SWIFT_SDK_LINUX_ARCHITECTURES "" CACHE STRING
494+
"The architectures to configure when using the Linux SDK.")
495+
482496
#
483497
# User-configurable Android specific options.
484498
#
@@ -618,6 +632,9 @@ option(SWIFT_STDLIB_ENABLE_OBJC_INTEROP
618632
"Should stdlib be built with Obj-C interop."
619633
"${SWIFT_STDLIB_ENABLE_OBJC_INTEROP_default}")
620634

635+
set(SWIFT_DEBUGINFO_NON_LTO_ARGS "-g" CACHE STRING
636+
"Compiler options to use when building the compiler in debug or debuginfo mode. These do not apply when linking with LTO")
637+
621638
#
622639
# User-configurable experimental options. Do not use in production builds.
623640
#
@@ -898,12 +915,20 @@ set(SWIFT_MAIN_INCLUDE_DIR "${SWIFT_SOURCE_DIR}/include")
898915
set(SWIFT_SHIMS_INCLUDE_DIR "${SWIFT_SOURCE_DIR}/stdlib/public/SwiftShims")
899916
set(SWIFT_INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")
900917

918+
if (NOT BOOTSTRAPPING_MODE)
919+
message(FATAL_ERROR "turning off bootstrapping is not supported anymore")
920+
endif()
921+
901922
set(SWIFT_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
902923
set(SWIFT_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
903924
if("${SWIFT_NATIVE_SWIFT_TOOLS_PATH}" STREQUAL "")
904925
# This is the normal case. We are not cross-compiling.
905926
set(SWIFT_NATIVE_SWIFT_TOOLS_PATH "${SWIFT_RUNTIME_OUTPUT_INTDIR}")
906927
set(SWIFT_EXEC_FOR_SWIFT_MODULES "${CMAKE_Swift_COMPILER}")
928+
if(NOT SWIFT_EXEC_FOR_SWIFT_MODULES)
929+
message(WARNING "BOOSTRAPPING set to OFF because no Swift compiler is defined")
930+
set(BOOTSTRAPPING_MODE "OFF")
931+
endif()
907932
elseif(BOOTSTRAPPING_MODE MATCHES "BOOTSTRAPPING.*")
908933
# If cross-compiling, we don't have to bootstrap. We can just use the previously
909934
# built native swiftc to build the swift compiler modules.
@@ -983,6 +1008,8 @@ endif()
9831008
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
9841009
# our own defaults. This should only be possible in a unified (not stand alone)
9851010
# build environment.
1011+
include(GoldVersion)
1012+
9861013
if(LLVM_USE_LINKER)
9871014
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
9881015
elseif(SWIFT_HOST_VARIANT_SDK STREQUAL "ANDROID")
@@ -994,7 +1021,17 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
9941021
elseif(DISTRO_NAME STREQUAL "Amazon Linux 2023")
9951022
set(SWIFT_USE_LINKER_default "lld")
9961023
else()
997-
set(SWIFT_USE_LINKER_default "gold")
1024+
get_gold_version(gold_version)
1025+
if(NOT gold_version)
1026+
message(STATUS "GNU Gold not found; using lld instead")
1027+
set(SWIFT_USE_LINKER_default "lld")
1028+
elseif(gold_version VERSION_LESS "2.36")
1029+
message(STATUS "GNU Gold is too old (${gold_version}); using lld instead")
1030+
set(SWIFT_USE_LINKER_default "lld")
1031+
else()
1032+
message(STATUS "Using GNU Gold ${gold_version}")
1033+
set(SWIFT_USE_LINKER_default "gold")
1034+
endif()
9981035
endif()
9991036
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
10001037
"Build Swift with a non-default linker")
@@ -1076,12 +1113,26 @@ if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
10761113
set(SWIFT_HOST_VARIANT "linux" CACHE STRING
10771114
"Deployment OS for Swift host tools (the compiler) [linux].")
10781115

1079-
# Should we build the standard library for the host?
10801116
is_sdk_requested(LINUX swift_build_linux)
10811117
if(swift_build_linux)
1082-
configure_sdk_unix("Linux" "${SWIFT_HOST_VARIANT_ARCH}")
1083-
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
1084-
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
1118+
if("${SWIFT_SDK_LINUX_ARCHITECTURES}" STREQUAL "")
1119+
set(SWIFT_SDK_LINUX_ARCHITECTURES "${SWIFT_HOST_VARIANT_ARCH}")
1120+
endif()
1121+
1122+
configure_sdk_unix("Linux" "${SWIFT_SDK_LINUX_ARCHITECTURES}")
1123+
endif()
1124+
1125+
is_sdk_requested(LINUX_STATIC swift_build_linux_static)
1126+
if(swift_build_linux_static)
1127+
if("${SWIFT_MUSL_PATH}" STREQUAL "")
1128+
message(FATAL_ERROR "You must set SWIFT_MUSL_PATH to point to the Musl libraries and headers. Specifically, we expect to find Musl at <SWIFT_MUSL_PATH>/<arch> for each requested architecture.")
1129+
endif()
1130+
1131+
if("${SWIFT_SDK_LINUX_STATIC_ARCHITECTURES}" STREQUAL "")
1132+
set(SWIFT_SDK_LINUX_STATIC_ARCHITECTURES "aarch64;x86_64")
1133+
endif()
1134+
1135+
configure_sdk_unix("Linux_Static" "${SWIFT_SDK_LINUX_STATIC_ARCHITECTURES}")
10851136
endif()
10861137

10871138
is_sdk_requested(FREESTANDING swift_build_freestanding)
@@ -1090,6 +1141,10 @@ if("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "LINUX")
10901141
# configure_sdk_unix("FREESTANDING" "${SWIFT_HOST_VARIANT_ARCH}")
10911142
endif()
10921143

1144+
# Default is Linux SDK for host
1145+
set(SWIFT_PRIMARY_VARIANT_SDK_default "${SWIFT_HOST_VARIANT_SDK}")
1146+
set(SWIFT_PRIMARY_VARIANT_ARCH_default "${SWIFT_HOST_VARIANT_ARCH}")
1147+
10931148
elseif("${SWIFT_HOST_VARIANT_SDK}" STREQUAL "FREEBSD")
10941149

10951150
set(SWIFT_HOST_VARIANT "freebsd" CACHE STRING

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
| | **Architecture** | **Build** |
1010
|---|:---:|:---:|
1111
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-macos)|
12-
| **Ubuntu 18.04** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04)|
1312
| **Ubuntu 20.04** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|
1413
| **Ubuntu 20.04** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04-aarch64)|
1514
| **Ubuntu 22.04** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-22_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-22_04)|
@@ -18,6 +17,12 @@
1817
| **Amazon Linux 2** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2)|
1918
| **Amazon Linux 2** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2-aarch64)|
2019
| **Universal Base Image 9** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-ubi-9/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubi-9)|
20+
| **Debian 12** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-debian-12/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-debian-12)|
21+
| **Debian 12** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-debian-12-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-debian-12-aarch64)|
22+
| **Fedora 39** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-fedora-39/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-fedora-39)|
23+
| **Fedora 39** | AArch64 |[![Build Status](https://ci.swift.org/job/oss-swift-package-fedora-39-aarch64/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-fedora-39-aarch64)|
24+
| **Windows 10** | x86_64 |[![Build Status](https://ci-external.swift.org/job/swift-main-windows-toolchain/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/swift-main-windows-toolchain)|
25+
| **Windows 10** | ARM64 |[![Build Status](https://ci-external.swift.org/job/swift-main-windows-toolchain-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/swift-main-windows-toolchain-arm64)|
2126

2227
**Cross-Compilation Targets**
2328

SwiftCompilerSources/CMakeLists.txt

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ function(add_swift_compiler_modules_library name)
106106
"-Xcc" "-std=c++17"
107107
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
108108
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
109+
109110
# Prior to 5.9, we have to use the experimental flag for C++ interop.
110111
if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.9)
111112
list(APPEND swift_compile_options "-Xfrontend" "-enable-experimental-cxx-interop")
@@ -120,6 +121,11 @@ function(add_swift_compiler_modules_library name)
120121
"-Xfrontend" "${SWIFT_MIN_RUNTIME_VERSION}")
121122
endif()
122123
list(APPEND swift_compile_options "-Xfrontend" "-disable-implicit-string-processing-module-import")
124+
125+
# We cannot use Unsafe*Pointer when importing C++ move-only types until the
126+
# host libraries are updated to Swift 6.0, because that importing strategy
127+
# requires _Pointer have its Pointee: ~Copyable. (rdar://128013193)
128+
list(APPEND swift_compile_options "-Xfrontend" "-cxx-interop-use-opaque-pointer-for-moveonly")
123129
endif()
124130

125131
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -167,7 +173,17 @@ function(add_swift_compiler_modules_library name)
167173
# under `include/swift`. These are either located next to the compiler (in case of open source toolchains) or
168174
# in the SDK (in case a Swift compiler from Xcode)
169175
get_filename_component(swift_exec_bin_dir ${ALS_SWIFT_EXEC} DIRECTORY)
170-
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
176+
177+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
178+
list(APPEND swift_compile_options "-static")
179+
list(APPEND sdk_option "-sdk" "${SWIFT_PATH_TO_SWIFT_SDK}")
180+
181+
# Workaround a crash in the LoadableByAddress pass
182+
# https://github.com/apple/swift/issues/73254
183+
list(APPEND swift_compile_options "-Xllvm" "-sil-disable-pass=loadable-address")
184+
else()
185+
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
186+
endif()
171187

172188
set(all_obj_files)
173189
set(all_module_targets)
@@ -193,11 +209,20 @@ function(add_swift_compiler_modules_library name)
193209
endforeach()
194210
endif()
195211

196-
set(module_obj_file "${build_dir}/${module}.o")
212+
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT SWIFT_HOST_VARIANT_SDK IN_LIST SWIFT_DARWIN_PLATFORMS)
213+
# swift-driver when non-optimizing in not Mach-O platforms adds an extra
214+
# job wrapmodule that uses the {module-name}.o as output, which clashes
215+
# with the name chosen here. Use a different name in those cases.
216+
set(module_obj_file "${build_dir}/${module}.object.o")
217+
set(output_obj_files "${module_obj_file}" "${build_dir}/${module}.o")
218+
else()
219+
set(module_obj_file "${build_dir}/${module}.o")
220+
set(output_obj_files "${module_obj_file}")
221+
endif()
197222
set(module_file "${build_dir}/${module}.swiftmodule")
198223
list(APPEND all_module_files ${module_file})
199224

200-
set(all_obj_files ${all_obj_files} ${module_obj_file})
225+
list(APPEND all_obj_files ${output_obj_files})
201226
set(c_include_paths
202227
# LLVM modules and headers.
203228
"${LLVM_MAIN_INCLUDE_DIR}"
@@ -226,7 +251,7 @@ function(add_swift_compiler_modules_library name)
226251
${c_include_paths_args}
227252
# Generated swift modules.
228253
"-I" "${build_dir}"
229-
OUTPUT ${module_obj_file}
254+
OUTPUT ${output_obj_files}
230255
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
231256
DEPENDS ${sources} ${deps} ${ALS_DEPENDS}
232257
importedHeaderDependencies
@@ -249,6 +274,9 @@ function(add_swift_compiler_modules_library name)
249274
add_library(${name} STATIC ${all_obj_files})
250275
add_dependencies(${name} ${all_module_targets})
251276
set_target_properties(${name} PROPERTIES LINKER_LANGUAGE CXX)
277+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
278+
target_link_libraries(${name} PUBLIC swiftSwiftOnoneSupport)
279+
endif()
252280

253281
# Downstream linking should include the swiftmodule in debug builds to allow lldb to
254282
# work correctly. Only do this on Darwin since neither gold (currently used by default

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
@_exported import BasicBridging
14-
import CxxStdlib
1514

1615
/// The assert function to be used in the compiler.
1716
///
@@ -52,6 +51,9 @@ public extension NoReflectionChildren {
5251
var customMirror: Mirror { Mirror(self, children: []) }
5352
}
5453

54+
#if !os(Windows)
55+
// TODO: https://github.com/apple/swift/issues/73252
56+
5557
public var standardError = CFileStream(fp: stderr)
5658

5759
#if os(Android) || canImport(Musl)
@@ -72,6 +74,8 @@ public struct CFileStream: TextOutputStream {
7274
}
7375
}
7476

77+
#endif
78+
7579
//===----------------------------------------------------------------------===//
7680
// StringRef
7781
//===----------------------------------------------------------------------===//

SwiftCompilerSources/Sources/Optimizer/DataStructures/InstructionRange.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import SIL
2020
/// One or more "potential" end instructions can be inserted.
2121
/// Though, not all inserted instructions end up as "end" instructions.
2222
///
23-
/// `InstructionRange` is useful for calculating the liferange of values.
23+
/// `InstructionRange` is useful for calculating the liverange of values.
2424
///
2525
/// The `InstructionRange` is similar to a `BasicBlockRange`, but defines the range
2626
/// in a "finer" granularity, i.e. on instructions instead of blocks.

0 commit comments

Comments
 (0)