Skip to content

Commit c1b336b

Browse files
Merge remote-tracking branch 'apple/master' into katei/merge-master-2020-07-06
2 parents 53b3064 + 9c20198 commit c1b336b

File tree

129 files changed

+3250
-389
lines changed

Some content is hidden

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

129 files changed

+3250
-389
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,12 @@ if(SWIFT_PATH_TO_CMARK_BUILD)
458458
endif()
459459
message(STATUS "")
460460

461+
if("${SWIFT_NATIVE_LLVM_TOOLS_PATH}" STREQUAL "")
462+
set(SWIFT_CROSS_COMPILING FALSE)
463+
else()
464+
set(SWIFT_CROSS_COMPILING TRUE)
465+
endif()
466+
461467
include(SwiftSharedCMakeConfig)
462468

463469
# NOTE: We include this before SwiftComponents as it relies on some LLVM CMake

benchmark/cmake/modules/AddSwiftBenchmarkSuite.cmake

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ macro(configure_build)
105105
endmacro()
106106

107107
macro(configure_sdks_darwin)
108-
set(macosx_arch "x86_64")
108+
set(macosx_arch "x86_64" "arm64")
109109
set(iphoneos_arch "arm64" "arm64e" "armv7")
110110
set(appletvos_arch "arm64")
111111
set(watchos_arch "armv7k")
@@ -609,11 +609,7 @@ function (swift_benchmark_compile_archopts)
609609

610610
if(is_darwin)
611611
# If host == target.
612-
if("${BENCH_COMPILE_ARCHOPTS_PLATFORM}" STREQUAL "macosx")
613-
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}")
614-
else()
615-
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}")
616-
endif()
612+
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}-${target}")
617613
else()
618614
# If we are on Linux, we do not support cross compiling.
619615
set(OUTPUT_EXEC "${benchmark-bin-dir}/Benchmark_${BENCH_COMPILE_ARCHOPTS_OPT}")

