Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d4c5b7a
reland: Emit coverage mappings for all modules
keith Jun 12, 2020
c7d7b1e
Add path remapping with -coverage-prefix-map to coverage data
keith Jun 4, 2020
e8fe229
Properly compute resource folder when linking statically
drexin Jul 28, 2020
c5e999d
Re-enable @available(macOS 11) test
beccadax Sep 3, 2020
07c379c
[Preset] Source compat suite cross compile for macOS arm64
shahmishal Aug 4, 2020
4000085
[Build System] Move host lipo step after install step
shahmishal Aug 13, 2020
e56821c
Remove old symlink before creating new symlink
shahmishal Aug 13, 2020
d5298f9
Clean up the whitespace in build-script
shahmishal Aug 14, 2020
a4356ab
[CMake] Remove a redundant and potentially incorrect check.
Jul 6, 2020
f9c6f3a
Merge pull request #33778 from brentdax/the-punchline-of-an-incredibl…
beccadax Sep 3, 2020
f82150b
Merge pull request #33678 from drexin/wip-backport-static-linking-5.3
drexin Sep 3, 2020
e178348
SILCombine: fix an assertion crash in SILCombine when casting AnyClas…
eeckstein Sep 1, 2020
8a07bc2
Merge pull request #33779 from apple/shahmishal/5.3-source-compat-suite
tkremenek Sep 3, 2020
3e1715e
[ConstraintSystem] Extend invalid function body fix to cover constrai…
xedin Sep 1, 2020
a28fd6b
Merge pull request #33785 from eeckstein/fix-sil-combine-5.3
eeckstein Sep 3, 2020
6c3e7a8
Merge pull request #33794 from xedin/rdar-65983237-5.3
xedin Sep 3, 2020
162d933
Disable LLDB tests in nightly package preset (67923799)
shahmishal Aug 28, 2020
b0fcffb
Merge pull request #33858 from apple/shahmishal/disable-5.3-lldb-test…
shahmishal Sep 8, 2020
6446e64
Disable the LLDB test for the right nightly preset
shahmishal Sep 9, 2020
4bb11cb
Merge remote-tracking branch 'swiftwasm/release/5.3' into katei-merge…
kateinoigakukun Sep 9, 2020
ba8362e
Stop ReplaceOpaqueTypesWithUnderlyingTypes recursion if it hits a fix…
jckarter Sep 9, 2020
377a3bd
Merge pull request #33880 from jckarter/replace-opaque-types-terminat…
tkremenek Sep 10, 2020
1d95eae
Merge pull request #31035 from martinboehme/emit-called-func
gribozavr Apr 22, 2020
e0d907d
Merge pull request #31272 from martinboehme/optimize-emit-clang-decl
gribozavr Apr 24, 2020
4a4796a
IRGen: Fix asserting local extern declarations.
3405691582 Sep 10, 2020
45e46eb
[5.3] Support cross compile Xcode toolchain for Apple Silicon (#33780)
shahmishal Sep 10, 2020
0535399
Fix glibc.modulemap generation
drexin Aug 5, 2020
da65420
Fix glibc.modulemap generation
drexin Aug 5, 2020
ac2b7c2
Merge pull request #33881 from aschwaighofer/irgen_fix_asserting_loca…
aschwaighofer Sep 11, 2020
865b3b7
Merge pull request #33899 from drexin/wip-fix-glibc-modulemap-5.3
DougGregor Sep 11, 2020
1aab800
Merge pull request #32389 from keith/ks/cp-wmo-coverage
DougGregor Sep 11, 2020
89edca6
Merge pull request #32416 from keith/ks/cp-coverage-relative
varungandhi-apple Sep 11, 2020
c6a5292
Merge remote-tracking branch 'apple/release/5.3' into katei-merge-5.3
kateinoigakukun Sep 12, 2020
58673c1
[WASM] Cleanup build directory
kateinoigakukun Sep 13, 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
17 changes: 0 additions & 17 deletions cmake/modules/DarwinSDKs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,6 @@ set(SUPPORTED_WATCHOS_ARCHS "armv7k")
set(SUPPORTED_WATCHOS_SIMULATOR_ARCHS "i386;arm64")
set(SUPPORTED_OSX_ARCHS "x86_64;arm64;arm64e")

# Get the SDK version from SDKSettings.
execute_process(
COMMAND "defaults" "read" "${CMAKE_OSX_SYSROOT}/SDKSettings.plist" "Version"
OUTPUT_VARIABLE SWIFT_OSX_SDK_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Remove the last component, if any. e.g. 10.15.26 -> 10.15
string(REGEX REPLACE "\([0-9]*[.][0-9]*\)[.][0-9]*" "\\1"
SWIFT_OSX_SDK_VERSION "${SWIFT_OSX_SDK_VERSION}")

if (${SWIFT_OSX_SDK_VERSION} STREQUAL "10.14" OR
${SWIFT_OSX_SDK_VERSION} STREQUAL "10.15")
set(SUPPORTED_OSX_ARCHS "x86_64")
else()
set(SUPPORTED_OSX_ARCHS "x86_64;arm64e")
endif()

is_sdk_requested(OSX swift_build_osx)
if(swift_build_osx)
configure_sdk_darwin(
Expand Down
17 changes: 13 additions & 4 deletions include/swift/AST/DiagnosticEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,19 @@ namespace swift {
}
}

bool hasDiagnostics() const {
return std::distance(Engine.TentativeDiagnostics.begin() +
PrevDiagnostics,
Engine.TentativeDiagnostics.end()) > 0;
bool hasErrors() const {
ArrayRef<Diagnostic> diagnostics(Engine.TentativeDiagnostics.begin() +
PrevDiagnostics,
Engine.TentativeDiagnostics.end());

for (auto &diagnostic : diagnostics) {
auto behavior = Engine.state.determineBehavior(diagnostic.getID());
if (behavior == DiagnosticState::Behavior::Fatal ||
behavior == DiagnosticState::Behavior::Error)
return true;
}

return false;
}

/// Abort and close this transaction and erase all diagnostics
Expand Down
3 changes: 3 additions & 0 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ ERROR(error_optimization_remark_pattern, none, "%0 in '%1'",
ERROR(error_invalid_debug_prefix_map, none,
"invalid argument '%0' to -debug-prefix-map; it must be of the form "
"'original=remapped'", (StringRef))
ERROR(error_invalid_coverage_prefix_map, none,
"invalid argument '%0' to -coverage-prefix-map; it must be of the form "
"'original=remapped'", (StringRef))


ERROR(error_unable_to_write_swift_ranges_file, none,
Expand Down
3 changes: 3 additions & 0 deletions include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ class IRGenOptions {
/// Path prefixes that should be rewritten in debug info.
PathRemapper DebugPrefixMap;

/// Path prefixes that should be rewritten in coverage info.
PathRemapper CoveragePrefixMap;

/// What level of debug info to generate.
IRGenDebugInfoLevel DebugInfoLevel : 2;

Expand Down
10 changes: 7 additions & 3 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ class CompilerInvocation {
bool parseArgs(ArrayRef<const char *> Args, DiagnosticEngine &Diags,
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
*ConfigurationFileBuffers = nullptr,
StringRef workingDirectory = {});
StringRef workingDirectory = {},
StringRef mainExecutablePath = {});

/// Sets specific options based on the given serialized Swift binary data.
///
Expand Down Expand Up @@ -213,8 +214,11 @@ class CompilerInvocation {
/// Computes the runtime resource path relative to the given Swift
/// executable.
static void computeRuntimeResourcePathFromExecutablePath(
StringRef mainExecutablePath,
llvm::SmallString<128> &runtimeResourcePath);
StringRef mainExecutablePath, bool shared,
llvm::SmallVectorImpl<char> &runtimeResourcePath);

/// Appends `lib/swift[_static]` to the given path
static void appendSwiftLibDir(llvm::SmallVectorImpl<char> &path, bool shared);

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

Expand Down
5 changes: 5 additions & 0 deletions include/swift/Frontend/FrontendOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ class FrontendOptions {
/// Indicates whether the action will immediately run code.
static bool isActionImmediate(ActionType);

/// Determines whether the static or shared resource folder is used.
/// When set to `true`, the default resource folder will be set to
/// '.../lib/swift', otherwise '.../lib/swift_static'.
bool UseSharedResourceFolder = true;

/// \return true if action only parses without doing other compilation steps.
static bool shouldActionOnlyParse(ActionType);

Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -719,4 +719,8 @@ def target_sdk_version : Separate<["-"], "target-sdk-version">,
def target_variant_sdk_version : Separate<["-"], "target-variant-sdk-version">,
HelpText<"The version of target variant SDK used for compilation">;


def use_static_resource_dir
: Flag<["-"], "use-static-resource-dir">,
HelpText<"Use resources in the static resource directory">;
} // end let Flags = [FrontendOption, NoDriverOption, HelpHidden]
3 changes: 3 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,9 @@ def gdwarf_types : Flag<["-"], "gdwarf-types">,
def debug_prefix_map : Separate<["-"], "debug-prefix-map">,
Flags<[FrontendOption]>,
HelpText<"Remap source paths in debug info">;
def coverage_prefix_map : Separate<["-"], "coverage-prefix-map">,
Flags<[FrontendOption]>,
HelpText<"Remap source paths in coverage info">;

def debug_info_format : Joined<["-"], "debug-info-format=">,
Flags<[FrontendOption]>,
Expand Down
4 changes: 2 additions & 2 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3059,8 +3059,8 @@ operator()(SubstitutableType *maybeOpaqueType) const {
}))
return maybeOpaqueType;

// If the type still contains opaque types, recur.
if (substTy->hasOpaqueArchetype()) {
// If the type changed, but still contains opaque types, recur.
if (!substTy->isEqual(maybeOpaqueType) && substTy->hasOpaqueArchetype()) {
return ::substOpaqueTypesWithUnderlyingTypes(
substTy, inContext, contextExpansion, isContextWholeModule);
}
Expand Down
13 changes: 13 additions & 0 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ static void validateDebugInfoArgs(DiagnosticEngine &diags,
for (auto A : args.getAllArgValues(options::OPT_debug_prefix_map))
if (A.find('=') == StringRef::npos)
diags.diagnose(SourceLoc(), diag::error_invalid_debug_prefix_map, A);

// Check for any -coverage-prefix-map options that aren't of the form
// 'original=remapped' (either side can be empty, however).
for (auto A : args.getAllArgValues(options::OPT_coverage_prefix_map))
if (A.find('=') == StringRef::npos)
diags.diagnose(SourceLoc(), diag::error_invalid_coverage_prefix_map, A);
}

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

if (Args.hasFlag(options::OPT_static_executable,
options::OPT_no_static_executable, false) ||
Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
false)) {
commandLine.push_back("-use-static-resource-dir");
}

std::string executable = getSwiftProgramPath();

// FIXME: This bypasses mechanisms like -v and -###. (SR-12119)
Expand Down
23 changes: 13 additions & 10 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "swift/Driver/Compilation.h"
#include "swift/Driver/Driver.h"
#include "swift/Driver/Job.h"
#include "swift/Frontend/Frontend.h"
#include "swift/Option/Options.h"
#include "clang/Basic/Version.h"
#include "clang/Driver/Util.h"
Expand Down Expand Up @@ -264,6 +265,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,

// Pass on file paths that should be remapped in debug info.
inputArgs.AddAllArgs(arguments, options::OPT_debug_prefix_map);
inputArgs.AddAllArgs(arguments, options::OPT_coverage_prefix_map);

// Pass through the values passed to -Xfrontend.
inputArgs.AddAllArgValues(arguments, options::OPT_Xfrontend);
Expand Down Expand Up @@ -523,6 +525,13 @@ ToolChain::constructInvocation(const CompileJobAction &job,
Arguments.push_back("-track-system-dependencies");
}

if (context.Args.hasFlag(options::OPT_static_executable,
options::OPT_no_static_executable, false) ||
context.Args.hasFlag(options::OPT_static_stdlib,
options::OPT_no_static_stdlib, false)) {
Arguments.push_back("-use-static-resource-dir");
}

context.Args.AddLastArg(
Arguments,
options::
Expand Down Expand Up @@ -1256,25 +1265,19 @@ void ToolChain::getClangLibraryPath(const ArgList &Args,
void ToolChain::getResourceDirPath(SmallVectorImpl<char> &resourceDirPath,
const llvm::opt::ArgList &args,
bool shared) const {
// FIXME: Duplicated from CompilerInvocation, but in theory the runtime
// library link path and the standard library module import path don't
// need to be the same.
if (const Arg *A = args.getLastArg(options::OPT_resource_dir)) {
StringRef value = A->getValue();
resourceDirPath.append(value.begin(), value.end());
} else if (!getTriple().isOSDarwin() && !getTriple().isOSWASI() && args.hasArg(options::OPT_sdk)) {
// for WASI, sdk option points to wasi-sysroot which doesn't have Swift toolchain
StringRef value = args.getLastArg(options::OPT_sdk)->getValue();
resourceDirPath.append(value.begin(), value.end());
llvm::sys::path::append(resourceDirPath, "usr", "lib",
shared ? "swift" : "swift_static");
llvm::sys::path::append(resourceDirPath, "usr");
CompilerInvocation::appendSwiftLibDir(resourceDirPath, shared);
} else {
auto programPath = getDriver().getSwiftProgramPath();
resourceDirPath.append(programPath.begin(), programPath.end());
llvm::sys::path::remove_filename(resourceDirPath); // remove /swift
llvm::sys::path::remove_filename(resourceDirPath); // remove /bin
llvm::sys::path::append(resourceDirPath, "lib",
shared ? "swift" : "swift_static");
CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
programPath, shared, resourceDirPath);
}

StringRef libSubDir = getPlatformNameForTriple(getTriple());
Expand Down
1 change: 1 addition & 0 deletions lib/Frontend/ArgsToFrontendOptionsConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ bool ArgsToFrontendOptionsConverter::convert(
Opts.EnableSourceImport |= Args.hasArg(OPT_enable_source_import);
Opts.ImportUnderlyingModule |= Args.hasArg(OPT_import_underlying_module);
Opts.EnableIncrementalDependencyVerifier |= Args.hasArg(OPT_verify_incremental_dependencies);
Opts.UseSharedResourceFolder = !Args.hasArg(OPT_use_static_resource_dir);

computeImportObjCHeaderOptions();
computeImplicitImportModuleNames();
Expand Down
31 changes: 24 additions & 7 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,25 @@ swift::CompilerInvocation::CompilerInvocation() {
}

void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
StringRef mainExecutablePath, llvm::SmallString<128> &runtimeResourcePath) {
runtimeResourcePath.assign(mainExecutablePath);
StringRef mainExecutablePath, bool shared,
llvm::SmallVectorImpl<char> &runtimeResourcePath) {
runtimeResourcePath.append(mainExecutablePath.begin(),
mainExecutablePath.end());

llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /swift
llvm::sys::path::remove_filename(runtimeResourcePath); // Remove /bin
llvm::sys::path::append(runtimeResourcePath, "lib", "swift");
appendSwiftLibDir(runtimeResourcePath, shared);
}

void CompilerInvocation::appendSwiftLibDir(llvm::SmallVectorImpl<char> &path,
bool shared) {
llvm::sys::path::append(path, "lib", shared ? "swift" : "swift_static");
}

void CompilerInvocation::setMainExecutablePath(StringRef Path) {
llvm::SmallString<128> LibPath;
computeRuntimeResourcePathFromExecutablePath(Path, LibPath);
computeRuntimeResourcePathFromExecutablePath(
Path, FrontendOpts.UseSharedResourceFolder, LibPath);
setRuntimeResourcePath(LibPath.str());

llvm::SmallString<128> DiagnosticDocsPath(Path);
Expand Down Expand Up @@ -1258,6 +1267,11 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.DebugPrefixMap.addMapping(SplitMap.first, SplitMap.second);
}

for (auto A : Args.getAllArgValues(options::OPT_coverage_prefix_map)) {
auto SplitMap = StringRef(A).split('=');
Opts.CoveragePrefixMap.addMapping(SplitMap.first, SplitMap.second);
}

for (const Arg *A : Args.filtered(OPT_Xcc)) {
StringRef Opt = A->getValue();
if (Opt.startswith("-D") || Opt.startswith("-U"))
Expand Down Expand Up @@ -1584,11 +1598,10 @@ static bool ParseMigratorArgs(MigratorOptions &Opts,
}

bool CompilerInvocation::parseArgs(
ArrayRef<const char *> Args,
DiagnosticEngine &Diags,
ArrayRef<const char *> Args, DiagnosticEngine &Diags,
SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>>
*ConfigurationFileBuffers,
StringRef workingDirectory) {
StringRef workingDirectory, StringRef mainExecutablePath) {
using namespace options;

if (Args.empty())
Expand Down Expand Up @@ -1619,6 +1632,10 @@ bool CompilerInvocation::parseArgs(
return true;
}

if (!mainExecutablePath.empty()) {
setMainExecutablePath(mainExecutablePath);
}

ParseModuleInterfaceArgs(ModuleInterfaceOpts, ParsedArgs);
SaveModuleInterfaceArgs(ModuleInterfaceOpts, FrontendOpts, ParsedArgs, Diags);

Expand Down
9 changes: 5 additions & 4 deletions lib/FrontendTool/FrontendTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2078,17 +2078,18 @@ int swift::performFrontend(ArrayRef<const char *> Args,
}

CompilerInvocation Invocation;
std::string MainExecutablePath = llvm::sys::fs::getMainExecutable(Argv0,
MainAddr);
Invocation.setMainExecutablePath(MainExecutablePath);

SmallString<128> workingDirectory;
llvm::sys::fs::current_path(workingDirectory);

std::string MainExecutablePath =
llvm::sys::fs::getMainExecutable(Argv0, MainAddr);

// Parse arguments.
SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 4> configurationFileBuffers;
if (Invocation.parseArgs(Args, Instance->getDiags(),
&configurationFileBuffers, workingDirectory)) {
&configurationFileBuffers, workingDirectory,
MainExecutablePath)) {
return finishDiagProcessing(1, /*verifierEnabled*/ false);
}

Expand Down
47 changes: 37 additions & 10 deletions lib/IRGen/GenClangDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,43 @@ class ClangDeclRefFinder
return true;
}
};

// If any (re)declaration of `decl` contains executable code, returns that
// redeclaration; otherwise, returns nullptr.
// In the case of a function, executable code is contained in the function
// definition. In the case of a variable, executable code can be contained in
// the initializer of the variable.
clang::Decl *getDeclWithExecutableCode(clang::Decl *decl) {
if (auto fd = dyn_cast<clang::FunctionDecl>(decl)) {
const clang::FunctionDecl *definition;
if (fd->hasBody(definition)) {
return const_cast<clang::FunctionDecl *>(definition);
}
} else if (auto vd = dyn_cast<clang::VarDecl>(decl)) {
clang::VarDecl *initializingDecl = vd->getInitializingDeclaration();
if (initializingDecl) {
return initializingDecl;
}
}

return nullptr;
}

} // end anonymous namespace

void IRGenModule::emitClangDecl(const clang::Decl *decl) {
auto valueDecl = dyn_cast<clang::ValueDecl>(decl);
if (!valueDecl || valueDecl->isExternallyVisible()) {
// Ignore this decl if we've seen it before.
if (!GlobalClangDecls.insert(decl->getCanonicalDecl()).second)
return;

// Fast path for the case where `decl` doesn't contain executable code, so it
// can't reference any other declarations that we would need to emit.
if (getDeclWithExecutableCode(const_cast<clang::Decl *>(decl)) == nullptr) {
ClangCodeGen->HandleTopLevelDecl(
clang::DeclGroupRef(const_cast<clang::Decl*>(decl)));
return;
}

if (!GlobalClangDecls.insert(decl->getCanonicalDecl()).second)
return;
SmallVector<const clang::Decl *, 8> stack;
stack.push_back(decl);

Expand All @@ -69,13 +94,15 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {

while (!stack.empty()) {
auto *next = const_cast<clang::Decl *>(stack.pop_back_val());
if (auto fn = dyn_cast<clang::FunctionDecl>(next)) {
const clang::FunctionDecl *definition;
if (fn->hasBody(definition)) {
refFinder.TraverseDecl(const_cast<clang::FunctionDecl *>(definition));
next = const_cast<clang::FunctionDecl *>(definition);
}
if (clang::Decl *executableDecl = getDeclWithExecutableCode(next)) {
refFinder.TraverseDecl(executableDecl);
next = executableDecl;
}

if (auto var = dyn_cast<clang::VarDecl>(next))
if (!var->isFileVarDecl())
continue;

ClangCodeGen->HandleTopLevelDecl(clang::DeclGroupRef(next));
}
}
Expand Down
Loading