From 71309a8fa95fe9f4c755804316bacb68fe0a2e5c Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sun, 7 Jun 2020 11:25:48 -0700 Subject: [PATCH] Revert "[LTO] Support LLVM level link time optimization on Darwin, Linux and Windows" --- include/swift/AST/IRGenOptions.h | 9 --- include/swift/Driver/Action.h | 7 +- include/swift/Driver/Driver.h | 8 --- include/swift/Option/Options.td | 4 -- lib/Driver/DarwinToolChains.cpp | 28 +------- lib/Driver/Driver.cpp | 31 ++------ lib/Driver/ToolChains.cpp | 5 -- lib/Driver/ToolChains.h | 3 - lib/Driver/UnixToolChains.cpp | 26 +------ lib/Driver/WindowsToolChains.cpp | 71 ++++--------------- lib/Frontend/CompilerInvocation.cpp | 11 --- lib/IRGen/IRGen.cpp | 9 +-- lib/IRGen/IRGenModule.cpp | 27 ++----- test/Driver/Inputs/lto/lib.swift | 1 - test/Driver/Inputs/lto/main.swift | 3 - test/Driver/Inputs/lto/multifiles/file.swift | 3 - test/Driver/Inputs/lto/multifiles/main.swift | 1 - test/Driver/link-time-opt-lib-thin.swift | 12 ---- test/Driver/link-time-opt-lib.swift | 5 -- .../Driver/link-time-opt-staticlib-thin.swift | 14 ---- test/Driver/link-time-opt-staticlib.swift | 6 -- test/Driver/link-time-opt.swift | 5 -- utils/build-windows.bat | 3 +- 23 files changed, 36 insertions(+), 256 deletions(-) delete mode 100644 test/Driver/Inputs/lto/lib.swift delete mode 100644 test/Driver/Inputs/lto/main.swift delete mode 100644 test/Driver/Inputs/lto/multifiles/file.swift delete mode 100644 test/Driver/Inputs/lto/multifiles/main.swift delete mode 100644 test/Driver/link-time-opt-lib-thin.swift delete mode 100644 test/Driver/link-time-opt-lib.swift delete mode 100644 test/Driver/link-time-opt-staticlib-thin.swift delete mode 100644 test/Driver/link-time-opt-staticlib.swift delete mode 100644 test/Driver/link-time-opt.swift diff --git a/include/swift/AST/IRGenOptions.h b/include/swift/AST/IRGenOptions.h index 31d14627e093e..279fdcefb3c4e 100644 --- a/include/swift/AST/IRGenOptions.h +++ b/include/swift/AST/IRGenOptions.h @@ -65,12 +65,6 @@ enum class IRGenDebugInfoFormat : unsigned { CodeView }; -enum class IRGenLLVMLTOKind : unsigned { - None, - Thin, - Full -}; - enum class IRGenEmbedMode : unsigned { None, EmbedMarker, @@ -223,8 +217,6 @@ class IRGenOptions { /// Whether we should embed the bitcode file. IRGenEmbedMode EmbedMode : 2; - IRGenLLVMLTOKind LLVMLTOKind: 2; - /// Add names to LLVM values. unsigned HasValueNamesSetting : 1; unsigned ValueNames : 1; @@ -326,7 +318,6 @@ class IRGenOptions { DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false), Playground(false), EmitStackPromotionChecks(false), FunctionSections(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None), - LLVMLTOKind(IRGenLLVMLTOKind::None), HasValueNamesSetting(false), ValueNames(false), EnableReflectionMetadata(true), EnableReflectionNames(true), EnableAnonymousContextMangledNames(false), ForcePublicLinkage(false), diff --git a/include/swift/Driver/Action.h b/include/swift/Driver/Action.h index 3f787bace7714..02801d8aece66 100644 --- a/include/swift/Driver/Action.h +++ b/include/swift/Driver/Action.h @@ -328,19 +328,16 @@ class GeneratePCHJobAction : public JobAction { class DynamicLinkJobAction : public JobAction { virtual void anchor(); LinkKind Kind; - bool LTO; public: - DynamicLinkJobAction(ArrayRef Inputs, LinkKind K, bool LTO) + DynamicLinkJobAction(ArrayRef Inputs, LinkKind K) : JobAction(Action::Kind::DynamicLinkJob, Inputs, file_types::TY_Image), - Kind(K), LTO(LTO) { + Kind(K) { assert(Kind != LinkKind::None && Kind != LinkKind::StaticLibrary); } LinkKind getKind() const { return Kind; } - bool PerformLTO() const { return LTO; } - static bool classof(const Action *A) { return A->getKind() == Action::Kind::DynamicLinkJob; } diff --git a/include/swift/Driver/Driver.h b/include/swift/Driver/Driver.h index 018b2a468812b..5e055359d6346 100644 --- a/include/swift/Driver/Driver.h +++ b/include/swift/Driver/Driver.h @@ -101,14 +101,6 @@ class OutputInfo { /// The output type which should be used for compile actions. file_types::ID CompilerOutputType = file_types::ID::TY_INVALID; - enum class LTOKind { - None, - LLVMThin, - LLVMFull, - }; - - LTOKind LTOVariant = LTOKind::None; - /// Describes if and how the output of compile actions should be /// linked together. LinkKind LinkAction = LinkKind::None; diff --git a/include/swift/Option/Options.td b/include/swift/Option/Options.td index fd7992bad5ccf..0ca3c312b961c 100644 --- a/include/swift/Option/Options.td +++ b/include/swift/Option/Options.td @@ -515,10 +515,6 @@ def disable_bridging_pch : Flag<["-"], "disable-bridging-pch">, Flags<[HelpHidden]>, HelpText<"Disable automatic generation of bridging PCH files">; -def lto : Joined<["-"], "lto=">, - Flags<[FrontendOption, NoInteractiveOption]>, - HelpText<"Specify the LTO type to either 'llvm' or 'llvm-full'">; - // Experimental feature options // Note: this flag will be removed when JVP/differential generation in the diff --git a/lib/Driver/DarwinToolChains.cpp b/lib/Driver/DarwinToolChains.cpp index f50877d6db639..bfd3bd442d3cc 100644 --- a/lib/Driver/DarwinToolChains.cpp +++ b/lib/Driver/DarwinToolChains.cpp @@ -238,15 +238,12 @@ toolchains::Darwin::addLinkerInputArgs(InvocationInfo &II, Arguments.push_back("-filelist"); Arguments.push_back(context.getTemporaryFilePath("inputs", "LinkFileList")); II.FilelistInfos.push_back( - {Arguments.back(), context.OI.CompilerOutputType, + {Arguments.back(), file_types::TY_Object, FilelistInfo::WhichFiles::InputJobsAndSourceInputActions}); } else { addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); } @@ -309,20 +306,6 @@ toolchains::Darwin::addArgsToLinkARCLite(ArgStringList &Arguments, } } -void -toolchains::Darwin::addLTOLibArgs(ArgStringList &Arguments, - const JobContext &context) const { - llvm::SmallString<128> LTOLibPath; - if (findXcodeClangPath(LTOLibPath)) { - llvm::sys::path::remove_filename(LTOLibPath); // 'clang' - llvm::sys::path::remove_filename(LTOLibPath); // 'bin' - llvm::sys::path::append(LTOLibPath, "lib", "libLTO.dylib"); - - Arguments.push_back("-lto_library"); - Arguments.push_back(context.Args.MakeArgString(LTOLibPath)); - } -} - void toolchains::Darwin::addSanitizerArgs(ArgStringList &Arguments, const DynamicLinkJobAction &job, @@ -740,10 +723,6 @@ toolchains::Darwin::constructInvocation(const DynamicLinkJobAction &job, addArgsToLinkARCLite(Arguments, context); - if (job.PerformLTO()) { - addLTOLibArgs(Arguments, context); - } - for (const Arg *arg : context.Args.filtered(options::OPT_F, options::OPT_Fsystem)) { Arguments.push_back("-F"); @@ -811,17 +790,14 @@ toolchains::Darwin::constructInvocation(const StaticLinkJobAction &job, if (context.shouldUseInputFileList()) { Arguments.push_back("-filelist"); Arguments.push_back(context.getTemporaryFilePath("inputs", "LinkFileList")); - II.FilelistInfos.push_back({Arguments.back(), context.OI.CompilerOutputType, + II.FilelistInfos.push_back({Arguments.back(), file_types::TY_Object, FilelistInfo::WhichFiles::InputJobs}); } else { addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); } addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); Arguments.push_back("-o"); diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index d66279d81771b..d0be6bc80fd3a 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1427,15 +1427,12 @@ static bool isSDKTooOld(StringRef sdkPath, const llvm::Triple &target) { void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args, const bool BatchMode, const InputFileList &Inputs, OutputInfo &OI) const { - auto LinkerInputType = Args.hasArg(options::OPT_lto) - ? file_types::TY_LLVM_BC - : file_types::TY_Object; // By default, the driver does not link its output; this will be updated // appropriately below if linking is required. OI.CompilerOutputType = driverKind == DriverKind::Interactive ? file_types::TY_Nothing - : LinkerInputType; + : file_types::TY_Object; if (const Arg *A = Args.getLastArg(options::OPT_num_threads)) { if (BatchMode) { @@ -1465,14 +1462,14 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args, diag::error_static_emit_executable_disallowed); OI.LinkAction = LinkKind::Executable; - OI.CompilerOutputType = LinkerInputType; + OI.CompilerOutputType = file_types::TY_Object; break; case options::OPT_emit_library: OI.LinkAction = Args.hasArg(options::OPT_static) ? LinkKind::StaticLibrary : LinkKind::DynamicLibrary; - OI.CompilerOutputType = LinkerInputType; + OI.CompilerOutputType = file_types::TY_Object; break; case options::OPT_static: @@ -1782,18 +1779,6 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args, } - if (const Arg *A = Args.getLastArg(options::OPT_lto)) { - auto LTOVariant = llvm::StringSwitch>(A->getValue()) - .Case("llvm", OutputInfo::LTOKind::LLVMThin) - .Case("llvm-full", OutputInfo::LTOKind::LLVMFull) - .Default(llvm::None); - if (LTOVariant) - OI.LTOVariant = LTOVariant.getValue(); - else - Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value, - A->getAsString(Args), A->getValue()); - } - if (TC.getTriple().isOSWindows()) { if (const Arg *A = Args.getLastArg(options::OPT_libc)) { OI.RuntimeVariant = @@ -2128,17 +2113,15 @@ void Driver::buildActions(SmallVectorImpl &TopLevelActions, MergeModuleAction = C.createAction(AllModuleInputs); } - auto PerformLTO = Args.hasArg(options::OPT_lto); if (OI.shouldLink() && !AllLinkerInputs.empty()) { JobAction *LinkAction = nullptr; if (OI.LinkAction == LinkKind::StaticLibrary) { LinkAction = C.createAction(AllLinkerInputs, - OI.LinkAction); + OI.LinkAction); } else { LinkAction = C.createAction(AllLinkerInputs, - OI.LinkAction, - PerformLTO); + OI.LinkAction); } // On ELF platforms there's no built in autolinking mechanism, so we @@ -2147,7 +2130,7 @@ void Driver::buildActions(SmallVectorImpl &TopLevelActions, const auto &Triple = TC.getTriple(); SmallVector AutolinkExtractInputs; for (const Action *A : AllLinkerInputs) - if (A->getType() == OI.CompilerOutputType) { + if (A->getType() == file_types::TY_Object) { // Shared objects on ELF platforms don't have a swift1_autolink_entries // section in them because the section in the .o files is marked as // SHF_EXCLUDE. @@ -2163,7 +2146,7 @@ void Driver::buildActions(SmallVectorImpl &TopLevelActions, (Triple.getObjectFormat() == llvm::Triple::ELF && !Triple.isPS4()) || Triple.getObjectFormat() == llvm::Triple::Wasm || Triple.isOSCygMing(); - if (!AutolinkExtractInputs.empty() && AutolinkExtractRequired && !PerformLTO) { + if (!AutolinkExtractInputs.empty() && AutolinkExtractRequired) { auto *AutolinkExtractAction = C.createAction(AutolinkExtractInputs); // Takes the same inputs as the linker... diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index a235829ff7335..232a69ac30487 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -518,11 +518,6 @@ ToolChain::constructInvocation(const CompileJobAction &job, Arguments.push_back("-track-system-dependencies"); } - if (auto arg = context.Args.getLastArg(options::OPT_lto)) { - Arguments.push_back(context.Args.MakeArgString( - Twine("-lto=") + arg->getValue())); - } - context.Args.AddLastArg( Arguments, options:: diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 946a8e70bc446..29a04c1b243a8 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -48,9 +48,6 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain { void addDeploymentTargetArgs(llvm::opt::ArgStringList &Arguments, const JobContext &context) const; - void addLTOLibArgs(llvm::opt::ArgStringList &Arguments, - const JobContext &context) const; - void addCommonFrontendArgs( const OutputInfo &OI, const CommandOutput &output, const llvm::opt::ArgList &inputArgs, diff --git a/lib/Driver/UnixToolChains.cpp b/lib/Driver/UnixToolChains.cpp index 75c812b9521ad..59f24a4eafe1e 100644 --- a/lib/Driver/UnixToolChains.cpp +++ b/lib/Driver/UnixToolChains.cpp @@ -72,10 +72,7 @@ ToolChain::InvocationInfo toolchains::GenericUnix::constructInvocation( addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); Arguments.push_back("-o"); Arguments.push_back( @@ -170,9 +167,6 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job, std::string Linker; if (const Arg *A = context.Args.getLastArg(options::OPT_use_ld)) { Linker = A->getValue(); - } else if (context.OI.LTOVariant != OutputInfo::LTOKind::None) { - // Force to use lld for LTO - Linker = "lld"; } else { Linker = getDefaultLinker(); } @@ -224,16 +218,6 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job, Arguments.push_back("-pie"); } - switch (context.OI.LTOVariant) { - case OutputInfo::LTOKind::LLVMThin: - Arguments.push_back("-flto=thin"); - break; - case OutputInfo::LTOKind::LLVMFull: - Arguments.push_back("-flto=full"); - break; - case OutputInfo::LTOKind::None: break; - } - bool staticExecutable = false; bool staticStdlib = false; @@ -269,11 +253,7 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job, addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); - for (const Arg *arg : context.Args.filtered(options::OPT_F, options::OPT_Fsystem)) { @@ -388,7 +368,7 @@ toolchains::GenericUnix::constructInvocation(const StaticLinkJobAction &job, ArgStringList Arguments; // Configure the toolchain. - const char *AR = "llvm-ar"; + const char *AR = "ar"; Arguments.push_back("crs"); Arguments.push_back( @@ -396,11 +376,7 @@ toolchains::GenericUnix::constructInvocation(const StaticLinkJobAction &job, addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); - InvocationInfo II{AR, Arguments}; diff --git a/lib/Driver/WindowsToolChains.cpp b/lib/Driver/WindowsToolChains.cpp index 5131d14e14f03..0fe623675eb1a 100644 --- a/lib/Driver/WindowsToolChains.cpp +++ b/lib/Driver/WindowsToolChains.cpp @@ -143,11 +143,7 @@ toolchains::Windows::constructInvocation(const DynamicLinkJobAction &job, addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); - for (const Arg *arg : context.Args.filtered(options::OPT_F, options::OPT_Fsystem)) { @@ -190,21 +186,6 @@ toolchains::Windows::constructInvocation(const DynamicLinkJobAction &job, context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group); context.Args.AddAllArgValues(Arguments, options::OPT_Xclang_linker); - switch (context.OI.LTOVariant) { - case OutputInfo::LTOKind::LLVMThin: - case OutputInfo::LTOKind::LLVMFull: { - if (Linker.empty()) - Arguments.push_back("-fuse-ld=lld"); - if (context.OI.LTOVariant == OutputInfo::LTOKind::LLVMThin) { - Arguments.push_back("-flto=thin"); - } else { - Arguments.push_back("-flto=full"); - } - break; - } - case OutputInfo::LTOKind::None: break; - } - // Run clang++ in verbose mode if "-v" is set if (context.Args.hasArg(options::OPT_v)) { Arguments.push_back("-v"); @@ -229,46 +210,22 @@ toolchains::Windows::constructInvocation(const StaticLinkJobAction &job, ArgStringList Arguments; - switch (context.OI.LTOVariant) { - case OutputInfo::LTOKind::LLVMThin: - case OutputInfo::LTOKind::LLVMFull: { - const char *AR = "llvm-ar"; - Arguments.push_back("crs"); + const char *Linker = "link"; + if (const Arg *A = context.Args.getLastArg(options::OPT_use_ld)) + Linker = context.Args.MakeArgString(A->getValue()); + + Arguments.push_back("/lib"); + Arguments.push_back("-nologo"); - Arguments.push_back( - context.Args.MakeArgString(context.Output.getPrimaryOutputFilename())); + addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, + file_types::TY_Object); + addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); - addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); + StringRef OutputFile = context.Output.getPrimaryOutputFilename(); + Arguments.push_back(context.Args.MakeArgString(Twine("/OUT:") + OutputFile)); - InvocationInfo II{AR, Arguments}; + InvocationInfo II{Linker, Arguments}; + II.allowsResponseFiles = true; - return II; - } - case OutputInfo::LTOKind::None: - const char *Linker = "link"; - if (const Arg *A = context.Args.getLastArg(options::OPT_use_ld)) - Linker = context.Args.MakeArgString(A->getValue()); - - Arguments.push_back("/lib"); - Arguments.push_back("-nologo"); - - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_Object); - addPrimaryInputsOfType(Arguments, context.Inputs, context.Args, - file_types::TY_LLVM_BC); - addInputsOfType(Arguments, context.InputActions, file_types::TY_Object); - addInputsOfType(Arguments, context.InputActions, file_types::TY_LLVM_BC); - - StringRef OutputFile = context.Output.getPrimaryOutputFilename(); - Arguments.push_back(context.Args.MakeArgString(Twine("/OUT:") + OutputFile)); - - InvocationInfo II{Linker, Arguments}; - II.allowsResponseFiles = true; - return II; - } + return II; } diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index f3a78f9373765..071ccdf4f65e4 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1428,17 +1428,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args, } } - if (const Arg *A = Args.getLastArg(options::OPT_lto)) { - auto LLVMLTOKind = llvm::StringSwitch>(A->getValue()) - .Case("llvm", IRGenLLVMLTOKind::Thin) - .Case("llvm-full", IRGenLLVMLTOKind::Full) - .Default(llvm::None); - if (LLVMLTOKind) - Opts.LLVMLTOKind = LLVMLTOKind.getValue(); - else - Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value, - A->getAsString(Args), A->getValue()); - } if (const Arg *A = Args.getLastArg(options::OPT_sanitize_coverage_EQ)) { Opts.SanitizeCoverage = diff --git a/lib/IRGen/IRGen.cpp b/lib/IRGen/IRGen.cpp index 24886a9b362c9..21a400c8f3213 100644 --- a/lib/IRGen/IRGen.cpp +++ b/lib/IRGen/IRGen.cpp @@ -548,14 +548,9 @@ bool swift::performLLVM(const IRGenOptions &Opts, case IRGenOutputKind::LLVMAssembly: EmitPasses.add(createPrintModulePass(*RawOS)); break; - case IRGenOutputKind::LLVMBitcode: { - if (Opts.LLVMLTOKind == IRGenLLVMLTOKind::Thin) { - EmitPasses.add(createWriteThinLTOBitcodePass(*RawOS)); - } else { - EmitPasses.add(createBitcodeWriterPass(*RawOS)); - } + case IRGenOutputKind::LLVMBitcode: + EmitPasses.add(createBitcodeWriterPass(*RawOS)); break; - } case IRGenOutputKind::NativeAssembly: case IRGenOutputKind::ObjectFile: { CodeGenFileType FileType; diff --git a/lib/IRGen/IRGenModule.cpp b/lib/IRGen/IRGenModule.cpp index c0da6209e7056..87f3207b6ef09 100644 --- a/lib/IRGen/IRGenModule.cpp +++ b/lib/IRGen/IRGenModule.cpp @@ -1098,18 +1098,10 @@ void IRGenModule::addLinkLibrary(const LinkLibrary &linkLib) { switch (linkLib.getKind()) { case LibraryKind::Library: { - if (TargetInfo.OutputObjectFormat == llvm::Triple::ELF && IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None) { - // When performing LTO, we always use lld that supports auto linking mechanism with ELF. - // So embed dependent libraries names in "llvm.dependent-libraries" instead of options - // to avoid using swift-autolink-extract. - AutolinkEntries.push_back( - llvm::MDNode::get(ctx, llvm::MDString::get(ctx, linkLib.getName()))); - } else { - llvm::SmallString<32> opt = - getTargetDependentLibraryOption(Triple, linkLib.getName()); - AutolinkEntries.push_back( - llvm::MDNode::get(ctx, llvm::MDString::get(ctx, opt))); - } + llvm::SmallString<32> opt = + getTargetDependentLibraryOption(Triple, linkLib.getName()); + AutolinkEntries.push_back( + llvm::MDNode::get(ctx, llvm::MDString::get(ctx, opt))); break; } case LibraryKind::Framework: { @@ -1196,12 +1188,7 @@ static bool isFirstObjectFileInModule(IRGenModule &IGM) { void IRGenModule::emitAutolinkInfo() { // Collect the linker options already in the module (from ClangCodeGen). // FIXME: This constant should be vended by LLVM somewhere. - // When performing LTO, we always use lld that supports auto linking mechanism with ELF. - // So embed dependent libraries names in "llvm.dependent-libraries" instead of "llvm.linker.options". - const StringRef AutolinkSectionName = - TargetInfo.OutputObjectFormat == llvm::Triple::ELF && IRGen.Opts.LLVMLTOKind != IRGenLLVMLTOKind::None - ? "llvm.dependent-libraries" : "llvm.linker.options"; - auto *Metadata = Module.getOrInsertNamedMetadata(AutolinkSectionName); + auto *Metadata = Module.getOrInsertNamedMetadata("llvm.linker.options"); for (llvm::MDNode *LinkOption : Metadata->operands()) AutolinkEntries.push_back(LinkOption); @@ -1216,9 +1203,9 @@ void IRGenModule::emitAutolinkInfo() { AutolinkEntries.end()); const bool AutolinkExtractRequired = - ((TargetInfo.OutputObjectFormat == llvm::Triple::ELF && !Triple.isPS4()) || + (TargetInfo.OutputObjectFormat == llvm::Triple::ELF && !Triple.isPS4()) || TargetInfo.OutputObjectFormat == llvm::Triple::Wasm || - Triple.isOSCygMing()) && IRGen.Opts.LLVMLTOKind == IRGenLLVMLTOKind::None; + Triple.isOSCygMing(); if (!AutolinkExtractRequired) { // On platforms that support autolinking, continue to use the metadata. diff --git a/test/Driver/Inputs/lto/lib.swift b/test/Driver/Inputs/lto/lib.swift deleted file mode 100644 index 2da93851bb3e7..0000000000000 --- a/test/Driver/Inputs/lto/lib.swift +++ /dev/null @@ -1 +0,0 @@ -public func libraryFunction() {} diff --git a/test/Driver/Inputs/lto/main.swift b/test/Driver/Inputs/lto/main.swift deleted file mode 100644 index fef49f4c4f8f2..0000000000000 --- a/test/Driver/Inputs/lto/main.swift +++ /dev/null @@ -1,3 +0,0 @@ -import A - -libraryFunction() diff --git a/test/Driver/Inputs/lto/multifiles/file.swift b/test/Driver/Inputs/lto/multifiles/file.swift deleted file mode 100644 index 2ff6e02c99461..0000000000000 --- a/test/Driver/Inputs/lto/multifiles/file.swift +++ /dev/null @@ -1,3 +0,0 @@ -func anotherFileFunction() { - print(#function) -} diff --git a/test/Driver/Inputs/lto/multifiles/main.swift b/test/Driver/Inputs/lto/multifiles/main.swift deleted file mode 100644 index c81b011f13bd9..0000000000000 --- a/test/Driver/Inputs/lto/multifiles/main.swift +++ /dev/null @@ -1 +0,0 @@ -anotherFileFunction() diff --git a/test/Driver/link-time-opt-lib-thin.swift b/test/Driver/link-time-opt-lib-thin.swift deleted file mode 100644 index f07ecded6e0c1..0000000000000 --- a/test/Driver/link-time-opt-lib-thin.swift +++ /dev/null @@ -1,12 +0,0 @@ -// FIXME: ld64 in Xcode toolchain uses older version of LLVM than swiftc, so ld64 can't read module summary for LTO -// from bitcode file produced by compiler. This should be fixed before shipping Xcode toolchain by upgrading -// LLVM version used in ld64. -// XFAIL: OS=macosx -// XFAIL: OS=tvos -// XFAIL: OS=watchos -// XFAIL: OS=ios -// RUN: rm -rf %t -// RUN: %empty-directory(%t/thin) - -// RUN: %target-swiftc_driver %S/Inputs/lto/lib.swift -lto=llvm -emit-library -emit-module -module-name A -working-directory %t/thin -// RUN: %target-swiftc_driver %S/Inputs/lto/main.swift -L. -I. -lA -lto=llvm -working-directory %t/thin diff --git a/test/Driver/link-time-opt-lib.swift b/test/Driver/link-time-opt-lib.swift deleted file mode 100644 index 81cfaa4cafe92..0000000000000 --- a/test/Driver/link-time-opt-lib.swift +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: rm -rf %t -// RUN: %empty-directory(%t/full) - -// RUN: %target-swiftc_driver %S/Inputs/lto/lib.swift -lto=llvm-full -emit-library -emit-module -module-name A -working-directory %t/full -// RUN: %target-swiftc_driver %S/Inputs/lto/main.swift -L. -I. -lA -lto=llvm-full -working-directory %t/full diff --git a/test/Driver/link-time-opt-staticlib-thin.swift b/test/Driver/link-time-opt-staticlib-thin.swift deleted file mode 100644 index 283b7c541fcbd..0000000000000 --- a/test/Driver/link-time-opt-staticlib-thin.swift +++ /dev/null @@ -1,14 +0,0 @@ -// UNSUPPORTED: OS=windows-msvc -// FIXME: ld64 in Xcode toolchain uses older version of LLVM than swiftc, so ld64 can't read module summary for LTO -// from bitcode file produced by compiler. This should be fixed before shipping Xcode toolchain by upgrading -// LLVM version used in ld64. -// XFAIL: OS=macosx -// XFAIL: OS=tvos -// XFAIL: OS=watchos -// XFAIL: OS=ios - -// RUN: rm -rf %t -// RUN: %empty-directory(%t/thin-static) - -// RUN: %target-swiftc_driver %S/Inputs/lto/lib.swift -static -lto=llvm -emit-library -emit-module -module-name A -working-directory %t/thin-static -// RUN: %target-swiftc_driver %S/Inputs/lto/main.swift -L. -I. -lA -lto=llvm -working-directory %t/thin-static diff --git a/test/Driver/link-time-opt-staticlib.swift b/test/Driver/link-time-opt-staticlib.swift deleted file mode 100644 index 6daf95595bf3e..0000000000000 --- a/test/Driver/link-time-opt-staticlib.swift +++ /dev/null @@ -1,6 +0,0 @@ -// UNSUPPORTED: OS=windows-msvc -// RUN: rm -rf %t -// RUN: %empty-directory(%t/full-static) - -// RUN: %target-swiftc_driver %S/Inputs/lto/lib.swift -static -lto=llvm-full -emit-library -emit-module -module-name A -working-directory %t/full-static -// RUN: %target-swiftc_driver %S/Inputs/lto/main.swift -L. -I. -lA -lto=llvm-full -working-directory %t/full-static diff --git a/test/Driver/link-time-opt.swift b/test/Driver/link-time-opt.swift deleted file mode 100644 index 28a92ad1fcc99..0000000000000 --- a/test/Driver/link-time-opt.swift +++ /dev/null @@ -1,5 +0,0 @@ -// RUN: %target-swiftc_driver -driver-print-jobs %S/../Inputs/empty.swift -lto=llvm | %FileCheck %s --check-prefix=CHECK-%target-os --check-prefix=CHECK -// CHECK: swift{{(c\.exe")?}} -frontend -emit-bc -// CHECK-macosx-NEXT: bin/ld {{.+}} -lto_library {{.+}}/lib/libLTO.dylib -// CHECK-windows-msvc-NEXT: clang.exe" {{.+}} -fuse-ld=lld -flto=thin -// CHECK-linux-gnu-NEXT: bin/clang {{.+}} -flto=thin diff --git a/utils/build-windows.bat b/utils/build-windows.bat index 3c9c11e65ff49..ca62cfef8f43e 100644 --- a/utils/build-windows.bat +++ b/utils/build-windows.bat @@ -97,7 +97,6 @@ git clone --depth 1 --single-branch https://github.com/apple/swift-cmark cmark % git clone --depth 1 --single-branch --branch swift/master https://github.com/apple/llvm-project llvm-project %exitOnError% mklink /D "%source_root%\clang" "%source_root%\llvm-project\clang" mklink /D "%source_root%\llvm" "%source_root%\llvm-project\llvm" -mklink /D "%source_root%\lld" "%source_root%\llvm-project\lld" mklink /D "%source_root%\lldb" "%source_root%\llvm-project\lldb" mklink /D "%source_root%\compiler-rt" "%source_root%\llvm-project\compiler-rt" mklink /D "%source_root%\libcxx" "%source_root%\llvm-project\libcxx" @@ -166,7 +165,7 @@ cmake^ -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-unknown-windows-msvc^ -DLLVM_ENABLE_PDB:BOOL=YES^ -DLLVM_ENABLE_ASSERTIONS:BOOL=YES^ - -DLLVM_ENABLE_PROJECTS:STRING=lld;clang^ + -DLLVM_ENABLE_PROJECTS:STRING=clang^ -DLLVM_TARGETS_TO_BUILD:STRING="AArch64;ARM;X86"^ -DLLVM_INCLUDE_BENCHMARKS:BOOL=NO^ -DLLVM_INCLUDE_DOCS:BOOL=NO^