Skip to content

Commit 42f50eb

Browse files
Resolving conflicts
2 parents 9e64ee5 + 1224e90 commit 42f50eb

File tree

416 files changed

+47510
-48650
lines changed

Some content is hidden

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

416 files changed

+47510
-48650
lines changed

CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,18 @@ include(CMakePushCheckState)
499499

500500
print_versions()
501501

502+
include(SwiftSharedCMakeConfig)
503+
504+
# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake
505+
# functionality.
506+
# Support building Swift as a standalone project, using LLVM as an
507+
# external library.
508+
if(SWIFT_BUILT_STANDALONE)
509+
swift_common_standalone_build_config(SWIFT)
510+
else()
511+
swift_common_unified_build_config(SWIFT)
512+
endif()
513+
502514
include(SwiftComponents)
503515
include(SwiftHandleGybSources)
504516
include(SwiftSetIfArchBitness)
@@ -527,16 +539,6 @@ if(NOT CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_PROCESSOR STREQUAL "i386")
527539
OUTPUT_STRIP_TRAILING_WHITESPACE)
528540
endif()
529541

530-
include(SwiftSharedCMakeConfig)
531-
532-
# Support building Swift as a standalone project, using LLVM as an
533-
# external library.
534-
if(SWIFT_BUILT_STANDALONE)
535-
swift_common_standalone_build_config(SWIFT)
536-
else()
537-
swift_common_unified_build_config(SWIFT)
538-
endif()
539-
540542
get_filename_component(SWIFT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
541543
set(SWIFT_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
542544
set(SWIFT_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
@@ -1051,6 +1053,7 @@ if(SWIFT_NEED_EXPLICIT_LIBDISPATCH)
10511053
else()
10521054
set(SOURCEKIT_RUNTIME_DIR lib)
10531055
endif()
1056+
add_dependencies(sourcekit-inproc BlocksRuntime dispatch)
10541057
swift_install_in_component(FILES
10551058
$<TARGET_FILE:dispatch>
10561059
$<TARGET_FILE:BlocksRuntime>

apinotes/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ add_custom_target("copy_apinotes" ALL
2626
COMMENT "Copying API notes to ${output_dir}"
2727
SOURCES "${sources}")
2828

29+
add_dependencies(compiler copy_apinotes)
2930
swift_install_in_component(DIRECTORY "${output_dir}"
3031
DESTINATION "lib/swift/"
3132
COMPONENT compiler)

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ set(SWIFT_BENCH_MODULES
151151
single-source/SetTests
152152
single-source/SevenBoom
153153
single-source/Sim2DArray
154+
single-source/SortArrayInClass
154155
single-source/SortIntPyramids
155156
single-source/SortLargeExistentials
156157
single-source/SortLettersInPlace

benchmark/README.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,17 @@ The following build options are available:
7070

7171
The following build targets are available:
7272

73-
1. `swift-benchmark-macosx-x86_64`
74-
2. `swift-benchmark-iphoneos-arm64`
75-
3. `swift-benchmark-iphoneos-armv7`
76-
4. `swift-benchmark-appletvos-arm64`
77-
5. `swift-benchmark-watchos-armv7k`
73+
* `swift-benchmark-macosx-x86_64`
74+
* `swift-benchmark-iphoneos-arm64`
75+
* `swift-benchmark-iphoneos-armv7`
76+
* `swift-benchmark-appletvos-arm64`
77+
* `swift-benchmark-watchos-armv7k`
7878

7979
Build steps (with example options):
8080

81-
1. `$ cd benchmark`
82-
2. `$ mkdir build`
83-
3. `$ cd build`
84-
4. `$ cmake ../benchmark -G Ninja -DSWIFT_EXEC=[path to built swiftc]`
85-
5. `$ ninja swift-benchmark-macosx-x86_64`
81+
1. `$ mkdir build; cd build`
82+
2. `$ cmake [path to swift src]/benchmark -G Ninja -DSWIFT_EXEC=[path to built swiftc]`
83+
3. `$ ninja swift-benchmark-macosx-x86_64`
8684

8785
Benchmark binaries are placed in `bin`.
8886

@@ -96,12 +94,12 @@ relative to the benchmark binary at the time it was executed
9694
For example, to benchmark against a locally built `swiftc`, including
9795
any standard library changes in that build, you might configure using:
9896

99-
cmake ../benchmark -G Ninja -DSWIFT_EXEC=<src>/swift/build/swift-macosx-x86_64/bin/swiftc
97+
cmake <src>/benchmark -G Ninja -DSWIFT_EXEC=<build>/swift-macosx-x86_64/bin/swiftc
10098
ninja swift-benchmark-iphoneos-arm64
10199

102100
To build against the installed Xcode, simply omit SWIFT_EXEC:
103101

104-
cmake ../benchmark -G Ninja
102+
cmake <src>/benchmark -G Ninja
105103
ninja swift-benchmark-iphoneos-arm64
106104

107105
In both examples above, to run the benchmarks on a device, the dynamic
@@ -110,7 +108,7 @@ relative to `swiftc`. To benchmark against the target machine's
110108
installed libraries instead, enable
111109
`SWIFT_BENCHMARK_USE_OS_LIBRARIES`.
112110

113-
cmake ../benchmark -G Ninja -DSWIFT_BENCHMARK_USE_OS_LIBRARIES=ON
111+
cmake <src>/benchmark -G Ninja -DSWIFT_BENCHMARK_USE_OS_LIBRARIES=ON
114112
ninja swift-benchmark-iphoneos-arm64
115113

116114
This will reflect the performance of the Swift standard library
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//===--- SortArrayInClass.swift -------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
// This benchmark is derived from user code that encoutered a major
12+
// performance problem in normal usage. Contributed by Saleem
13+
// Abdulrasool (compnerd).
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
import TestsUtils
18+
19+
// Specifically tests efficient access to Array subscript when the
20+
// array is a class property, but also generally tests quicksort in a
21+
// class which needs a slew of array optimizations, uniqueness, bounds
22+
// and exclusivity optimizations.
23+
public let SortArrayInClass = [
24+
BenchmarkInfo(
25+
name: "SortArrayInClass",
26+
runFunction: run_SortArrayInClass,
27+
tags: [.abstraction, .safetychecks, .exclusivity, .algorithm, .api, .Array])
28+
]
29+
30+
let LARGE_ARRAY_SIZE = 10000
31+
32+
class Sorter {
33+
var array: [Int]
34+
init(size: Int) {
35+
array = Array((0..<size).reversed())
36+
}
37+
38+
private func _swap(i: Int, j: Int) {
39+
let t = array[i]
40+
// This currently copies the entire array. Assigning to a
41+
// temporary, or using swapAt would avoid the copy, but users
42+
// shouldn't need to know that.
43+
array[i] = array[j]
44+
array[j] = t
45+
}
46+
47+
private func _quicksort(left: Int, right: Int) {
48+
49+
if left < right {
50+
let pivot = array[left + ((right - left) / 2)]
51+
var left_new = left
52+
var right_new = right
53+
54+
repeat {
55+
while array[left_new] < pivot {
56+
left_new += 1
57+
}
58+
while pivot < array[right_new] {
59+
right_new -= 1
60+
}
61+
if left_new <= right_new {
62+
_swap(i:left_new, j:right_new)
63+
left_new += 1
64+
right_new -= 1
65+
}
66+
} while left_new <= right_new
67+
68+
_quicksort(left: left, right: right_new)
69+
_quicksort(left: left_new, right:right)
70+
}
71+
}
72+
73+
func quicksort() {
74+
_quicksort(left:0, right:array.count - 1);
75+
}
76+
}
77+
78+
public func run_SortArrayInClass(_ N: Int) {
79+
for _ in 1...N {
80+
// The array needs to be reinitialized before each sort, so it
81+
// can't be a setup/tearDown function.
82+
let sorter = Sorter(size:LARGE_ARRAY_SIZE)
83+
sorter.quicksort()
84+
}
85+
}

benchmark/utils/TestsUtils.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public enum BenchmarkCategory : String {
2828
case runtime, refcount, metadata
2929
// Other general areas of compiled code validation.
3030
case abstraction, safetychecks, exceptions, bridging, concurrency, existential
31+
case exclusivity
3132

3233
// Algorithms are "micro" that test some well-known algorithm in isolation:
3334
// sorting, searching, hashing, fibonaci, crypto, etc.

benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ import SequenceAlgos
146146
import SetTests
147147
import SevenBoom
148148
import Sim2DArray
149+
import SortArrayInClass
149150
import SortIntPyramids
150151
import SortLargeExistentials
151152
import SortLettersInPlace
@@ -325,6 +326,7 @@ registerBenchmark(SequenceAlgos)
325326
registerBenchmark(SetTests)
326327
registerBenchmark(SevenBoom)
327328
registerBenchmark(Sim2DArray)
329+
registerBenchmark(SortArrayInClass)
328330
registerBenchmark(SortIntPyramids)
329331
registerBenchmark(SortLargeExistentials)
330332
registerBenchmark(SortLettersInPlace)

cmake/modules/AddSwift.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ function(add_swift_host_library name)
15061506
INSTALL_IN_COMPONENT "dev"
15071507
)
15081508

1509+
add_dependencies(dev ${name})
15091510
if(NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
15101511
swift_install_in_component(TARGETS ${name}
15111512
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT dev
@@ -2117,6 +2118,7 @@ function(add_swift_target_library name)
21172118
endif()
21182119

21192120
if(sdk STREQUAL WINDOWS AND CMAKE_SYSTEM_NAME STREQUAL Windows)
2121+
add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${name}-windows-${SWIFT_PRIMARY_VARIANT_ARCH})
21202122
swift_install_in_component(TARGETS ${name}-windows-${SWIFT_PRIMARY_VARIANT_ARCH}
21212123
RUNTIME
21222124
DESTINATION "bin"
@@ -2129,6 +2131,9 @@ function(add_swift_target_library name)
21292131
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
21302132
PERMISSIONS ${file_permissions})
21312133
else()
2134+
# NOTE: ${UNIVERSAL_LIBRARY_NAME} is the output associated with the target
2135+
# ${lipo_target}
2136+
add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${lipo_target})
21322137
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
21332138
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}"
21342139
COMPONENT "${SWIFTLIB_INSTALL_IN_COMPONENT}"
@@ -2139,6 +2144,7 @@ function(add_swift_target_library name)
21392144
foreach(arch ${SWIFT_SDK_WINDOWS_ARCHITECTURES})
21402145
if(TARGET ${name}-windows-${arch}_IMPLIB)
21412146
get_target_property(import_library ${name}-windows-${arch}_IMPLIB IMPORTED_LOCATION)
2147+
add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${name}-windows-${arch}_IMPLIB)
21422148
swift_install_in_component(FILES ${import_library}
21432149
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${arch}"
21442150
COMPONENT ${SWIFTLIB_INSTALL_IN_COMPONENT}
@@ -2205,6 +2211,7 @@ function(add_swift_target_library name)
22052211
OUTPUT
22062212
"${UNIVERSAL_LIBRARY_NAME}"
22072213
${THIN_INPUT_TARGETS_STATIC})
2214+
add_dependencies(${SWIFTLIB_INSTALL_IN_COMPONENT} ${lipo_target_static})
22082215
swift_install_in_component(FILES "${UNIVERSAL_LIBRARY_NAME}"
22092216
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${install_subdir}/${resource_dir_sdk_subdir}"
22102217
PERMISSIONS
@@ -2406,6 +2413,7 @@ function(add_swift_host_tool executable)
24062413
ARCHITECTURE ${SWIFT_HOST_VARIANT_ARCH}
24072414
${ASHT_UNPARSED_ARGUMENTS})
24082415

2416+
add_dependencies(${ASHT_SWIFT_COMPONENT} ${executable})
24092417
swift_install_in_component(TARGETS ${executable}
24102418
RUNTIME
24112419
DESTINATION bin

cmake/modules/SwiftComponents.cmake

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,23 @@ macro(swift_configure_components)
9292
"A semicolon-separated list of components to install from the set ${_SWIFT_DEFINED_COMPONENTS}")
9393

9494
foreach(component ${_SWIFT_DEFINED_COMPONENTS})
95+
add_custom_target(${component})
96+
add_llvm_install_targets(install-${component}
97+
DEPENDS ${component}
98+
COMPONENT ${component})
99+
95100
string(TOUPPER "${component}" var_name_piece)
96101
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
97102
set(SWIFT_INSTALL_${var_name_piece} FALSE)
98103
endforeach()
99104

105+
# NOTE: never_install is a dummy component to indicate something should not
106+
# be installed. We explicitly do not add an install target for this.
107+
add_custom_target(never_install)
108+
109+
add_custom_target(swift-components)
110+
add_custom_target(install-swift-components)
111+
100112
foreach(component ${SWIFT_INSTALL_COMPONENTS})
101113
if(NOT "${component}" IN_LIST _SWIFT_DEFINED_COMPONENTS)
102114
message(FATAL_ERROR "unknown install component: ${component}")
@@ -106,6 +118,8 @@ macro(swift_configure_components)
106118
string(REPLACE "-" "_" var_name_piece "${var_name_piece}")
107119
if(NOT SWIFT_INSTALL_EXCLUDE_${var_name_piece})
108120
set(SWIFT_INSTALL_${var_name_piece} TRUE)
121+
add_dependencies(swift-components ${component})
122+
add_dependencies(install-swift-components install-${component})
109123
endif()
110124
endforeach()
111125
endmacro()
@@ -173,6 +187,10 @@ function(swift_install_symlink_component component)
173187
precondition(INSTALL_SYMLINK
174188
MESSAGE "LLVMInstallSymlink script must be available.")
175189

190+
# Create the directory if it doesn't exist. It will fail to create a symlink
191+
# otherwise.
192+
install(DIRECTORY DESTINATION "${ARG_DESTINATION}" COMPONENT ${component})
176193
install(SCRIPT ${INSTALL_SYMLINK}
177-
CODE "install_symlink(${ARG_LINK_NAME} ${ARG_TARGET} ${ARG_DESTINATION})")
194+
CODE "install_symlink(${ARG_LINK_NAME} ${ARG_TARGET} ${ARG_DESTINATION})"
195+
COMPONENT ${component})
178196
endfunction()

cmake/modules/SwiftManpage.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function(manpage)
2727
"${CMAKE_CURRENT_BINARY_DIR}/${MP_MAN_FILE_BASENAME}.${MP_MAN_SECTION}")
2828

2929
add_custom_command_target(
30-
unused_var
30+
manpage_target
3131
COMMAND
3232
"${POD2MAN}" "--section" "${MP_MAN_SECTION}"
3333
"--center" "${MP_PAGE_HEADER}" "--release=\"swift ${SWIFT_VERSION}\""
@@ -38,6 +38,7 @@ function(manpage)
3838
DEPENDS "${MP_SOURCE}"
3939
ALL)
4040

41+
add_dependencies(${MP_INSTALL_IN_COMPONENT} ${manpage_target})
4142
swift_install_in_component(FILES "${output_file_name}"
4243
DESTINATION "share/man/man${MP_MAN_SECTION}"
4344
COMPONENT "${MP_INSTALL_IN_COMPONENT}")

cmake/modules/SwiftSource.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ function(_compile_swift_files
229229
# The standard library and overlays are always built resiliently.
230230
if(SWIFTFILE_IS_STDLIB)
231231
list(APPEND swift_flags "-enable-library-evolution")
232+
list(APPEND swift_flags "-Xfrontend" "-enable-ownership-stripping-after-serialization")
232233
endif()
233234

234235
if(SWIFT_STDLIB_USE_NONATOMIC_RC)

docs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ if (DOXYGEN_FOUND)
6868
add_dependencies(doxygen doxygen-swift)
6969
endif()
7070

71+
add_dependencies(dev doxygen-swift)
7172
swift_install_in_component(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/doxygen/html"
7273
DESTINATION "docs/html"
7374
COMPONENT dev)

docs/Diagnostics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Most diagnostics have no reason to change behavior under editor mode. An example
9797

9898
- `%0`, `%1`, etc - Formats the specified diagnostic argument based on its type.
9999

100-
- `%select{a|b|c}0` - Chooses from a list of alternatives, separated by vertical bars, based on the value of the given argument. In this example, a value of 2 in diagnostic argument 0 would result in "c" being output.
100+
- `%select{a|b|c}0` - Chooses from a list of alternatives, separated by vertical bars, based on the value of the given argument. In this example, a value of 2 in diagnostic argument 0 would result in "c" being output. The argument to the %select may be an integer, enum, or StringRef. If it's a StringRef, the specifier acts as an emptiness check.
101101

102102
- `%s0` - Produces an "s" if the given argument is anything other than 1, as meant for an English plural. This isn't particularly localizable without a more general `%plural` form, but most diagnostics try to avoid cases where a plural/singular distinction would be necessary in the first place.
103103

0 commit comments

Comments
 (0)