Skip to content

[pull] swiftwasm from master #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
May 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
6bf0f26
Emit `/DEFAULTLIB` directive for `#pragma comment(lib, ...)` in a C m…
martinboehme May 20, 2020
e530ef8
Update WindowsBuild.md
martinboehme May 25, 2020
fd56606
[NFC] Remove bits and pieces referring to Ubuntu 14.04 LTS (Trusty Ta…
varungandhi-apple May 25, 2020
d867c88
Update WindowsBuild.md
martinboehme May 26, 2020
6ca148d
AST: Optimize removeShadowedDecls()
slavapestov May 27, 2020
f025dea
Update WindowsBuild.md
martinboehme May 28, 2020
3767ece
[CMake] Simplify two binary variables into one tri-state variable
davezarzycki May 27, 2020
9526384
[IRGen] NFC: Narrow the scope of some code
davezarzycki May 28, 2020
3c3093d
[AutoDiff] Clean up VJP basic block utilities.
dan-zheng May 28, 2020
24de636
[AutoDiff] Re-enable control_flow.swift test.
dan-zheng May 28, 2020
c050a26
runtime: further isolate runtime from LLVMSupport
compnerd May 28, 2020
d5d076d
[AutoDiff] Support differentiation of branching cast instructions.
dan-zheng May 28, 2020
56c77df
[Serialization] Skip SPI documentation in swiftdoc files
xymus May 27, 2020
b89ef78
Adding `final` to public API is API-stable.
jckarter May 28, 2020
d5c40bf
Revert "Disable objc_mangling.swift and SwiftObjectNSObject.swift tes…
shahmishal May 28, 2020
d4f4871
stdlib: add `StringSwitch` to LLVMSupport fork
compnerd May 28, 2020
be8674e
Make an internal KeyPath helper final.
jckarter May 29, 2020
a40edb9
Merge branch 'master' into martinboehme-patch-2
martinboehme May 29, 2020
93ff8b0
stdlib: make sure that SetAlgebra.init(sequence) is on the fast path.
eeckstein May 26, 2020
f6ec448
stdlib: Prevent storing into the empty array singleton when replacing…
eeckstein May 26, 2020
68728dc
stdlib: move the new-buffer creation function from Array to ArrayBuffer
eeckstein May 26, 2020
6b513a8
Merge pull request #32073 from apple/re-enable-test-56959761
shahmishal May 29, 2020
4bf0ddb
Merge pull request #32016 from apple/martinboehme-patch-2
martinboehme May 29, 2020
c63153d
Merge pull request #32069 from dan-zheng/autodiff-branching-casts
dan-zheng May 29, 2020
56c8eba
[SIL] Fix `alloc_stack [dynamic_lifetime]` attribute cloning.
dan-zheng May 27, 2020
f9c5d7a
[AutoDiff] Derive `Differentiable.zeroTangentVectorInitializer`. (#31…
dan-zheng May 29, 2020
ff97ae7
[AutoDiff] Fix SIL locations and debug scopes.
dan-zheng May 27, 2020
d3a9831
Merge pull request #32042 from davezarzycki/pr32042
davezarzycki May 29, 2020
f58e7b2
Merge pull request #32059 from davezarzycki/pr32059
davezarzycki May 29, 2020
1a770a3
Merge pull request #31913 from martinboehme/autolink-c-pragma
martinboehme May 29, 2020
15ea3fe
Merge branch 'master' into martinboehme-patch-1
martinboehme May 29, 2020
b4a202c
Merge pull request #32055 from eeckstein/array-changes
eeckstein May 29, 2020
ff3eca4
Merge pull request #32076 from compnerd/switching-strings
compnerd May 29, 2020
9bde41a
Merge pull request #32066 from compnerd/small-change-for-small-vector
compnerd May 29, 2020
94ff157
Merge pull request #32070 from xymus/spi-swiftdoc
xymus May 29, 2020
99a0919
[Fast Dependency Scanner] Ensure Swift modules don't depend on self.
artemcm May 29, 2020
68ba9cf
Merge pull request #32034 from slavapestov/optimize-remove-shadowed-d…
slavapestov May 29, 2020
bdef1ce
[metadata prespecialization] Support for classes.
nate-chandler Dec 20, 2019
2433646
Add debug output for vtable layout
jckarter May 29, 2020
26125f5
Merge pull request #32083 from artemcm/RecycleYourSwiftModules
artemcm May 29, 2020
8c70a96
Merge pull request #32031 from dan-zheng/fix-alloc-stack-cloning
dan-zheng May 29, 2020
9737ce0
[ConstraintSystem] Add missing handling of `Stmt *` to `getLoc`
xedin May 30, 2020
5204af3
Merge pull request #30089 from nate-chandler/generic-metadata-prespec…
nate-chandler May 30, 2020
124808d
Merge pull request #32088 from jckarter/final-keypath-methods
jckarter May 30, 2020
7469101
[test] Shortened filenames for Windows.
nate-chandler May 30, 2020
5f0c225
Merge pull request #32098 from nate-chandler/filenames
nate-chandler May 30, 2020
3befe2f
Merge pull request #32010 from varungandhi-apple/vg-loss-of-trust
shahmishal May 30, 2020
e6bcc15
Merge pull request #32095 from xedin/add-stmt-to-getLoc
xedin May 30, 2020
88b804b
Merge pull request #32007 from apple/martinboehme-patch-1
martinboehme May 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,20 @@ set(SWIFT_COMPILER_VERSION "" CACHE STRING
set(CLANG_COMPILER_VERSION "" CACHE STRING
"The internal version of the Clang compiler")

# Indicate whether Swift should attempt to use the lld linker.
if(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(SWIFT_ENABLE_LLD_LINKER_default TRUE)
# Which default linker to use. Prefer LLVM_USE_LINKER if it set, otherwise use
# our own defaults. This should only be possible in a unified (not stand alone)
# build environment.
if(LLVM_USE_LINKER)
set(SWIFT_USE_LINKER_default "${LLVM_USE_LINKER}")
elseif(CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
set(SWIFT_USE_LINKER_default "lld")
elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_USE_LINKER_default "")
else()
set(SWIFT_ENABLE_LLD_LINKER_default FALSE)
set(SWIFT_USE_LINKER_default "gold")
endif()
set(SWIFT_ENABLE_LLD_LINKER ${SWIFT_ENABLE_LLD_LINKER_default} CACHE BOOL
"Enable using the lld linker when available")

# Indicate whether Swift should attempt to use the gold linker.
# This is not used on Darwin.
if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL Windows)
set(SWIFT_ENABLE_GOLD_LINKER_default FALSE)
else()
set(SWIFT_ENABLE_GOLD_LINKER_default TRUE)
endif()
set(SWIFT_ENABLE_GOLD_LINKER ${SWIFT_ENABLE_GOLD_LINKER_default} CACHE BOOL
"Enable using the gold linker when available")
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
"Build Swift with a non-default linker")

set(SWIFT_TOOLS_ENABLE_LTO OFF CACHE STRING "Build Swift tools with LTO. One
must specify the form of LTO by setting this to one of: 'full', 'thin'. This
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ with version 2 shipped with Ubuntu.

**Note:** For Ubuntu 20.04, use `libpython2-dev` in place of the libpython-dev package above.

Build instructions for Ubuntu 14.04 LTS can be found [here](docs/Ubuntu14.md).

### Getting Sources for Swift and Related Projects

First create a directory for all of the Swift sources:
Expand Down
9 changes: 3 additions & 6 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function(_add_host_variant_c_compile_link_flags name)
if(SWIFT_HOST_VARIANT_SDK STREQUAL ANDROID)
# lld can handle targeting the android build. However, if lld is not
# enabled, then fallback to the linker included in the android NDK.
if(NOT SWIFT_ENABLE_LLD_LINKER)
if(NOT SWIFT_USE_LINKER STREQUAL "lld")
swift_android_tools_path(${SWIFT_HOST_VARIANT_ARCH} tools_path)
target_compile_options(${name} PRIVATE -B${tools_path})
endif()
Expand Down Expand Up @@ -368,12 +368,9 @@ function(_add_host_variant_link_flags target)
endif()

if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
if(SWIFT_ENABLE_LLD_LINKER)
if(SWIFT_USE_LINKER)
target_link_options(${target} PRIVATE
-fuse-ld=lld$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
elseif(SWIFT_ENABLE_GOLD_LINKER)
target_link_options(${target} PRIVATE
-fuse-ld=gold$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
-fuse-ld=${SWIFT_USE_LINKER}$<$<STREQUAL:${CMAKE_HOST_SYSTEM_NAME},Windows>:.exe>)
endif()
endif()

Expand Down
10 changes: 2 additions & 8 deletions cmake/modules/AddSwiftUnittests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,9 @@ function(add_swift_unittest test_dirname)
_ENABLE_EXTENDED_ALIGNED_STORAGE)
endif()

find_program(LDLLD_PATH "ld.lld")
# Strangely, macOS finds lld and then can't find it when using -fuse-ld=
if(SWIFT_ENABLE_LLD_LINKER AND LDLLD_PATH AND NOT APPLE)
if(SWIFT_USE_LINKER)
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
LINK_FLAGS " -fuse-ld=lld")
elseif(SWIFT_ENABLE_GOLD_LINKER AND
"${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_OBJECT_FORMAT}" STREQUAL "ELF")
set_property(TARGET "${test_dirname}" APPEND_STRING PROPERTY
LINK_FLAGS " -fuse-ld=gold")
LINK_FLAGS " -fuse-ld=${SWIFT_USE_LINKER}")
endif()

if(SWIFT_ANALYZE_CODE_COVERAGE)
Expand Down
36 changes: 25 additions & 11 deletions docs/DifferentiableProgramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -1079,11 +1079,6 @@ public extension Differentiable where Self == TangentVector {
mutating func move(along direction: TangentVector) {
self += direction
}

@noDerivative
var zeroTangentVectorInitializer: () -> TangentVector {
{ .zero }
}
}
```

Expand Down Expand Up @@ -1144,8 +1139,8 @@ extension Array: Differentiable where Element: Differentiable {

@noDerivative
public var zeroTangentVectorInitializer: () -> TangentVector {
{ [count = self.count] in
TangentVector(Array(repeating: .zero, count: count))
{ [zeroInits = map(\.zeroTangentVectorInitializer)] in
TangentVector(zeroInits.map { $0() })
}
}
}
Expand Down Expand Up @@ -1238,8 +1233,15 @@ the same effective access level as their corresponding original properties.

A `move(along:)` method is synthesized with a body that calls `move(along:)` for
each pair of the original property and its corresponding property in
`TangentVector`. Similarly, `zeroTangentVector` is synthesized to return a
tangent vector that consists of each stored property's `zeroTangentVector`.
`TangentVector`.

Similarly, when memberwise derivation is possible,
`zeroTangentVectorInitializer` is synthesized to return a closure that captures
and calls each stored property's `zeroTangentVectorInitializer` closure.
When memberwise derivation is not possible (e.g. for custom user-defined
`TangentVector` types), `zeroTangentVectorInitializer` is synthesized as a
`{ TangentVector.zero }` closure.

Here's an example:

```swift
Expand All @@ -1251,14 +1253,17 @@ struct Foo<T: Differentiable, U: Differentiable>: @memberwise Differentiable {
@noDerivative let helperVariable: T

// The compiler synthesizes:
//
// struct TangentVector: Differentiable, AdditiveArithmetic {
// var x: T.TangentVector
// var y: U.TangentVector
// }
//
// mutating func move(along direction: TangentVector) {
// x.move(along: direction.x)
// y.move(along: direction.y)
// }
//
// @noDerivative
// var zeroTangentVectorInitializer: () -> TangentVector {
// { [xTanInit = x.zeroTangentVectorInitializer,
Expand All @@ -1278,16 +1283,25 @@ properties are declared to conform to `AdditiveArithmetic`. There are no
`@noDerivative` stored properties.

In these cases, the compiler will make `TangentVector` be a type alias for Self.
Method `move(along:)` and property `zeroTangentVector` will not be synthesized
because a default implementation already exists.
Method `move(along:)` will not be synthesized because a default implementation
already exists.

```swift
struct Point<T: Real>: @memberwise Differentiable, @memberwise AdditiveArithmetic {
// `x` and `y` are the "differentiation properties".
var x, y: T

// The compiler synthesizes:
//
// typealias TangentVector = Self
//
// @noDerivative
// var zeroTangentVectorInitializer: () -> TangentVector {
// { [xTanInit = x.zeroTangentVectorInitializer,
// yTanInit = y.zeroTangentVectorInitializer] in
// TangentVector(x: xTanInit(), y: yTanInit())
// }
// }
}
```

Expand Down
24 changes: 0 additions & 24 deletions docs/Ubuntu14.md

This file was deleted.

7 changes: 5 additions & 2 deletions docs/WindowsBuild.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Building Swift on Windows

Visual Studio 2017 or newer is needed to build Swift on Windows.
Visual Studio 2017 or newer is needed to build Swift on Windows. The free Community edition is sufficient to build Swift.

The commands below (with the exception of installing Visual Studio) must be entered in the "**x64 Native** Tools Command Prompt for VS2017" (or VS2019, VS2019 Preview depending on the Visual Studio that you are using) in the Start Menu. This sets environment variables to select the correct target platform.

Expand Down Expand Up @@ -32,7 +32,7 @@ The command above already installs Python 2 and 3. Alternatively, in the Visual

1. Install *Python 2*, either the 32-bit version (C:\Python27\\) or the 64-bit version (C:\Python27amd64\\)

> If you install the 64-bit version only, you will need to adjust `PYTHON_EXECUTABLE` below to `C:\Python27amd64\python.exe`
**Note:** If you install the 64-bit version only, you will need to adjust `PYTHON_EXECUTABLE` below to `C:\Python27amd64\python.exe`

2. Install *Python 3 64 bits (3.7.x)*

Expand Down Expand Up @@ -150,6 +150,9 @@ cmake -B "S:\b\toolchain" ^
ninja -C S:\b\toolchain
```

**Note:** If you installed only the 64-bit version of Python, you will need to adjust `PYTHON_EXECUTABLE` argument to `C:\Python27amd64\python.exe`


## Running Swift tests on Windows

```cmd
Expand Down
2 changes: 1 addition & 1 deletion include/swift/ABI/Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ struct TargetAnyClassMetadata : public TargetHeapMetadata<Runtime> {
using TargetMetadata<Runtime>::setClassISA;
#endif

// Note that ObjC classes does not have a metadata header.
// Note that ObjC classes do not have a metadata header.

/// The metadata for the superclass. This is null for the root class.
ConstTargetMetadataPointer<Runtime, swift::TargetClassMetadata> Superclass;
Expand Down
2 changes: 1 addition & 1 deletion include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ DECL_ATTR(available, Available,
CONTEXTUAL_SIMPLE_DECL_ATTR(final, Final,
OnClass | OnFunc | OnAccessor | OnVar | OnSubscript |
DeclModifier |
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIStableToRemove,
ABIBreakingToAdd | ABIBreakingToRemove | APIStableToAdd | APIStableToRemove,
2)
DECL_ATTR(objc, ObjC,
OnAbstractFunction | OnClass | OnProtocol | OnExtension | OnVar |
Expand Down
1 change: 1 addition & 0 deletions include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ IDENTIFIER(move)
IDENTIFIER(pullback)
IDENTIFIER(TangentVector)
IDENTIFIER(zero)
IDENTIFIER(zeroTangentVectorInitializer)

#undef IDENTIFIER
#undef IDENTIFIER_
Expand Down
12 changes: 11 additions & 1 deletion include/swift/AST/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,17 @@ class alignas(1 << TypeAlignInBits) TypeBase {
/// \returns The superclass of this type, or a null type if it has no
/// superclass.
Type getSuperclass(bool useArchetypes = true);


/// Retrieve the root class of this type by repeatedly retrieving the
/// superclass.
///
/// \param useArchetypes Whether to use context archetypes for outer generic
/// parameters if the class is nested inside a generic function.
///
/// \returns The base class of this type, or this type itself if it has no
/// superclasses.
Type getRootClass(bool useArchetypes = true);

/// True if this type is the exact superclass of another type.
///
/// \param ty The potential subclass.
Expand Down
4 changes: 2 additions & 2 deletions include/swift/Basic/LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace llvm {
template <typename T, unsigned N> class SmallPtrSet;
#if !defined(swiftCore_EXPORTS)
template <typename T> class SmallVectorImpl;
#endif
template <typename T, unsigned N> class SmallVector;
#endif
template <unsigned N> class SmallString;
template <typename T, unsigned N> class SmallSetVector;
#if !defined(swiftCore_EXPORTS)
Expand Down Expand Up @@ -86,8 +86,8 @@ namespace swift {
using llvm::SmallPtrSetImpl;
using llvm::SmallSetVector;
using llvm::SmallString;
using llvm::SmallVector;
#if !defined(swiftCore_EXPORTS)
using llvm::SmallVector;
using llvm::SmallVectorImpl;
#endif
using llvm::StringLiteral;
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Demangling/DemangleNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -287,5 +287,9 @@ NODE(OpaqueTypeDescriptorAccessorVar)
NODE(OpaqueReturnType)
CONTEXT_NODE(OpaqueReturnTypeOf)

// Added in Swift 5.3
NODE(CanonicalSpecializedGenericMetaclass)
NODE(CanonicalSpecializedGenericTypeMetadataAccessFunction)

#undef CONTEXT_NODE
#undef NODE
14 changes: 7 additions & 7 deletions include/swift/Demangling/TypeDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class TypeDecoder {
if (Node->getNumChildren() < 2)
return BuiltType();

SmallVector<BuiltType, 8> args;
llvm::SmallVector<BuiltType, 8> args;

const auto &genericArgs = Node->getChild(1);
if (genericArgs->getKind() != NodeKind::TypeList)
Expand Down Expand Up @@ -474,7 +474,7 @@ class TypeDecoder {
return BuiltType();

// Find the protocol list.
SmallVector<BuiltProtocolDecl, 8> Protocols;
llvm::SmallVector<BuiltProtocolDecl, 8> Protocols;
auto TypeList = Node->getChild(0);
if (TypeList->getKind() == NodeKind::ProtocolList &&
TypeList->getNumChildren() >= 1) {
Expand Down Expand Up @@ -576,7 +576,7 @@ class TypeDecoder {
return BuiltType();

bool hasParamFlags = false;
SmallVector<FunctionParam<BuiltType>, 8> parameters;
llvm::SmallVector<FunctionParam<BuiltType>, 8> parameters;
if (!decodeMangledFunctionInputType(Node->getChild(isThrow ? 1 : 0),
parameters, hasParamFlags))
return BuiltType();
Expand All @@ -598,9 +598,9 @@ class TypeDecoder {
}
case NodeKind::ImplFunctionType: {
auto calleeConvention = ImplParameterConvention::Direct_Unowned;
SmallVector<ImplFunctionParam<BuiltType>, 8> parameters;
SmallVector<ImplFunctionResult<BuiltType>, 8> results;
SmallVector<ImplFunctionResult<BuiltType>, 8> errorResults;
llvm::SmallVector<ImplFunctionParam<BuiltType>, 8> parameters;
llvm::SmallVector<ImplFunctionResult<BuiltType>, 8> results;
llvm::SmallVector<ImplFunctionResult<BuiltType>, 8> errorResults;
ImplFunctionTypeFlags flags;

for (unsigned i = 0; i < Node->getNumChildren(); i++) {
Expand Down Expand Up @@ -684,7 +684,7 @@ class TypeDecoder {
return decodeMangledType(Node->getChild(0));

case NodeKind::Tuple: {
SmallVector<BuiltType, 8> elements;
llvm::SmallVector<BuiltType, 8> elements;
std::string labels;
bool variadic = false;
for (auto &element : *Node) {
Expand Down
Loading