cmake/modules/DarwinSDKs.cmake

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,34 @@ option(SWIFT_ENABLE_IOS32
44

55
if(SWIFT_ENABLE_IOS32)
66
set(SUPPORTED_IOS_ARCHS "armv7;armv7s;arm64;arm64e")
7-
set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64")
7+
set(SUPPORTED_IOS_SIMULATOR_ARCHS "i386;x86_64;arm64")
88
else()
99
set(SUPPORTED_IOS_ARCHS "arm64;arm64e")
10-
set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64")
10+
set(SUPPORTED_IOS_SIMULATOR_ARCHS "x86_64;arm64")
1111
endif()
1212

1313
set(SUPPORTED_TVOS_ARCHS "arm64")
14-
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64")
14+
set(SUPPORTED_TVOS_SIMULATOR_ARCHS "x86_64;arm64")
1515
set(SUPPORTED_WATCHOS_ARCHS "armv7k")
16-
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386")
17-
set(SUPPORTED_OSX_ARCHS "x86_64")
16+
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64")
17+
set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e")
18+
19+
# Get the SDK version from SDKSettings.
20+
execute_process(
21+
COMMAND "defaults" "read" "${CMAKE_OSX_SYSROOT}/SDKSettings.plist" "Version"
22+
OUTPUT_VARIABLE SWIFT_OSX_SDK_VERSION
23+
OUTPUT_STRIP_TRAILING_WHITESPACE)
24+
25+
# Remove the last component, if any. e.g. 10.15.26 -> 10.15
26+
string(REGEX REPLACE "\([0-9]*[.][0-9]*\)[.][0-9]*" "\\1"
27+
SWIFT_OSX_SDK_VERSION "${SWIFT_OSX_SDK_VERSION}")
28+
29+
if (${SWIFT_OSX_SDK_VERSION} STREQUAL "10.14" OR
30+
${SWIFT_OSX_SDK_VERSION} STREQUAL "10.15")
31+
set(SUPPORTED_OSX_ARCHS "x86_64")
32+
else()
33+
set(SUPPORTED_OSX_ARCHS "x86_64;arm64e")
34+
endif()
1835

1936
is_sdk_requested(OSX swift_build_osx)
2037
if(swift_build_osx)

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,38 @@ function(_report_sdk prefix)
8585
message(STATUS "")
8686
endfunction()
8787

88+
# Remove architectures not supported by the SDK from the given list.
89+
function(remove_sdk_unsupported_archs name os sdk_path architectures_var)
90+
execute_process(COMMAND
91+
/usr/libexec/PlistBuddy -c "Print :SupportedTargets:${os}:Archs" ${sdk_path}/SDKSettings.plist
92+
OUTPUT_VARIABLE sdk_supported_archs
93+
RESULT_VARIABLE plist_error)
94+
95+
if (NOT plist_error EQUAL 0)
96+
message(STATUS "${os} SDK at ${sdk_path} does not publish its supported architectures")
97+
return()
98+
endif()
99+
100+
set(architectures)
101+
foreach(arch ${${architectures_var}})
102+
if(sdk_supported_archs MATCHES "${arch}\n")
103+
list(APPEND architectures ${arch})
104+
elseif(arch MATCHES "^armv7(s)?$" AND os STREQUAL "iphoneos")
105+
# 32-bit iOS is not listed explicitly in SDK settings.
106+
message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}")
107+
list(APPEND architectures ${arch})
108+
elseif(arch STREQUAL "i386" AND os STREQUAL "iphonesimulator")
109+
# 32-bit iOS simulatoris not listed explicitly in SDK settings.
110+
message(STATUS "Assuming ${name} SDK at ${sdk_path} supports architecture ${arch}")
111+
list(APPEND architectures ${arch})
112+
else()
113+
message(STATUS "${name} SDK at ${sdk_path} does not support architecture ${arch}")
114+
endif()
115+
endforeach()
116+
117+
set("${architectures_var}" ${architectures} PARENT_SCOPE)
118+
endfunction()
119+
88120
# Configure an SDK
89121
#
90122
# Usage:
@@ -164,6 +196,9 @@ macro(configure_sdk_darwin
164196
SWIFT_SDK_${prefix}_ARCHITECTURES) # result
165197
endif()
166198

