Skip to content

Commit 0a0215b

Browse files
Merge pull request #1724 from swiftwasm/katei-merge-5.3
Upstream merge 5.3
2 parents 335c349 + 58673c1 commit 0a0215b

Some content is hidden

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

55 files changed

+725
-113
lines changed

cmake/modules/DarwinSDKs.cmake

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,6 @@ set(SUPPORTED_WATCHOS_ARCHS "armv7k")
1616
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64")
1717
set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e")
1818

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()
35-
3619
is_sdk_requested(OSX swift_build_osx)
3720
if(swift_build_osx)
3821
configure_sdk_darwin(

include/swift/AST/DiagnosticEngine.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,10 +1025,19 @@ namespace swift {
10251025
}
10261026
}
10271027

1028-
bool hasDiagnostics() const {
1029-
return std::distance(Engine.TentativeDiagnostics.begin() +
1030-
PrevDiagnostics,
1031-
Engine.TentativeDiagnostics.end()) > 0;
1028+
bool hasErrors() const {
1029+
ArrayRef<Diagnostic> diagnostics(Engine.TentativeDiagnostics.begin() +
1030+
PrevDiagnostics,
1031+
Engine.TentativeDiagnostics.end());
1032+
1033+
for (auto &diagnostic : diagnostics) {
1034+
auto behavior = Engine.state.determineBehavior(diagnostic.getID());
1035+
if (behavior == DiagnosticState::Behavior::Fatal ||
1036+
behavior == DiagnosticState::Behavior::Error)
1037+
return true;
1038+
}
1039+
1040+
return false;
10321041
}
10331042

10341043
/// Abort and close this transaction and erase all diagnostics

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ ERROR(error_optimization_remark_pattern, none, "%0 in '%1'",
301301
ERROR(error_invalid_debug_prefix_map, none,
302302
"invalid argument '%0' to -debug-prefix-map; it must be of the form "
303303
"'original=remapped'", (StringRef))
304+
ERROR(error_invalid_coverage_prefix_map, none,
305+
"invalid argument '%0' to -coverage-prefix-map; it must be of the form "
306+
"'original=remapped'", (StringRef))
304307

305308

306309
ERROR(error_unable_to_write_swift_ranges_file, none,

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ class IRGenOptions {
169169
/// Path prefixes that should be rewritten in debug info.
170170
PathRemapper DebugPrefixMap;
171171

172+
/// Path prefixes that should be rewritten in coverage info.
173+
PathRemapper CoveragePrefixMap;
174+
172175
/// What level of debug info to generate.
173176
IRGenDebugInfoLevel DebugInfoLevel : 2;
174177

include/swift/Frontend/Frontend.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ class CompilerInvocation {
128128
bool parseArgs(ArrayRef<const char *> Args, DiagnosticEngine &Diags,
129129
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
130130
*ConfigurationFileBuffers = nullptr,
131-
StringRef workingDirectory = {});
131+
StringRef workingDirectory = {},
132+
StringRef mainExecutablePath = {});
132133

133134
/// Sets specific options based on the given serialized Swift binary data.
134135
///
@@ -213,8 +214,11 @@ class CompilerInvocation {
213214
/// Computes the runtime resource path relative to the given Swift
214215
/// executable.
215216
static void computeRuntimeResourcePathFromExecutablePath(
216-
StringRef mainExecutablePath,
217-
llvm::SmallString<128> &runtimeResourcePath);
217+
StringRef mainExecutablePath, bool shared,
218+
llvm::SmallVectorImpl<char> &runtimeResourcePath);
219+
220+
/// Appends `lib/swift[_static]` to the given path
221+
static void appendSwiftLibDir(llvm::SmallVectorImpl<char> &path, bool shared);
218222

219223
void setSDKPath(const std::string &Path);
220224

include/swift/Frontend/FrontendOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ class FrontendOptions {
301301
/// Indicates whether the action will immediately run code.
302302
static bool isActionImmediate(ActionType);
303303

304+
/// Determines whether the static or shared resource folder is used.
305+
/// When set to `true`, the default resource folder will be set to
306+
/// '.../lib/swift', otherwise '.../lib/swift_static'.
307+
bool UseSharedResourceFolder = true;
308+
304309
/// \return true if action only parses without doing other compilation steps.
305310
static bool shouldActionOnlyParse(ActionType);
306311

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,4 +719,8 @@ def target_sdk_version : Separate<["-"], "target-sdk-version">,
719719
def target_variant_sdk_version : Separate<["-"], "target-variant-sdk-version">,
720720
HelpText<"The version of target variant SDK used for compilation">;
721721

722+
723+
def use_static_resource_dir
724+
: Flag<["-"], "use-static-resource-dir">,
725+
HelpText<"Use resources in the static resource directory">;
722726
} // end let Flags = [FrontendOption, NoDriverOption, HelpHidden]

include/swift/Option/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@ def gdwarf_types : Flag<["-"], "gdwarf-types">,
708708
def debug_prefix_map : Separate<["-"], "debug-prefix-map">,
709709
Flags<[FrontendOption]>,
710710
HelpText<"Remap source paths in debug info">;
711+
def coverage_prefix_map : Separate<["-"], "coverage-prefix-map">,
712+
Flags<[FrontendOption]>,
713+
HelpText<"Remap source paths in coverage info">;
711714

712715
def debug_info_format : Joined<["-"], "debug-info-format=">,
713716
Flags<[FrontendOption]>,

lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,8 +3059,8 @@ operator()(SubstitutableType *maybeOpaqueType) const {
30593059
}))
30603060
return maybeOpaqueType;
30613061

3062-
// If the type still contains opaque types, recur.
3063-
if (substTy->hasOpaqueArchetype()) {
3062+
// If the type changed, but still contains opaque types, recur.
3063+
if (!substTy->isEqual(maybeOpaqueType) && substTy->hasOpaqueArchetype()) {
30643064
return ::substOpaqueTypesWithUnderlyingTypes(
30653065
substTy, inContext, contextExpansion, isContextWholeModule);
30663066
}

lib/Driver/Driver.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ static void validateDebugInfoArgs(DiagnosticEngine &diags,
179179
for (auto A : args.getAllArgValues(options::OPT_debug_prefix_map))
180180
if (A.find('=') == StringRef::npos)
181181
diags.diagnose(SourceLoc(), diag::error_invalid_debug_prefix_map, A);
182+
183+
// Check for any -coverage-prefix-map options that aren't of the form
184+
// 'original=remapped' (either side can be empty, however).
185+
for (auto A : args.getAllArgValues(options::OPT_coverage_prefix_map))
186+
if (A.find('=') == StringRef::npos)
187+
diags.diagnose(SourceLoc(), diag::error_invalid_coverage_prefix_map, A);
182188
}
183189

184190
static void validateVerifyIncrementalDependencyArgs(DiagnosticEngine &diags,
@@ -2233,6 +2239,13 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) {
22332239
commandLine.push_back(resourceDirArg->getValue());
22342240
}
22352241

2242+
if (Args.hasFlag(options::OPT_static_executable,
2243+
options::OPT_no_static_executable, false) ||
2244+
Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
2245+
false)) {
2246+
commandLine.push_back("-use-static-resource-dir");
2247+
}
2248+
22362249
std::string executable = getSwiftProgramPath();
22372250

22382251
// FIXME: This bypasses mechanisms like -v and -###. (SR-12119)

0 commit comments

Comments
 (0)