Skip to content

Commit b68e864

Browse files
committed
Try to appease CI
more test fixes
1 parent 6715548 commit b68e864

File tree

7 files changed

+137
-89
lines changed

7 files changed

+137
-89
lines changed

test/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ normalize_boolean_spelling(SWIFT_ENABLE_DISPATCH)
209209
normalize_boolean_spelling(SWIFT_STDLIB_ENABLE_OBJC_INTEROP)
210210
normalize_boolean_spelling(SWIFT_ENABLE_BACKTRACING)
211211
normalize_boolean_spelling(SWIFT_BUILD_SWIFT_SYNTAX)
212+
normalize_boolean_spelling(SWIFT_ENABLE_SYNCHRONIZATION)
212213
is_build_type_optimized("${SWIFT_STDLIB_BUILD_TYPE}" SWIFT_OPTIMIZED)
213214

214215
# Get 'SWIFT_HOST_SDKROOT' for lit.site.cfg.in
@@ -405,6 +406,10 @@ foreach(SDK ${SWIFT_SDKS})
405406
list(APPEND LIT_ARGS "--param" "observation")
406407
endif()
407408

409+
if(SWIFT_ENABLE_SYNCHRONIZATION)
410+
list(APPEND LIT_ARGS "--param" "synchronization")
411+
endif()
412+
408413
list(APPEND LIT_ARGS "--param" "threading=${SWIFT_SDK_${SDK}_THREADING_PACKAGE}")
409414

410415
# Enable on-crash backtracing if supported

test/abi/macOS/x86_64/synchronization.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,6 @@ Added: _$ss6UInt64V15Synchronization11AtomicValueACMc
617617
// protocol witness table for Swift.UInt64 : Synchronization.AtomicValue in Synchronization
618618
Added: _$ss6UInt64V15Synchronization11AtomicValueACWP
619619

620-
// protocol conformance descriptor for Swift.Float16 : Synchronization.AtomicValue in Synchronization
621-
Added: _$ss7Float16V15Synchronization11AtomicValueACMc
622-
623-
// protocol witness table for Swift.Float16 : Synchronization.AtomicValue in Synchronization
624-
Added: _$ss7Float16V15Synchronization11AtomicValueACWP
625-
626620
// protocol conformance descriptor for Swift.Duration : Synchronization.AtomicValue in Synchronization
627621
Added: _$ss8DurationV15Synchronization11AtomicValueACMc
628622

test/stdlib/Atomics/LockFreeSingleConsumerStack.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-simple-swift
1+
// RUN: %target-run-simple-swift(%import-libdispatch)
22
// REQUIRES: executable_test
33
// REQUIRES: libdispatch
44

@@ -46,9 +46,9 @@ class LockFreeSingleConsumerStack<Element> {
4646
// This method does not support multiple overlapping concurrent calls.
4747
func pop() -> Element? {
4848
precondition(
49-
_consumerCount.wrappingAdd(by: 1, ordering: .acquiring).oldValue == 0,
49+
_consumerCount.wrappingAdd(1, ordering: .acquiring).oldValue == 0,
5050
"Multiple consumers detected")
51-
defer { _consumerCount.wrappingSubtract(by: 1, ordering: .releasing) }
51+
defer { _consumerCount.wrappingSubtract(1, ordering: .releasing) }
5252
var done = false
5353
var current = _last.load(ordering: .acquiring)
5454
while let c = current {

test/stdlib/Atomics/WordPair.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ suite.test("basics") {
3535
//expectEqual(MemoryLayout<WordPair>.alignment, 2 * MemoryLayout<UInt>.alignment)
3636

3737
let value0 = WordPair(first: 2, second: 1)
38+
#if _endian(little)
39+
expectEqual(componentsInMemoryOrder(of: value0), UIntPair(2, 1))
40+
#else
3841
expectEqual(componentsInMemoryOrder(of: value0), UIntPair(1, 2))
42+
#endif
3943

4044
let value1 = WordPair(first: .max, second: 0)
4145
expectEqual(value1.first, .max)

utils/SwiftAtomics.py

Lines changed: 107 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#===-----------------------------------------------------------------------===//
1+
# ===----------------------------------------------------------------------===//
22
#
33
# This source file is part of the Swift.org open source project
44
#
@@ -8,119 +8,146 @@
88
# See https://swift.org/LICENSE.txt for license information
99
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010
#
11-
#===-----------------------------------------------------------------------===//
11+
# ===----------------------------------------------------------------------===//
1212

1313
atomicTypes = [
14-
# Name Size Alignment Builtin Swift Type
15-
("_Atomic8BitStorage", "8", "1", "Builtin.Int8", "UInt8"),
16-
("_Atomic16BitStorage", "16", "2", "Builtin.Int16", "UInt16"),
17-
("_Atomic32BitStorage", "32", "4", "Builtin.Int32", "UInt32"),
18-
("_Atomic64BitStorage", "64", "8", "Builtin.Int64", "UInt64"),
19-
20-
# Note: WordPair only on 64 bit platforms.
21-
("_Atomic128BitStorage", "128", "16", "Builtin.Int128", "WordPair"),
14+
# Name, Size, Alignment, Builtin, Swift Type
15+
("_Atomic8BitStorage", "8", "1", "Builtin.Int8", "UInt8"),
16+
("_Atomic16BitStorage", "16", "2", "Builtin.Int16", "UInt16"),
17+
("_Atomic32BitStorage", "32", "4", "Builtin.Int32", "UInt32"),
18+
("_Atomic64BitStorage", "64", "8", "Builtin.Int64", "UInt64"),
19+
20+
# Note: WordPair only on 64 bit platforms.
21+
("_Atomic128BitStorage", "128", "16", "Builtin.Int128", "WordPair"),
2222
]
2323

2424
intTypes = [
25-
# Swift Storage Type Builtin
26-
("Int8", "_Atomic8BitStorage", "Int8"),
27-
("Int16", "_Atomic16BitStorage", "Int16"),
28-
("Int32", "_Atomic32BitStorage", "Int32"),
29-
("Int64", "_Atomic64BitStorage", "Int64"),
30-
31-
# We handle the word type's storage in source.
32-
("Int", "", ""),
33-
("UInt", "", ""),
34-
35-
("UInt8", "_Atomic8BitStorage", "Int8"),
36-
("UInt16", "_Atomic16BitStorage", "Int16"),
37-
("UInt32", "_Atomic32BitStorage", "Int32"),
38-
("UInt64", "_Atomic64BitStorage", "Int64"),
25+
# Swift, Storage Type, Builtin
26+
("Int8", "_Atomic8BitStorage", "Int8"),
27+
("Int16", "_Atomic16BitStorage", "Int16"),
28+
("Int32", "_Atomic32BitStorage", "Int32"),
29+
("Int64", "_Atomic64BitStorage", "Int64"),
30+
31+
# We handle the word type's storage in source.
32+
("Int", "", ""),
33+
("UInt", "", ""),
34+
35+
("UInt8", "_Atomic8BitStorage", "Int8"),
36+
("UInt16", "_Atomic16BitStorage", "Int16"),
37+
("UInt32", "_Atomic32BitStorage", "Int32"),
38+
("UInt64", "_Atomic64BitStorage", "Int64"),
3939
]
4040

4141
loadOrderings = [
42-
# Swift API name doc name LLVM name
43-
("relaxed", "Relaxed", "relaxed", "monotonic"),
44-
("acquiring", "Acquiring", "acquiring", "acquire"),
45-
("sequentiallyConsistent", "SequentiallyConsistent", "sequentially consistent", "seqcst")
42+
# Swift, API name, doc name, LLVM name
43+
("relaxed", "Relaxed", "relaxed", "monotonic"),
44+
("acquiring", "Acquiring", "acquiring", "acquire"),
45+
(
46+
"sequentiallyConsistent",
47+
"SequentiallyConsistent",
48+
"sequentially consistent",
49+
"seqcst"
50+
)
4651
]
4752

4853
storeOrderings = [
49-
# Swift enum case, API name, doc name, LLVM name
50-
("relaxed", "Relaxed", "relaxed", "monotonic"),
51-
("releasing", "Releasing", "releasing", "release"),
52-
("sequentiallyConsistent", "SequentiallyConsistent", "sequentially consistent", "seqcst")
54+
# Swift enum case, API name, doc name, LLVM name
55+
("relaxed", "Relaxed", "relaxed", "monotonic"),
56+
("releasing", "Releasing", "releasing", "release"),
57+
(
58+
"sequentiallyConsistent",
59+
"SequentiallyConsistent",
60+
"sequentially consistent",
61+
"seqcst"
62+
)
5363
]
5464

5565
updateOrderings = [
56-
# Swift enum case, API name, doc name, LLVM name, failure name
57-
("relaxed", "Relaxed", "relaxed", "monotonic", "monotonic"),
58-
("acquiring", "Acquiring", "acquiring", "acquire", "acquire"),
59-
("releasing", "Releasing", "releasing", "release", "monotonic"),
60-
("acquiringAndReleasing", "AcquiringAndReleasing", "acquiring-and-releasing", "acqrel", "acquire"),
61-
("sequentiallyConsistent", "SequentiallyConsistent", "sequentially consistent", "seqcst", "seqcst"),
66+
# Swift enum case, API name, doc name, LLVM name, failure name
67+
("relaxed", "Relaxed", "relaxed", "monotonic", "monotonic"),
68+
("acquiring", "Acquiring", "acquiring", "acquire", "acquire"),
69+
("releasing", "Releasing", "releasing", "release", "monotonic"),
70+
(
71+
"acquiringAndReleasing",
72+
"AcquiringAndReleasing",
73+
"acquiring-and-releasing",
74+
"acqrel",
75+
"acquire"
76+
),
77+
(
78+
"sequentiallyConsistent",
79+
"SequentiallyConsistent",
80+
"sequentially consistent",
81+
"seqcst",
82+
"seqcst"
83+
),
6284
]
6385

6486
integerOperations = [
65-
# Swift name, llvm name, operator, doc name
66-
("WrappingAdd", "add", "&+", "wrapping add"),
67-
("WrappingSubtract", "sub", "&-", "wrapping subtract"),
68-
("BitwiseAnd", "and", "&", "bitwise AND"),
69-
("BitwiseOr", "or", "|", "bitwise OR"),
70-
("BitwiseXor", "xor", "^", "bitwise XOR"),
71-
72-
# These two are handled specially in source.
73-
("Min", "min", "", "minimum"),
74-
("Max", "max", "", "maximum")
87+
# Swift name, llvm name, operator, doc name
88+
("WrappingAdd", "add", "&+", "wrapping add"),
89+
("WrappingSubtract", "sub", "&-", "wrapping subtract"),
90+
("BitwiseAnd", "and", "&", "bitwise AND"),
91+
("BitwiseOr", "or", "|", "bitwise OR"),
92+
("BitwiseXor", "xor", "^", "bitwise XOR"),
93+
94+
# These two are handled specially in source.
95+
("Min", "min", "", "minimum"),
96+
("Max", "max", "", "maximum")
7597
]
7698

7799
boolOperations = [
78-
# Swift name, llvm name, operator, doc
79-
("LogicalAnd", "and", "&&", "logical AND"),
80-
("LogicalOr", "or", "||", "logical OR"),
81-
("LogicalXor", "xor", "!=", "logical XOR")
100+
# Swift name, llvm name, operator, doc
101+
("LogicalAnd", "and", "&&", "logical AND"),
102+
("LogicalOr", "or", "||", "logical OR"),
103+
("LogicalXor", "xor", "!=", "logical XOR")
82104
]
83105

106+
84107
# LLVM doesn't support arbitrary ordering combinations yet, so for the
85108
# two-ordering cmpxchg variants we need to upgrade the success
86109
# ordering when necessary so that it is at least as "strong" as the
87110
# failure case. This function implements that mapping.
88111
#
89112
# See llvm/Support/AtomicOrdering.h
90113
def actualOrders(success, failure):
91-
def max(success, failure):
92-
if failure == "acquire":
93-
if success == "monotonic":
94-
return "acquire"
95-
if success == "release":
96-
return "acqrel"
97-
if failure == "seqcst":
98-
return "seqcst"
99-
return success
100-
actualSuccess = max(success, failure)
101-
return actualSuccess + "_" + failure
114+
def max(success, failure):
115+
if failure == "acquire":
116+
if success == "monotonic":
117+
return "acquire"
118+
if success == "release":
119+
return "acqrel"
120+
if failure == "seqcst":
121+
return "seqcst"
122+
return success
123+
actualSuccess = max(success, failure)
124+
return actualSuccess + "_" + failure
125+
102126

103127
def llvmToCaseName(ordering):
104-
if ordering == "monotonic":
105-
return "relaxed"
106-
if ordering == "acquire":
107-
return "acquiring"
108-
if ordering == "release":
109-
return "releasing"
110-
if ordering == "acqrel":
111-
return "acquiringAndReleasing"
112-
if ordering == "seqcst":
113-
return "sequentiallyConsistent"
128+
if ordering == "monotonic":
129+
return "relaxed"
130+
if ordering == "acquire":
131+
return "acquiring"
132+
if ordering == "release":
133+
return "releasing"
134+
if ordering == "acqrel":
135+
return "acquiringAndReleasing"
136+
if ordering == "seqcst":
137+
return "sequentiallyConsistent"
138+
114139

115140
def atomicOperationName(intType, operation):
116-
if operation == "Min":
117-
return "umin" if intType.startswith("U") else "min"
118-
if operation == "Max":
119-
return "umax" if intType.startswith("U") else "max"
120-
return operation
141+
if operation == "Min":
142+
return "umin" if intType.startswith("U") else "min"
143+
if operation == "Max":
144+
return "umax" if intType.startswith("U") else "max"
145+
return operation
146+
121147

122148
def lowerFirst(str):
123-
return str[:1].lower() + str[1:] if str else ""
149+
return str[:1].lower() + str[1:] if str else ""
150+
124151

125152
def argLabel(label):
126-
return label + ": " if label != "_" else ""
153+
return label + ": " if label != "_" else ""

utils/build_swift/tests/expected_options.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
'enable_experimental_string_processing': True,
168168
'enable_experimental_observation': True,
169169
'swift_enable_backtracing': True,
170+
'enable_synchronization': True,
170171
'enable_lsan': False,
171172
'enable_sanitize_coverage': False,
172173
'disable_guaranteed_normal_arguments': False,
@@ -591,6 +592,7 @@ class BuildScriptImplOption(_BaseOption):
591592
EnableOption('--enable-ubsan'),
592593
EnableOption('--export-compile-commands'),
593594
EnableOption('--swift-enable-backtracing'),
595+
EnableOption('--enable-synchronization'),
594596
EnableOption('--foundation', dest='build_foundation'),
595597
EnableOption('--host-test'),
596598
EnableOption('--only-executable-test'),

utils/swift_build_support/tests/products/test_swift.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def setUp(self):
6060
enable_experimental_distributed=False,
6161
enable_experimental_observation=False,
6262
swift_enable_backtracing=False,
63+
enable_synchronization=False,
6364
build_early_swiftsyntax=False,
6465
build_swift_stdlib_static_print=False,
6566
build_swift_stdlib_unicode_data=True,
@@ -103,6 +104,7 @@ def test_by_default_no_cmake_options(self):
103104
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
104105
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
105106
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
107+
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
106108
'-DSWIFT_STDLIB_STATIC_PRINT=FALSE',
107109
'-DSWIFT_FREESTANDING_IS_DARWIN:BOOL=FALSE',
108110
'-DSWIFT_STDLIB_BUILD_PRIVATE:BOOL=TRUE',
@@ -130,6 +132,7 @@ def test_swift_runtime_tsan(self):
130132
'-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED:BOOL=FALSE',
131133
'-DSWIFT_ENABLE_EXPERIMENTAL_OBSERVATION:BOOL=FALSE',
132134
'-DSWIFT_ENABLE_BACKTRACING:BOOL=FALSE',
135+
'-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL=FALSE',
133136
'-DSWIFT_STDLIB_STATIC_PRINT=FALSE',
134137
'-DSWIFT_FREESTANDING_IS_DARWIN:BOOL=FALSE',
135138
'-DSWIFT_STDLIB_BUILD_PRIVATE:BOOL=TRUE',
@@ -424,6 +427,19 @@ def test_backtracing_flags(self):
424427
[x for x in swift.cmake_options
425428
if 'DSWIFT_ENABLE_BACKTRACING' in x])
426429

430+
def test_synchronization_flags(self):
431+
self.args.enable_synchronization = True
432+
swift = Swift(
433+
args=self.args,
434+
toolchain=self.toolchain,
435+
source_dir='/path/to/src',
436+
build_dir='/path/to/build')
437+
self.assertEqual(
438+
['-DSWIFT_ENABLE_SYNCHRONIZATION:BOOL='
439+
'TRUE'],
440+
[x for x in swift.cmake_options
441+
if 'DSWIFT_ENABLE_SYNCHRONIZATION' in x])
442+
427443
def test_freestanding_is_darwin_flags(self):
428444
self.args.swift_freestanding_is_darwin = True
429445
swift = Swift(

0 commit comments

Comments
 (0)