Skip to content

Commit aba4f77

Browse files
committed
Merge branch 'master' of github.com:swiftwasm/swift into maxd/master-merge
# Conflicts: # stdlib/public/stubs/ThreadLocalStorage.cpp # utils/build_swift/build_swift/driver_arguments.py
2 parents 4456632 + 3e8278a commit aba4f77

File tree

483 files changed

+15493
-4731
lines changed

Some content is hidden

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

483 files changed

+15493
-4731
lines changed

CMakeLists.txt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,6 @@ option(SWIFT_RUNTIME_ENABLE_LEAK_CHECKER
395395
"Should the runtime be built with support for non-thread-safe leak detecting entrypoints"
396396
FALSE)
397397

398-
option(SWIFT_STDLIB_USE_NONATOMIC_RC
399-
"Build the standard libraries and overlays with nonatomic reference count operations enabled"
400-
FALSE)
401-
402398
option(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS
403399
"Enable runtime function counters and expose the API."
404400
FALSE)
@@ -638,6 +634,22 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQU
638634
set(SWIFT_COMPILER_IS_MSVC_LIKE TRUE)
639635
endif()
640636

637+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
638+
# CMake's default for CMAKE_CXX_FLAGS_RELEASE is "-O3 -DNDEBUG". Let's avoid "-O3" for consistency
639+
# between Release and RelWithDebInfo. Dropping -DNDEBUG from this setting is blocked by triggering
640+
# a test failure of Swift-Unit :: Syntax/./SwiftSyntaxTests/TypeSyntaxTests.MetatypeTypeWithAPIs
641+
# because unit tests don't currently explicitly set -DNDEBUG/-UNDEBUG.
642+
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
643+
644+
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
645+
if(_lto_flag_out)
646+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} -gline-tables-only")
647+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -gline-tables-only")
648+
endif()
649+
else()
650+
651+
endif()
652+
641653
#
642654
# Configure SDKs.
643655
#
@@ -937,7 +949,6 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
937949
endif()
938950
endif()
939951

940-
find_package(Python2 COMPONENTS Interpreter REQUIRED)
941952
find_package(Python3 COMPONENTS Interpreter REQUIRED)
942953

943954
#

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ The required version of Xcode changes frequently, and is often a beta release.
115115
Check this document or the host information on <https://ci.swift.org> for the
116116
current required version.
117117

