mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge remote-tracking branch 'origin/master' into master-rebranch
This commit is contained in:
@@ -250,6 +250,9 @@ public:
|
||||
/// Should we enable the dependency verifier for all primary files known to this frontend?
|
||||
bool EnableIncrementalDependencyVerifier = false;
|
||||
|
||||
/// The path of the swift-frontend executable.
|
||||
std::string MainExecutablePath;
|
||||
|
||||
/// The directory path we should use when print #include for the bridging header.
|
||||
/// By default, we include ImplicitObjCHeaderPath directly.
|
||||
llvm::Optional<std::string> BridgingHeaderDirForPrint;
|
||||
|
||||
@@ -266,10 +266,12 @@ struct ModuleInterfaceLoaderOptions {
|
||||
bool remarkOnRebuildFromInterface = false;
|
||||
bool disableInterfaceLock = false;
|
||||
bool disableImplicitSwiftModule = false;
|
||||
std::string mainExecutablePath;
|
||||
ModuleInterfaceLoaderOptions(const FrontendOptions &Opts):
|
||||
remarkOnRebuildFromInterface(Opts.RemarkOnRebuildFromModuleInterface),
|
||||
disableInterfaceLock(Opts.DisableInterfaceFileLock),
|
||||
disableImplicitSwiftModule(Opts.DisableImplicitModules) {}
|
||||
disableImplicitSwiftModule(Opts.DisableImplicitModules),
|
||||
mainExecutablePath(Opts.MainExecutablePath) {}
|
||||
ModuleInterfaceLoaderOptions() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ void CompilerInvocation::computeRuntimeResourcePathFromExecutablePath(
|
||||
}
|
||||
|
||||
void CompilerInvocation::setMainExecutablePath(StringRef Path) {
|
||||
FrontendOpts.MainExecutablePath = Path.str();
|
||||
llvm::SmallString<128> LibPath;
|
||||
computeRuntimeResourcePathFromExecutablePath(Path, LibPath);
|
||||
setRuntimeResourcePath(LibPath.str());
|
||||
|
||||
@@ -1268,6 +1268,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
|
||||
StringRef prebuiltCachePath,
|
||||
bool serializeDependencyHashes,
|
||||
bool trackSystemDependencies): SM(SM), Diags(Diags), ArgSaver(Allocator) {
|
||||
subInvocation.setMainExecutablePath(LoaderOpts.mainExecutablePath);
|
||||
inheritOptionsForBuildingInterface(searchPathOpts, langOpts);
|
||||
// Configure front-end input.
|
||||
auto &SubFEOpts = subInvocation.getFrontendOptions();
|
||||
|
||||
@@ -1908,11 +1908,7 @@ void irgen::updateLinkageForDefinition(IRGenModule &IGM,
|
||||
|
||||
// Everything externally visible is considered used in Swift.
|
||||
// That mostly means we need to be good at not marking things external.
|
||||
//
|
||||
// Exclude "main", because it should naturally be used, and because adding it
|
||||
// to llvm.used leaves a dangling use when the REPL attempts to discard
|
||||
// intermediate mains.
|
||||
if (LinkInfo::isUsed(IRL) && global->getName() != SWIFT_ENTRY_POINT_FUNCTION)
|
||||
if (LinkInfo::isUsed(IRL))
|
||||
IGM.addUsedGlobal(global);
|
||||
}
|
||||
|
||||
@@ -2003,11 +1999,7 @@ llvm::Function *irgen::createFunction(IRGenModule &IGM,
|
||||
|
||||
// Everything externally visible is considered used in Swift.
|
||||
// That mostly means we need to be good at not marking things external.
|
||||
//
|
||||
// Exclude "main", because it should naturally be used, and because adding it
|
||||
// to llvm.used leaves a dangling use when the REPL attempts to discard
|
||||
// intermediate mains.
|
||||
if (linkInfo.isUsed() && name != SWIFT_ENTRY_POINT_FUNCTION) {
|
||||
if (linkInfo.isUsed()) {
|
||||
IGM.addUsedGlobal(fn);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// REQUIRES: CPU=x86_64
|
||||
|
||||
sil_stage canonical
|
||||
import Builtin
|
||||
import Swift
|
||||
|
||||
sil private @foo : $@convention(thin) () -> () {
|
||||
bb0:
|
||||
@@ -43,12 +45,20 @@ bb0:
|
||||
return %1 : $()
|
||||
}
|
||||
|
||||
// CHECK-macho: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @frieda to i8*), i8* bitcast (i16* @__swift_reflection_version to i8*)], section "llvm.metadata"
|
||||
// CHECK-elf: @llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @frieda to i8*), i8* bitcast (i16* @__swift_reflection_version to i8*), i8* getelementptr inbounds ([0 x i8], [0 x i8]* @_swift1_autolink_entries, i32 0, i32 0)], section "llvm.metadata"
|
||||
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
|
||||
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
|
||||
%2 = integer_literal $Builtin.Int32, 0 // user: %3
|
||||
%3 = struct $Int32 (%2 : $Builtin.Int32) // user: %4
|
||||
return %3 : $Int32 // id: %4
|
||||
}
|
||||
|
||||
// CHECK-macho: @llvm.used = appending global [3 x i8*] [i8* bitcast (void ()* @frieda to i8*), i8* bitcast (i32 (i32, i8**)* @main to i8*), i8* bitcast (i16* @__swift_reflection_version to i8*)], section "llvm.metadata"
|
||||
// CHECK-elf: @llvm.used = appending global [4 x i8*] [i8* bitcast (void ()* @frieda to i8*), i8* bitcast (i32 (i32, i8**)* @main to i8*), i8* bitcast (i16* @__swift_reflection_version to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @_swift1_autolink_entries, i32 0, i32 0)], section "llvm.metadata"
|
||||
|
||||
// CHECK: define linkonce_odr hidden swiftcc void @qux()
|
||||
// CHECK: define hidden swiftcc void @fred()
|
||||
// CHECK: define{{( dllexport)?}}{{( protected)?}} swiftcc void @frieda()
|
||||
// CHECK: define{{( dllexport)?}}{{( protected)?}} i32 @main
|
||||
|
||||
// NEGATIVE-NOT: @foo
|
||||
// NEGATIVE-NOT: @bar
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// REQUIRES: rdar66283479
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-build-swift %s -o %t/a.out
|
||||
// RUN: %{python} %S/../Inputs/not.py "%target-run %t/a.out" 2>&1 | %{lldb-python} %utils/symbolicate-linux-fatal %t/a.out - | %{python} %utils/backtrace-check -u
|
||||
|
||||
Reference in New Issue
Block a user