diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -286,7 +286,6 @@ (PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) || (PhaseArg = DAL.getLastArg(options::OPT_rewrite_legacy_objc)) || (PhaseArg = DAL.getLastArg(options::OPT__migrate)) || - (PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs)) || (PhaseArg = DAL.getLastArg(options::OPT__analyze, options::OPT__analyze_auto)) || (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) { @@ -301,6 +300,10 @@ FinalPhase = phases::Assemble; // Otherwise do everything. + } else if ((PhaseArg = DAL.getLastArg(options::OPT_emit_iterface_stubs))) { + FinalPhase = phases::Link; + SkipPhases.insert(phases::Backend); + SkipPhases.insert(phases::Assemble); } else FinalPhase = phases::Link; @@ -3312,6 +3315,7 @@ // If we find Phase in the SkipPhases, then skip it. if (PhasesToRun.SkipPhases.find(Phase) != PhasesToRun.SkipPhases.end()) continue; + llvm::errs() << "PHASE: " << Phase << "\n"; // Add any offload action the host action depends on. Current = OffloadBuilder.addDeviceDependencesToHostAction( @@ -3900,6 +3904,11 @@ T = combineAssembleBackend(ActionChain, Inputs, CollapsedOffloadAction); if (!T) T = combineBackendCompile(ActionChain, Inputs, CollapsedOffloadAction); + if (!T && C.getArgs().getLastArg(options::OPT_emit_iterface_stubs) && + isa(BaseAction)) { + llvm::errs() << "WTF\n"; + T = new tools::ifstool::Merger(TC); + } if (!T) { Inputs = BaseAction->getInputs(); T = TC.SelectTool(*BaseAction); diff --git a/clang/lib/Driver/ToolChains/Gnu.h b/clang/lib/Driver/ToolChains/Gnu.h --- a/clang/lib/Driver/ToolChains/Gnu.h +++ b/clang/lib/Driver/ToolChains/Gnu.h @@ -45,6 +45,21 @@ : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {} }; +namespace ifstool { +class LLVM_LIBRARY_VISIBILITY Merger : public GnuTool { +public: + Merger(const ToolChain &TC) : GnuTool("IFS::Merger", "merger", TC) {} + + bool hasIntegratedCPP() const override { return false; } + bool isLinkJob() const override { return true; } + + void ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &Output, const InputInfoList &Inputs, + const llvm::opt::ArgList &TCArgs, + const char *LinkingOutput) const override; +}; +} // end namespace ifstool + /// Directly call GNU Binutils' assembler and linker. namespace gnutools { class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -341,6 +341,21 @@ !Args.hasArg(options::OPT_static_pie); } +void tools::ifstool::Merger::ConstructJob(Compilation &C, const JobAction &JA, + const InputInfo &Output, + const InputInfoList &Inputs, + const ArgList &Args, + const char *LinkingOutput) const { + llvm::errs() << "Construct merger job\n"; + SmallVector CmdArgs; + const char *Exec = "/path/to/llvm-ifs"; + CmdArgs.push_back("-o"); + CmdArgs.push_back(Output.getFilename()); + for (auto Input : Inputs) + CmdArgs.push_back(Input.getFilename()); + C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs)); +} + void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs,