Skip to content

Commit 7880bae

Browse files
author
Greg Parker
committed
Merge branch 'master' of github.com:apple/swift into new-refcount-representation
2 parents 20d8d0f + 2f9a332 commit 7880bae

File tree

544 files changed

+24175
-5339
lines changed

Some content is hidden

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

544 files changed

+24175
-5339
lines changed

CODE_OWNERS.TXT

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ D: Swift standard library
1313

1414
N: David Farler
1515
E: dfarler@apple.com
16-
D: Markup, Swift Linux port
16+
D: Markup, lib/Syntax, Swift Linux port
1717

1818
N: Doug Gregor
1919
E: dgregor@apple.com

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ discussed below.
5353
macOS, Ubuntu Linux LTS, and the latest Ubuntu Linux release are the current
5454
supported host development operating systems.
5555

56-
For macOS, you need [Xcode 8.3 Beta 2](https://developer.apple.com/xcode/downloads/).
56+
For macOS, you need [Xcode 8.3 Beta 3](https://developer.apple.com/xcode/downloads/).
5757

5858
For Ubuntu, you'll need the following development dependencies:
5959

benchmark/scripts/compare_perf_tests.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#
1414
# ===---------------------------------------------------------------------===//
1515

16+
from __future__ import print_function
17+
1618
import argparse
1719
import csv
1820
import sys

benchmark/scripts/generate_harness/generate_harness.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
# Generate CMakeLists.txt and utils/main.swift from templates.
1616

17+
from __future__ import print_function
18+
1719
import glob
1820
import os
1921
import re

benchmark/scripts/perf_test_driver/perf_test_driver.py

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#
1313
# ===---------------------------------------------------------------------===//
1414

15+
from __future__ import print_function
16+
1517
import functools
1618
import multiprocessing
1719
import os

benchmark/utils/convertToJSON.py

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757
# ]
5858
# }
5959

60+
from __future__ import print_function
61+
6062
import json
6163
import re
6264
import sys

cmake/modules/AddSwift.cmake

+58-35
Original file line numberDiff line numberDiff line change
@@ -181,47 +181,65 @@ function(_add_variant_c_compile_flags)
181181
if(optimized OR CFLAGS_FORCE_BUILD_OPTIMIZED)
182182
list(APPEND result "-O2")
183183

184-
# Add -momit-leaf-frame-pointer on x86.
185-
if("${CFLAGS_ARCH}" STREQUAL "i386" OR "${CFLAGS_ARCH}" STREQUAL "x86_64")
186-
list(APPEND result "-momit-leaf-frame-pointer")
184+
# Omit leaf frame pointers on x86.
185+
if("${CFLAGS_ARCH}" STREQUAL "i386" OR "${CFLAGS_ARCH}" STREQUAL "i686")
186+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
187+
list(APPEND result "-momit-leaf-frame-pointer")
188+
else()
189+
list(APPEND result "/Oy")
190+
endif()
187191
endif()
188192
else()
189-
list(APPEND result "-O0")
190-
endif()
191-
is_build_type_with_debuginfo("${CFLAGS_BUILD_TYPE}" debuginfo)
192-
if(debuginfo)
193-
_compute_lto_flag("${CFLAGS_ENABLE_LTO}" _lto_flag_out)
194-
if(_lto_flag_out)
195-
list(APPEND result "-gline-tables-only")
193+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
194+
list(APPEND result "-O0")
196195
else()
197-
list(APPEND result "-g")
196+
list(APPEND result "/Od")
198197
endif()
199-
else()
200-
list(APPEND result "-g0")
201198
endif()
202199

203-
if("${CFLAGS_SDK}" STREQUAL "WINDOWS")
204-
list(APPEND result -Xclang;--dependent-lib=oldnames)
205-
# TODO(compnerd) handle /MT, /MTd, /MD, /MDd
206-
if("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
207-
list(APPEND result "-D_MD")
208-
list(APPEND result -Xclang;--dependent-lib=msvcrt)
200+
# CMake automatically adds the flags for debug info if we use MSVC/clang-cl.
201+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
202+
is_build_type_with_debuginfo("${CFLAGS_BUILD_TYPE}" debuginfo)
203+
if(debuginfo)
204+
_compute_lto_flag("${CFLAGS_ENABLE_LTO}" _lto_flag_out)
205+
if(_lto_flag_out)
206+
list(APPEND result "-gline-tables-only")
207+
else()
208+
list(APPEND result "-g")
209+
endif()
209210
else()
210-
list(APPEND result "-D_MDd")
211-
list(APPEND result -Xclang;--dependent-lib=msvcrtd)
211+
list(APPEND result "-g0")
212212
endif()
213-
list(APPEND result -fno-pic)
214213
endif()
215214

216215
if("${CFLAGS_SDK}" STREQUAL "WINDOWS")
216+
# MSVC doesn't support -Xclang. We don't need to manually specify
217+
# -D_MD or D_MDd either, as CMake does this automatically.
218+
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
219+
list(APPEND result -Xclang;--dependent-lib=oldnames)
220+
# TODO(compnerd) handle /MT, /MTd, /MD, /MDd
221+
if("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
222+
list(APPEND result "-D_MD")
223+
list(APPEND result -Xclang;--dependent-lib=msvcrt)
224+
else()
225+
list(APPEND result "-D_MDd")
226+
list(APPEND result -Xclang;--dependent-lib=msvcrtd)
227+
endif()
228+
endif()
229+
230+
# MSVC/clang-cl don't support -fno-pic or -fms-compatability-version.
231+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
232+
list(APPEND result -fno-pic)
233+
list(APPEND result "-fms-compatibility-version=1900")
234+
endif()
235+
217236
list(APPEND result "-DLLVM_ON_WIN32")
218237
list(APPEND result "-D_CRT_SECURE_NO_WARNINGS")
219238
list(APPEND result "-D_CRT_NONSTDC_NO_WARNINGS")
220239
# TODO(compnerd) permit building for different families
221240
list(APPEND result "-D_CRT_USE_WINAPI_FAMILY_DESKTOP_APP")
222241
# TODO(compnerd) handle /MT
223242
list(APPEND result "-D_DLL")
224-
list(APPEND result "-fms-compatibility-version=1900")
225243
endif()
226244

227245
if(CFLAGS_ENABLE_ASSERTIONS)
@@ -321,9 +339,12 @@ function(_add_variant_link_flags)
321339
elseif("${LFLAGS_SDK}" STREQUAL "CYGWIN")
322340
# No extra libraries required.
323341
elseif("${LFLAGS_SDK}" STREQUAL "WINDOWS")
324-
# NOTE: we do not use "/MD" or "/MDd" and select the runtime via linker
325-
# options. This causes conflicts.
326-
list(APPEND result "-nostdlib")
342+
# We don't need to add -nostdlib using MSVC or clang-cl, as MSVC and clang-cl rely on auto-linking entirely.
343+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
344+
# NOTE: we do not use "/MD" or "/MDd" and select the runtime via linker
345+
# options. This causes conflicts.
346+
list(APPEND result "-nostdlib")
347+
endif()
327348
elseif("${LFLAGS_SDK}" STREQUAL "ANDROID")
328349
list(APPEND result
329350
"-ldl"
@@ -351,15 +372,17 @@ function(_add_variant_link_flags)
351372
if(NOT "${SWIFT_${LFLAGS_SDK}_ICU_I18N}" STREQUAL "")
352373
list(APPEND library_search_directories "${SWIFT_${sdk}_ICU_I18N}")
353374
endif()
354-
355-
if(SWIFT_ENABLE_GOLD_LINKER AND
356-
"${SWIFT_SDK_${LFLAGS_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
357-
list(APPEND result "-fuse-ld=gold")
358-
endif()
359-
if(SWIFT_ENABLE_LLD_LINKER OR
360-
("${LFLAGS_SDK}" STREQUAL "WINDOWS" AND
361-
NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS"))
362-
list(APPEND result "-fuse-ld=lld")
375+
376+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
377+
if(SWIFT_ENABLE_GOLD_LINKER AND
378+
"${SWIFT_SDK_${LFLAGS_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
379+
list(APPEND result "-fuse-ld=gold")
380+
endif()
381+
if(SWIFT_ENABLE_LLD_LINKER OR
382+
("${LFLAGS_SDK}" STREQUAL "WINDOWS" AND
383+
NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WINDOWS"))
384+
list(APPEND result "-fuse-ld=lld")
385+
endif()
363386
endif()
364387

365388
set("${LFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)

cmake/modules/AddSwiftUnittests.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function(add_swift_unittest test_dirname)
2828

2929
set(new_libnames)
3030
foreach(dep ${libnames})
31-
if("${dep}" MATCHES "^(LLVM|Clang|gtest)")
31+
if("${dep}" MATCHES "^(LLVM|Clang|gtest)" AND NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
3232
list(APPEND new_libnames "${LLVM_LIBRARY_OUTPUT_INTDIR}/lib${dep}.a")
3333
else()
3434
list(APPEND new_libnames "${dep}")

cmake/modules/SwiftSource.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ function(_compile_swift_files
477477
if (NOT SWIFTFILE_IS_MAIN)
478478
add_custom_command_target(
479479
module_dependency_target
480+
COMMAND
481+
"${CMAKE_COMMAND}" "-E" "remove" "-f" "${module_file}"
480482
COMMAND
481483
"${PYTHON_EXECUTABLE}" "${line_directive_tool}" "@${file_path}" --
482484
"${swift_compiler_tool}" "-emit-module" "-o" "${module_file}" ${swift_flags}

docs/ContinuousIntegration.md

+17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Smoke Testing](#smoke-testing)
1010
- [Validation Testing](#validation-testing)
1111
- [Lint Testing](#lint-testing)
12+
- [Specific Preset Testing](#specific-preset-testing)
1213
- [Cross Repository Testing](#cross-repository-testing)
1314
- [ci.swift.org bots](#ciswiftorg-bots)
1415

@@ -28,6 +29,7 @@ swift-ci pull request testing is triggered by writing a comment on this PR addre
2829
2. Validation Testing
2930
3. Benchmarking.
3031
4. Lint Testing
32+
5. Specific Preset Testing
3133

3234
We describe each in detail below:
3335

@@ -79,6 +81,7 @@ A smoke test on Linux does the following:
7981
OS X platform | @swift-ci Please benchmark | Swift Benchmark on OS X Platform
8082
Linux platform | @swift-ci Please test Linux platform | Swift Test Linux Platform (smoke test)<br>Swift Test Linux Platform
8183
Linux platform | @swift-ci Please clean test Linux platform | Swift Test Linux Platform (smoke test)<br>Swift Test Linux Platform
84+
OS X platform | @swift-ci Please ASAN test | Swift ASAN Test OS X Platform
8285

8386
The core principles of validation testing is that:
8487

@@ -121,6 +124,20 @@ A validation test on Linux does the following:
121124
------------ | ------- | ------------
122125
Python | @swift-ci Please Python lint | Python lint
123126

127+
### Specific Preset Testing
128+
129+
Platform | Comment | Check Status
130+
------------ | ------- | ------------
131+
OS X platform | preset=<preset> <br> @swift-ci Please test macOS with preset | Swift Test macOS Platform with preset
132+
133+
For example:
134+
135+
```
136+
preset=buildbot_incremental,tools=RA,stdlib=RD,smoketest=macosx,single-thread
137+
@swift-ci Please test macOS with preset
138+
139+
```
140+
124141
## Cross Repository Testing
125142

126143
Simply provide the URL from corresponding pull requests in the same comment as "@swift-ci Please test" phrase. List all of the pull requests and then provide the specific test phrase you would like to trigger. Currently, it will only merge the main pull request you requested testing from as opposed to all of the PR's.

docs/OwnershipManifesto.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ the ownership system from an implementation detail to a more
9292
visible aspect of the language. They are also somewhat
9393
inseparable, for reasons we'll explain, although of course they
9494
can be prioritized differently. For these reasons, we will
95-
talk about them as a cohensive feature called "ownership".
95+
talk about them as a cohesive feature called "ownership".
9696

9797
### A bit more detail
9898

@@ -118,7 +118,7 @@ arbitrary function will use its arguments; it just falls
118118
back on a default rule for whether to pass ownership of
119119
the value. When that default rule is wrong, the program
120120
will end up making extra copies at runtime. So one simple
121-
thing we can do is allow programs to be more explicit at
121+
thing we can do is to allow programs to be more explicit at
122122
certain points about whether they need ownership or not.
123123

124124
That closely dovetails with the desire to support non-copyable
@@ -311,7 +311,7 @@ A *variable* is the semantics concept of a unique place in
311311
memory that stores a value. It's not necessarily mutable, at least
312312
as we're using it in this document. Variables are usually created for
313313
storage declarations, but they can also be created dynamically in
314-
raw memory, e.g. using UnsafeRawPointer. A variable always has a
314+
raw memory, e.g. using `UnsafeRawPointer`. A variable always has a
315315
specific type. It also has a *lifetime*, i.e. a point in the language
316316
semantics where it comes into existence and a point (or several)
317317
where it is destroyed.
@@ -725,7 +725,7 @@ use static enforcement for some class instance properties.
725725

726726
Undefined enforcement means that conflicts are not detected
727727
either statically or dynamically, and instead simply have
728-
undefined behavior. This is not a desireable mechanism
728+
undefined behavior. This is not a desirable mechanism
729729
for ordinary code given Swift's "safe by default" design,
730730
but it's the only real choice for things like unsafe pointers.
731731

@@ -747,7 +747,7 @@ not to escape. The following principles apply:
747747
- If a closure `C` potentially escapes, then for any variable
748748
`V` captured by `C`, all accesses to `V` potentially executed
749749
after a potential escape (including the accesses within `C`
750-
itself) must use dynamic enforcement unless all such acesses
750+
itself) must use dynamic enforcement unless all such accesses
751751
are reads.
752752

753753
- If a closure `C` does not escape a function, then its
@@ -797,7 +797,7 @@ additional semantic concerns.
797797
A shared value can be used in the scope that binds it
798798
just like an ordinary parameter or `let` binding.
799799
If the shared value is used in a place that requires
800-
ownership, Swift will simply implicitly copy the value
800+
ownership, Swift will simply implicitly copy the value --
801801
again, just like an ordinary parameter or `let` binding.
802802

803803
#### Limitations of shared values
@@ -819,7 +819,7 @@ born from a trio of concerns:
819819
- We have to scope this proposal to something that can
820820
conceivably be implemented in the coming months. We expect this
821821
proposal to yield major benefits to the language and its
822-
implementaton, but it is already quite broad and aggressive.
822+
implementation, but it is already quite broad and aggressive.
823823
First-class ephemerals would add enough complexity to the
824824
implementation and design that they are clearly out of scope.
825825
Furthermore, the remaining language-design questions are
@@ -861,7 +861,7 @@ born from a trio of concerns:
861861
lexical and maintains the ability to run arbitrary code
862862
at the end of an access. Imagine what it would take to
863863
implement a loop that added these temporary mutable
864-
references to an array each iteration of the loop would
864+
references to an array -- each iteration of the loop would
865865
have to be able to queue up arbitrary code to run as a clean-up
866866
when the function was finished with the array. This would
867867
hardly be a low-cost abstraction! A more Rust-like
@@ -1078,7 +1078,7 @@ A non-mutating iteration simply visits each of the elements
10781078
in the collection, leaving it intact and unmodified. We have
10791079
no reason to copy the elements; the iteration variable can
10801080
simply be bound to a shared value. This is a `nonmutating`
1081-
operaton on `Collection`.
1081+
operation on `Collection`.
10821082

10831083
This can be explicitly requested by declaring the iteration
10841084
variable `shared`:
@@ -1285,7 +1285,7 @@ value is returned. This is useful for several reasons:
12851285
reference, that storage is normally accessed for the duration
12861286
of the call. The programmer can suppress this and force the
12871287
copy to complete before the call by calling `copy` on the
1288-
storage reference before
1288+
storage reference before.
12891289

12901290
- It is necessary for types that have suppressed implicit
12911291
copies. See the section below on non-copyable types.
@@ -1402,7 +1402,7 @@ default.
14021402

14031403
The logical solution is to maintain the default assumption
14041404
that all types are copyable, and then allow select contexts
1405-
to turn that assumption off. We will cause these contexts
1405+
to turn that assumption off. We will call these contexts
14061406
`moveonly` contexts. All contexts lexically nested within
14071407
a `moveonly` context are also implicitly `moveonly`.
14081408

0 commit comments

Comments
 (0)