199+
# Remove any architectures not supported by the SDK.
200+
remove_sdk_unsupported_archs(${name} ${xcrun_name} ${SWIFT_SDK_${prefix}_PATH} SWIFT_SDK_${prefix}_ARCHITECTURES)
201+
167202
list_intersect(
168203
"${SWIFT_DARWIN_MODULE_ARCHS}" # lhs
169204
"${architectures}" # rhs

cmake/modules/SwiftSharedCMakeConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ macro(swift_common_standalone_build_config_llvm product)
5858
fix_imported_targets_for_xcode("${LLVM_EXPORTED_TARGETS}")
5959
endif()
6060

61-
if(NOT CMAKE_CROSSCOMPILING)
61+
if(NOT CMAKE_CROSSCOMPILING AND NOT SWIFT_CROSS_COMPILING)
6262
set(${product}_NATIVE_LLVM_TOOLS_PATH "${LLVM_TOOLS_BINARY_DIR}")
6363
endif()
6464

include/swift/AST/AvailabilitySpec.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,33 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
6868
SourceLoc PlatformLoc;
6969

7070
llvm::VersionTuple Version;
71+
72+
// For macOS Big Sur, we canonicalize 10.16 to 11.0 for compile-time
73+
// checking since clang canonicalizes availability markup. However, to
74+
// support Beta versions of macOS Big Sur where the OS
75+
// reports 10.16 at run time, we need to compare against 10.16,
76+
//
77+
// This means for:
78+
//
79+
// if #available(macOS 10.16, *) { ... }
80+
//
81+
// we need to keep around both a canonical version for use in compile-time
82+
// checks and an uncanonicalized version for the version to actually codegen
83+
// with.
84+
llvm::VersionTuple RuntimeVersion;
85+
7186
SourceRange VersionSrcRange;
7287

7388
public:
7489
PlatformVersionConstraintAvailabilitySpec(PlatformKind Platform,
7590
SourceLoc PlatformLoc,
7691
llvm::VersionTuple Version,
92+
llvm::VersionTuple RuntimeVersion,
7793
SourceRange VersionSrcRange)
7894
: AvailabilitySpec(AvailabilitySpecKind::PlatformVersionConstraint),
7995
Platform(Platform),
8096
PlatformLoc(PlatformLoc), Version(Version),
97+
RuntimeVersion(RuntimeVersion),
8198
VersionSrcRange(VersionSrcRange) {}
8299

83100
/// The required platform.
@@ -93,6 +110,11 @@ class PlatformVersionConstraintAvailabilitySpec : public AvailabilitySpec {
93110
llvm::VersionTuple getVersion() const { return Version; }
94111
SourceRange getVersionSrcRange() const { return VersionSrcRange; }
95112

113+
// The version to be used in codegen for version comparisons at run time.
114+
// This is required to support beta versions of macOS Big Sur that
115+
// report 10.16 at run time.
116+
llvm::VersionTuple getRuntimeVersion() const { return RuntimeVersion; }
117+
96118
SourceRange getSourceRange() const;
97119

98120
void print(raw_ostream &OS, unsigned Indent) const;

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,6 +3151,8 @@ ERROR(autodiff_attr_original_multiple_semantic_results,none,
31513151
ERROR(autodiff_attr_result_not_differentiable,none,
31523152
"can only differentiate functions with results that conform to "
31533153
"'Differentiable', but %0 does not conform to 'Differentiable'", (Type))
3154+
ERROR(autodiff_attr_opaque_result_type_unsupported,none,
3155+
"cannot differentiate functions returning opaque result types", ())
31543156

31553157
// differentiation `wrt` parameters clause
31563158
ERROR(diff_function_no_parameters,none,

include/swift/AST/PlatformKind.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/Basic/LLVM.h"
2121
#include "swift/Config.h"
2222
#include "llvm/ADT/StringRef.h"
23+
#include "llvm/Support/VersionTuple.h"
2324

2425
namespace swift {
2526

@@ -65,6 +66,9 @@ PlatformKind targetPlatform(const LangOptions &LangOpts);
6566
/// an explicit attribute for the child.
6667
bool inheritsAvailabilityFromPlatform(PlatformKind Child, PlatformKind Parent);
6768

69+
llvm::VersionTuple canonicalizePlatformVersion(
70+
PlatformKind platform, const llvm::VersionTuple &version);
71+
6872
} // end namespace swift
6973

7074
#endif

include/swift/AST/SubstitutionMap.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,12 @@ class SubstitutionMap {
286286
Type lookupSubstitution(CanSubstitutableType type) const;
287287
};
288288

289+
inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
290+
const SubstitutionMap &subs) {
291+
subs.dump(OS);
292+
return OS;
293+
}
294+
289295
/// A function object suitable for use as a \c TypeSubstitutionFn that
290296
/// queries an underlying \c SubstitutionMap.
291297
struct QuerySubstitutionMap {

include/swift/AST/TypeCheckRequests.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,7 +2192,7 @@ class DerivativeAttrOriginalDeclRequest
21922192
/// property in a `Differentiable`-conforming type.
21932193
class TangentStoredPropertyRequest
21942194
: public SimpleRequest<TangentStoredPropertyRequest,
2195-
TangentPropertyInfo(VarDecl *),
2195+
TangentPropertyInfo(VarDecl *, CanType),
21962196
RequestFlags::Cached> {
21972197
public:
21982198
using SimpleRequest::SimpleRequest;
@@ -2201,8 +2201,8 @@ class TangentStoredPropertyRequest
22012201
friend SimpleRequest;
22022202

22032203
// Evaluation.
2204-
TangentPropertyInfo evaluate(Evaluator &evaluator,
2205-
VarDecl *originalField) const;
2204+
TangentPropertyInfo evaluate(Evaluator &evaluator, VarDecl *originalField,
2205+
CanType parentType) const;
22062206

22072207
public:
22082208
// Caching.

0 commit comments

Comments
 (0)