118+
Swift's build tooling is meant to support spaces in the paths passed to them,
119+
but using spaces sometimes tickles bugs in Swift's build scripts or the tools
120+
they rely on. For example, [SR-13441](https://bugs.swift.org/browse/SR-13441)
121+
is caused by a space in the Xcode path used on macOS. If you see Swift's build
122+
tooling misbehave due to a space in a path, please
123+
[report the bug on the Swift bug tracker](https://swift.org/contributing/#reporting-bugs)
124+
and then change the path to work around it.
125+
118126
You will also need [CMake](https://cmake.org) and [Ninja](https://ninja-build.org),
119127
which can be installed via a package manager:
120128

benchmark/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ set(SWIFT_BENCH_MODULES
136136
single-source/PrefixWhile
137137
single-source/Prims
138138
single-source/PrimsNonStrongRef
139+
single-source/ProtocolConformance
139140
single-source/ProtocolDispatch
140141
single-source/ProtocolDispatch2
141142
single-source/Queue
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
//===--- ProtocolDispatch.swift -------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2020 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+
//===----------------------------------------------------------------------===//
12+
13+
import TestsUtils
14+
15+
public let ProtocolConformance = BenchmarkInfo (
16+
name: "ProtocolConformance",
17+
runFunction: run_ProtocolConformance,
18+
tags: [.validation, .runtime])
19+
20+
protocol P {}
21+
22+
struct One: P {}
23+
struct Two {}
24+
25+
struct Cat<T, U> {}
26+
27+
extension Cat: P where T: P, U: P {}
28+
29+
protocol Growable {}
30+
extension Growable {
31+
func grow() -> (Growable, Growable) {
32+
return (Cat<Self, One>(), Cat<Self, Two>())
33+
}
34+
}
35+
36+
extension One: Growable {}
37+
extension Two: Growable {}
38+
extension Cat: Growable {}
39+
40+
@inline(never)
41+
public func run_ProtocolConformance(_ N: Int) {
42+
var array: [Growable] = [One(), Two()]
43+
var i = 0
44+
var checks = 0
45+
46+
// The expected number of times we expect `elt is P` to be true.
47+
var expectedConforms = 0
48+
49+
// The expected number of times we expect `elt is P` to be true
50+
// per iteration, at the current time.
51+
var expectedConformsPerIter = 1
52+
53+
// The number of times we've actually seen `elt is P` be true.
54+
var conforms = 0
55+
while checks < N * 500 {
56+
let (a, b) = array[i].grow()
57+
array.append(a)
58+
array.append(b)
59+
60+
// The number of times `elt is P` is true per outer iteration
61+
// goes up by 1 when the array's count is a power of 2.
62+
if array.count & (array.count - 1) == 0 {
63+
expectedConformsPerIter += 1
64+
}
65+
expectedConforms += expectedConformsPerIter
66+
67+
for elt in array {
68+
if elt is P {
69+
conforms += 1
70+
}
71+
checks += 1
72+
}
73+
i += 1
74+
}
75+
CheckResults(expectedConforms == conforms)
76+
}

benchmark/utils/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ import PrefixWhile
131131
import Prims
132132
import PrimsNonStrongRef
133133
import PrimsSplit
134+
import ProtocolConformance
134135
import ProtocolDispatch
135136
import ProtocolDispatch2
136137
import Queue
@@ -317,6 +318,7 @@ registerBenchmark(PrefixWhile)
317318
registerBenchmark(Prims)
318319
registerBenchmark(PrimsNonStrongRef)
319320
registerBenchmark(PrimsSplit)
321+
registerBenchmark(ProtocolConformance)
320322
registerBenchmark(ProtocolDispatch)
321323
registerBenchmark(ProtocolDispatch2)
322324
registerBenchmark(QueueGeneric)

cmake/modules/AddSwift.cmake

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,18 @@ function(_add_host_variant_c_compile_flags target)
130130
_add_host_variant_c_compile_link_flags(${target})
131131

132132
is_build_type_optimized("${CMAKE_BUILD_TYPE}" optimized)
133-
if(optimized)
134-
if("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
135-
target_compile_options(${target} PRIVATE -Os)
136-
else()
137-
target_compile_options(${target} PRIVATE -O2)
138-
endif()
133+
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debuginfo)
134+
135+
# Add -O0/-O2/-O3/-Os/-g/-momit-leaf-frame-pointer/... based on CMAKE_BUILD_TYPE.
136+
target_compile_options(${target} PRIVATE "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
139137

138+
if(optimized)
140139
# Omit leaf frame pointers on x86 production builds (optimized, no debug
141140
# info, and no asserts).
142-
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debug)
143-
if(NOT debug AND NOT LLVM_ENABLE_ASSERTIONS)
141+
if(NOT debuginfo AND NOT LLVM_ENABLE_ASSERTIONS)
142+
# Unfortunately, this cannot be folded into the standard
143+
# CMAKE_CXX_FLAGS_... because Apple multi-SDK builds use different
144+
# architectures for different SDKs.
144145
if(SWIFT_HOST_VARIANT_ARCH MATCHES "i?86")
145146
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
146147
target_compile_options(${target} PRIVATE -momit-leaf-frame-pointer)
@@ -149,27 +150,6 @@ function(_add_host_variant_c_compile_flags target)
149150
endif()
150151
endif()
151152
endif()
152-
else()
153-
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
154-
target_compile_options(${target} PRIVATE -O0)
155-
else()
156-
target_compile_options(${target} PRIVATE /Od)
157-
endif()
158-
endif()
159-
160-
# CMake automatically adds the flags for debug info if we use MSVC/clang-cl.
161-
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
162-
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debuginfo)
163-
if(debuginfo)
164-
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
165-
if(_lto_flag_out)
166-
target_compile_options(${target} PRIVATE -gline-tables-only)
167-
else()
168-
target_compile_options(${target} PRIVATE -g)
169-
endif()
170-
else()
171-
target_compile_options(${target} PRIVATE -g0)
172-
endif()
173153
endif()
174154

175155
if(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS)

docs/ABI/Mangling.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ Globals
176176
global ::= global 'MJ' // noncanonical specialized generic type metadata instantiation cache associated with global
177177
global ::= global 'MN' // noncanonical specialized generic type metadata for global
178178

179+
#if SWIFT_RUNTIME_VERSION >= 5.4
180+
global ::= context (decl-name '_')+ 'WZ' // global variable one-time initialization function
181+
global ::= context (decl-name '_')+ 'Wz' // global variable one-time initialization token
182+
#endif
183+
179184
A direct symbol resolves directly to the address of an object. An
180185
indirect symbol resolves to the address of a pointer to the object.
181186
They are distinct manglings to make a certain class of bugs

0 commit comments

Comments
 (0)