<div dir="ltr">Sorry about that, I was keeping an eye on the bots but I must have missed that one. I've relanded with a fix in r333013.<div><br></div><div>Peter</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 22, 2018 at 4:25 AM, Amara Emerson <span dir="ltr"><<a href="mailto:aemerson@apple.com" target="_blank">aemerson@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div class="h5"><div><blockquote type="cite"><div>On 21 May 2018, at 21:31, Peter Collingbourne via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:</div><br class="m_-6466676103100387217Apple-interchange-newline"><div><div>Author: pcc<br>Date: Mon May 21 13:31:59 2018<br>New Revision: 332885<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=332885&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=332885&view=rev</a><br>Log:<br>CodeGen, Driver: Start using direct split dwarf emission in clang.<br><br>Fixes PR37466.<br><br>Differential Revision: <a href="https://reviews.llvm.org/D47093" target="_blank">https://reviews.llvm.org/<wbr>D47093</a><br><br>Added:<br> cfe/trunk/test/Misc/cc1as-<wbr>split-dwarf.s<br>Modified:<br> cfe/trunk/include/clang/<wbr>Driver/CC1Options.td<br> cfe/trunk/lib/CodeGen/<wbr>BackendUtil.cpp<br> cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp<br> cfe/trunk/test/CodeGen/<wbr>split-debug-filename.c<br> cfe/trunk/test/Driver/<wbr>split-debug.c<br> cfe/trunk/test/Driver/<wbr>split-debug.s<br> cfe/trunk/tools/driver/<wbr>cc1as_main.cpp<br><br>Modified: cfe/trunk/include/clang/<wbr>Driver/CC1Options.td<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=332885&r1=332884&r2=332885&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Driver/CC1Options.td?<wbr>rev=332885&r1=332884&r2=<wbr>332885&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/include/clang/<wbr>Driver/CC1Options.td (original)<br>+++ cfe/trunk/include/clang/<wbr>Driver/CC1Options.td Mon May 21 13:31:59 2018<br>@@ -619,6 +619,8 @@ def version : Flag<["-"], "version">,<br> HelpText<"Print the compiler version">;<br> def main_file_name : Separate<["-"], "main-file-name">,<br> HelpText<"Main file name to use for debug info">;<br>+def split_dwarf_file : Separate<["-"], "split-dwarf-file">,<br>+ HelpText<"File name to use for split dwarf debug info output">;<br><br> }<br><br>@@ -628,8 +630,6 @@ def fexternc_nounwind : Flag<["-"], "fex<br> HelpText<"Assume all functions with C linkage do not unwind">;<br> def enable_split_dwarf : Flag<["-"], "enable-split-dwarf">,<br> HelpText<"Use split dwarf/Fission">;<br>-def split_dwarf_file : Separate<["-"], "split-dwarf-file">,<br>- HelpText<"File name to use for split dwarf debug info output">;<br> def fno_wchar : Flag<["-"], "fno-wchar">,<br> HelpText<"Disable C++ builtin type wchar_t">;<br> def fconstant_string_class : Separate<["-"], "fconstant-string-class">,<br><br>Modified: cfe/trunk/lib/CodeGen/<wbr>BackendUtil.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=332885&r1=332884&r2=332885&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/CodeGen/<wbr>BackendUtil.cpp?rev=332885&r1=<wbr>332884&r2=332885&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/lib/CodeGen/<wbr>BackendUtil.cpp (original)<br>+++ cfe/trunk/lib/CodeGen/<wbr>BackendUtil.cpp Mon May 21 13:31:59 2018<br>@@ -104,7 +104,17 @@ class EmitAssemblyHelper {<br> ///<br> /// \return True on success.<br> bool AddEmitPasses(legacy::<wbr>PassManager &CodeGenPasses, BackendAction Action,<br>- raw_<wbr>pwrite_stream &OS);<br>+ raw_<wbr>pwrite_stream &OS, raw_pwrite_stream *DwoOS);<br>+<br>+ std::unique_ptr<llvm::<wbr>ToolOutputFile> openOutputFile(StringRef Path) {<br>+ std::error_code EC;<br>+ auto F = make_unique<llvm::<wbr>ToolOutputFile>(Path, EC, llvm::sys::fs::F_None);<br>+ if (EC) {<br>+ Diags.Report(diag::err_<wbr>fe_unable_to_open_output) << Path << EC.message();<br>+ F.reset();<br>+ }<br>+ return F;<br>+ }<br><br> public:<br> EmitAssemblyHelper(<wbr>DiagnosticsEngine &_Diags,<br>@@ -701,7 +711,8 @@ void EmitAssemblyHelper::<wbr>CreateTargetMac<br><br> bool EmitAssemblyHelper::<wbr>AddEmitPasses(legacy::<wbr>PassManager &CodeGenPasses,<br> <wbr> BackendAction Action,<br>- <wbr> raw_pwrite_stream &OS) {<br>+ <wbr> raw_pwrite_stream &OS,<br>+ <wbr> raw_pwrite_stream *DwoOS) {<br> // Add LibraryInfo.<br> llvm::Triple TargetTriple(TheModule-><wbr>getTargetTriple());<br> std::unique_ptr<<wbr>TargetLibraryInfoImpl> TLII(<br>@@ -718,7 +729,7 @@ bool EmitAssemblyHelper::<wbr>AddEmitPasses(l<br> if (CodeGenOpts.OptimizationLevel > 0)<br> CodeGenPasses.add(<wbr>createObjCARCContractPass());<br><br>- if (TM->addPassesToEmitFile(<wbr>CodeGenPasses, OS, nullptr, CGFT,<br>+ if (TM->addPassesToEmitFile(<wbr>CodeGenPasses, OS, DwoOS, CGFT,<br> <wbr>/*DisableVerify=*/!<wbr>CodeGenOpts.VerifyModule)) {<br> Diags.Report(diag::err_fe_<wbr>unable_to_interface_with_<wbr>target);<br> return false;<br>@@ -757,7 +768,7 @@ void EmitAssemblyHelper::<wbr>EmitAssembly(Ba<br> CodeGenPasses.add(<br> <wbr>createTargetTransformInfoWrapp<wbr>erPass(getTargetIRAnalysis()))<wbr>;<br><br>- std::unique_ptr<raw_fd_<wbr>ostream> ThinLinkOS;<br>+ std::unique_ptr<llvm::<wbr>ToolOutputFile> ThinLinkOS, DwoOS;<br><br> switch (Action) {<br> case Backend_EmitNothing:<br>@@ -766,18 +777,12 @@ void EmitAssemblyHelper::<wbr>EmitAssembly(Ba<br> case Backend_EmitBC:<br> if (CodeGenOpts.EmitSummaryIndex) {<br> if (!CodeGenOpts.<wbr>ThinLinkBitcodeFile.empty()) {<br>- std::error_code EC;<br>- ThinLinkOS.reset(new llvm::raw_fd_ostream(<br>- CodeGenOpts.<wbr>ThinLinkBitcodeFile, EC,<br>- llvm::sys::fs::F_<wbr>None));<br>- if (EC) {<br>- Diags.Report(diag::<wbr>err_fe_unable_to_open_output) << CodeGenOpts.<wbr>ThinLinkBitcodeFile<br>- <wbr> << EC.message();<br>+ ThinLinkOS = openOutputFile(CodeGenOpts.<wbr>ThinLinkBitcodeFile);<br>+ if (!ThinLinkOS)<br> return;<br>- }<br> }<br>- PerModulePasses.add(<br>- <wbr>createWriteThinLTOBitcodePass(<wbr>*OS, ThinLinkOS.get()));<br>+ PerModulePasses.add(<wbr>createWriteThinLTOBitcodePass(<br>+ *OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr));<br> }<br> else<br> PerModulePasses.add(<br>@@ -790,7 +795,13 @@ void EmitAssemblyHelper::<wbr>EmitAssembly(Ba<br> break;<br><br> default:<br>- if (!AddEmitPasses(CodeGenPasses, Action, *OS))<br>+ if (!CodeGenOpts.SplitDwarfFile.<wbr>empty()) {<br>+ DwoOS = openOutputFile(CodeGenOpts.<wbr>SplitDwarfFile);<br>+ if (!DwoOS)<br>+ return;<br>+ }<br>+ if (!AddEmitPasses(CodeGenPasses, Action, *OS,<br>+ DwoOS ? &DwoOS->os() : nullptr))<br> return;<br> }<br><br>@@ -819,6 +830,11 @@ void EmitAssemblyHelper::<wbr>EmitAssembly(Ba<br> PrettyStackTraceString CrashInfo("Code generation");<br> CodeGenPasses.run(*<wbr>TheModule);<br> }<br>+<br>+ if (ThinLinkOS)<br>+ ThinLinkOS->keep();<br>+ if (DwoOS)<br>+ DwoOS->keep();<br> }<br><br> static PassBuilder::OptimizationLevel mapToLevel(const CodeGenOptions &Opts) {<br>@@ -971,7 +987,7 @@ void EmitAssemblyHelper::<wbr>EmitAssemblyWit<br> // create that pass manager here and use it as needed below.<br> legacy::PassManager CodeGenPasses;<br> bool NeedCodeGen = false;<br>- Optional<raw_fd_ostream> ThinLinkOS;<br>+ std::unique_ptr<llvm::<wbr>ToolOutputFile> ThinLinkOS, DwoOS;<br><br> // Append any output we need to the pass manager.<br> switch (Action) {<br>@@ -981,17 +997,12 @@ void EmitAssemblyHelper::<wbr>EmitAssemblyWit<br> case Backend_EmitBC:<br> if (CodeGenOpts.EmitSummaryIndex) {<br> if (!CodeGenOpts.<wbr>ThinLinkBitcodeFile.empty()) {<br>- std::error_code EC;<br>- ThinLinkOS.emplace(<wbr>CodeGenOpts.<wbr>ThinLinkBitcodeFile, EC,<br>- <wbr>llvm::sys::fs::F_None);<br>- if (EC) {<br>- Diags.Report(diag::<wbr>err_fe_unable_to_open_output)<br>- << CodeGenOpts.<wbr>ThinLinkBitcodeFile << EC.message();<br>+ ThinLinkOS = openOutputFile(CodeGenOpts.<wbr>ThinLinkBitcodeFile);<br>+ if (!ThinLinkOS)<br> return;<br>- }<br> }<br>- MPM.addPass(<br>- <wbr>ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &*ThinLinkOS : nullptr));<br>+ MPM.addPass(<wbr>ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()<br>+ <wbr> : nullptr));<br> } else {<br> MPM.addPass(<wbr>BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,<br> <wbr> CodeGenOpts.<wbr>EmitSummaryIndex,<br>@@ -1009,7 +1020,13 @@ void EmitAssemblyHelper::<wbr>EmitAssemblyWit<br> NeedCodeGen = true;<br> CodeGenPasses.add(<br> <wbr>createTargetTransformInfoWrapp<wbr>erPass(getTargetIRAnalysis()))<wbr>;<br>- if (!AddEmitPasses(CodeGenPasses, Action, *OS))<br>+ if (!CodeGenOpts.SplitDwarfFile.<wbr>empty()) {<br>+ DwoOS = openOutputFile(CodeGenOpts.<wbr>SplitDwarfFile);<br>+ if (!DwoOS)<br>+ return;<br>+ }<br>+ if (!AddEmitPasses(CodeGenPasses, Action, *OS,<br>+ DwoOS ? &DwoOS->os() : nullptr))<br> // FIXME: Should we handle this error differently?<br> return;<br> break;<br>@@ -1029,6 +1046,11 @@ void EmitAssemblyHelper::<wbr>EmitAssemblyWit<br> PrettyStackTraceString CrashInfo("Code generation");<br> CodeGenPasses.run(*<wbr>TheModule);<br> }<br>+<br>+ if (ThinLinkOS)<br>+ ThinLinkOS->keep();<br>+ if (DwoOS)<br>+ DwoOS->keep();<br> }<br><br> Expected<BitcodeModule> clang::FindThinLTOModule(<wbr>MemoryBufferRef MBRef) {<br><br>Modified: cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=332885&r1=332884&r2=332885&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp?rev=<wbr>332885&r1=332884&r2=332885&<wbr>view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp (original)<br>+++ cfe/trunk/lib/Driver/<wbr>ToolChains/Clang.cpp Mon May 21 13:31:59 2018<br>@@ -4802,12 +4802,6 @@ void Clang::ConstructJob(<wbr>Compilation &C,<br> C.addCommand(llvm::make_<wbr>unique<Command>(JA, *this, Exec, CmdArgs, Inputs));<br> }<br><br>- // Handle the debug info splitting at object creation time if we're<br>- // creating an object.<br>- // TODO: Currently only works on linux with newer objcopy.<br>- if (SplitDWARF && Output.getType() == types::TY_Object)<br>- SplitDebugInfo(<wbr>getToolChain(), C, *this, JA, Args, Output, SplitDWARFOut);<br>-<br> if (Arg *A = Args.getLastArg(options::OPT_<wbr>pg))<br> if (Args.hasArg(options::OPT_<wbr>fomit_frame_pointer))<br> D.Diag(diag::err_drv_<wbr>argument_not_allowed_with) << "-fomit-frame-pointer"<br>@@ -5464,19 +5458,17 @@ void ClangAs::ConstructJob(<wbr>Compilation &<br> CmdArgs.push_back("-o");<br> CmdArgs.push_back(Output.<wbr>getFilename());<br><br>+ if (Args.hasArg(options::OPT_<wbr>gsplit_dwarf) &&<br>+ getToolChain().getTriple(<wbr>).isOSLinux()) {<br>+ CmdArgs.push_back("-split-<wbr>dwarf-file");<br>+ CmdArgs.push_back(<wbr>SplitDebugName(Args, Input));<br>+ }<br>+<br> assert(Input.isFilename() && "Invalid input.");<br> CmdArgs.push_back(Input.<wbr>getFilename());<br><br> const char *Exec = getToolChain().getDriver().<wbr>getClangProgramPath();<br> C.addCommand(llvm::make_<wbr>unique<Command>(JA, *this, Exec, CmdArgs, Inputs));<br>-<br>- // Handle the debug info splitting at object creation time if we're<br>- // creating an object.<br>- // TODO: Currently only works on linux with newer objcopy.<br>- if (Args.hasArg(options::OPT_<wbr>gsplit_dwarf) &&<br>- getToolChain().getTriple(<wbr>).isOSLinux())<br>- SplitDebugInfo(<wbr>getToolChain(), C, *this, JA, Args, Output,<br>- <wbr>SplitDebugName(Args, Input));<br> }<br><br> // Begin OffloadBundler<br><br>Modified: cfe/trunk/test/CodeGen/split-<wbr>debug-filename.c<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-debug-filename.c?rev=332885&r1=332884&r2=332885&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>CodeGen/split-debug-filename.<wbr>c?rev=332885&r1=332884&r2=<wbr>332885&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/test/CodeGen/split-<wbr>debug-filename.c (original)<br>+++ cfe/trunk/test/CodeGen/split-<wbr>debug-filename.c Mon May 21 13:31:59 2018<br>@@ -1,5 +1,8 @@<br> // RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck %s<br> // RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck --check-prefix=VANILLA %s<br>+// RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file %t.dwo -emit-obj -o - %s | llvm-objdump -section-headers - | FileCheck --check-prefix=O %s<br>+// RUN: llvm-objdump -section-headers %t.dwo | FileCheck --check-prefix=DWO %s<br>+<br> int main (void) {<br> return 0;<br> }<br>@@ -10,3 +13,6 @@ int main (void) {<br> // Testing to ensure that the dwo name is not output into the compile unit if<br> // it's for vanilla split-dwarf rather than split-dwarf for implicit modules.<br> // VANILLA-NOT: splitDebugFilename<br>+<br>+// O-NOT: .dwo<br>+// DWO: .dwo<br><br>Modified: cfe/trunk/test/Driver/split-<wbr>debug.c<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.c?rev=332885&r1=332884&r2=332885&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/Driver/<wbr>split-debug.c?rev=332885&r1=<wbr>332884&r2=332885&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/test/Driver/split-<wbr>debug.c (original)<br>+++ cfe/trunk/test/Driver/split-<wbr>debug.c Mon May 21 13:31:59 2018<br>@@ -3,8 +3,7 @@<br> // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t<br> // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s<br> //<br>-// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*<wbr>}}"split-debug.dwo"<br>-// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}<wbr>"split-debug.o"<br>+// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"<br><br><br> // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t<br><br>Modified: cfe/trunk/test/Driver/split-<wbr>debug.s<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/split-debug.s?rev=332885&r1=332884&r2=332885&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/Driver/<wbr>split-debug.s?rev=332885&r1=<wbr>332884&r2=332885&view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/test/Driver/split-<wbr>debug.s (original)<br>+++ cfe/trunk/test/Driver/split-<wbr>debug.s Mon May 21 13:31:59 2018<br>@@ -3,8 +3,7 @@<br> // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t<br> // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s<br> //<br>-// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*<wbr>}}"split-debug.dwo"<br>-// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}<wbr>"split-debug.o"<br>+// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"<br><br><br> // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t<br><br>Added: cfe/trunk/test/Misc/cc1as-<wbr>split-dwarf.s<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-split-dwarf.s?rev=332885&view=auto" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/Misc/<wbr>cc1as-split-dwarf.s?rev=<wbr>332885&view=auto</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/test/Misc/cc1as-<wbr>split-dwarf.s (added)<br>+++ cfe/trunk/test/Misc/cc1as-<wbr>split-dwarf.s Mon May 21 13:31:59 2018<br>@@ -0,0 +1,25 @@<br>+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu %s -filetype obj -o %t1 -split-dwarf-file %t2<br>+// RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=O %s<br>+// RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DWO %s<br>+<br>+// O-NOT: Contents of section<br>+// O: Contents of section .strtab:<br>+// O-NOT: Contents of section<br>+// O: Contents of section .text:<br>+// O-NEXT: 0000 c3<br>+// O-NEXT: Contents of section .symtab:<br>+// O-NOT: Contents of section<br>+.globl main<br>+main:<br>+.Ltmp1:<br>+ret<br>+.Ltmp2:<br>+<br>+// DWO-NOT: Contents of section<br>+// DWO: Contents of section .strtab:<br>+// DWO-NOT: Contents of section<br>+// DWO: Contents of section .foo.dwo:<br>+// DWO-NEXT: 0000 01000000<br>+// DWO-NOT: Contents of section<br>+.section .foo.dwo<br>+.long .Ltmp2-.Ltmp1<br><br>Modified: cfe/trunk/tools/driver/cc1as_<wbr>main.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=332885&r1=332884&r2=332885&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/<wbr>driver/cc1as_main.cpp?rev=<wbr>332885&r1=332884&r2=332885&<wbr>view=diff</a><br>==============================<wbr>==============================<wbr>==================<br>--- cfe/trunk/tools/driver/cc1as_<wbr>main.cpp (original)<br>+++ cfe/trunk/tools/driver/cc1as_<wbr>main.cpp Mon May 21 13:31:59 2018<br>@@ -97,6 +97,7 @@ struct AssemblerInvocation {<br> llvm::DebugCompressionType CompressDebugSections =<br> llvm::<wbr>DebugCompressionType::None;<br> std::string MainFileName;<br>+ std::string SplitDwarfFile;<br><br> /// @}<br> /// @name Frontend Options<br>@@ -247,6 +248,7 @@ bool AssemblerInvocation::<wbr>CreateFromArgs<br> }<br> Opts.LLVMArgs = Args.getAllArgValues(OPT_<wbr>mllvm);<br> Opts.OutputPath = Args.getLastArgValue(OPT_o);<br>+ Opts.SplitDwarfFile = Args.getLastArgValue(OPT_<wbr>split_dwarf_file);<br> if (Arg *A = Args.getLastArg(OPT_filetype)) {<br> StringRef Name = A->getValue();<br> unsigned OutputType = StringSwitch<unsigned>(Name)<br>@@ -282,22 +284,17 @@ bool AssemblerInvocation::<wbr>CreateFromArgs<br> }<br><br> static std::unique_ptr<raw_fd_<wbr>ostream><br>-getOutputStream(<wbr>AssemblerInvocation &Opts, DiagnosticsEngine &Diags,<br>- bool Binary) {<br>- if (Opts.OutputPath.empty())<br>- Opts.OutputPath = "-";<br>-<br>+getOutputStream(StringRef Path, DiagnosticsEngine &Diags, bool Binary) {<br> // Make sure that the Out file gets unlinked from the disk if we get a<br> // SIGINT.<br>- if (Opts.OutputPath != "-")<br>- sys::RemoveFileOnSignal(<wbr>Opts.OutputPath);<br>+ if (Path != "-")<br>+ sys::RemoveFileOnSignal(<wbr>Path);<br><br> std::error_code EC;<br> auto Out = llvm::make_unique<raw_fd_<wbr>ostream>(<br>- Opts.OutputPath, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text));<br>+ Path, EC, (Binary ? sys::fs::F_None : sys::fs::F_Text));<br> if (EC) {<br>- Diags.Report(diag::err_fe_<wbr>unable_to_open_output) << Opts.OutputPath<br>- <wbr> << EC.message();<br>+ Diags.Report(diag::err_fe_<wbr>unable_to_open_output) << Path << EC.message();<br> return nullptr;<br> }<br><br>@@ -342,9 +339,15 @@ static bool ExecuteAssembler(AssemblerIn<br> MAI->setRelaxELFRelocations(<wbr>Opts.RelaxELFRelocations);<br><br> bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;<br>- std::unique_ptr<raw_fd_<wbr>ostream> FDOS = getOutputStream(Opts, Diags, IsBinary);<br>+ if (Opts.OutputPath.empty())<br>+ Opts.OutputPath = "-";<br>+ std::unique_ptr<raw_fd_<wbr>ostream> FDOS =<br>+ getOutputStream(Opts.<wbr>OutputPath, Diags, IsBinary);<br> if (!FDOS)<br> return true;<br>+ std::unique_ptr<raw_fd_<wbr>ostream> DwoOS;<br>+ if (!Opts.SplitDwarfFile.empty())<br>+ DwoOS = getOutputStream(Opts.<wbr>SplitDwarfFile, Diags, IsBinary);<br><br> // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and<br> // MCObjectFileInfo needs a MCContext reference in order to initialize itself.<br>@@ -427,7 +430,9 @@ static bool ExecuteAssembler(AssemblerIn<br> MCTargetOptions MCOptions;<br> std::unique_ptr<<wbr>MCAsmBackend> MAB(<br> TheTarget-><wbr>createMCAsmBackend(*STI, *MRI, MCOptions));<br>- std::unique_ptr<<wbr>MCObjectWriter> OW = MAB->createObjectWriter(*Out);<br>+ std::unique_ptr<<wbr>MCObjectWriter> OW =<br>+ DwoOS ? MAB->createDwoObjectWriter(*<wbr>Out, *DwoOS)<br>+ : MAB->createObjectWriter(*Out);<br><br> Triple T(Opts.Triple);<br> Str.reset(TheTarget-><wbr>createMCObjectStreamer(<br>@@ -476,8 +481,12 @@ static bool ExecuteAssembler(AssemblerIn<br> FDOS.reset();<br><br> // Delete output file if there were errors.<br>- if (Failed && Opts.OutputPath != "-")<br>- sys::fs::remove(Opts.<wbr>OutputPath);<br>+ if (Failed) {<br>+ if (Opts.OutputPath != "-")<br>+ sys::fs::remove(Opts.<wbr>OutputPath);<br>+ if (!Opts.SplitDwarfFile.empty() && Opts.SplitDwarfFile != "-")<br>+ sys::fs::remove(Opts.<wbr>SplitDwarfFile);<br>+ }<br><br> return Failed;<br> }<br><br><br>______________________________<wbr>_________________<br>cfe-commits mailing list<br><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br></div></div></blockquote></div><br></div></div><div>Hi Peter,</div><div><br></div><div>Sorry but I had to revert this and the two follow on commits in r332971, r332972, r332973 as it broke several green dragon buildbots. For example: <a href="http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/45399/" target="_blank">http://green.lab.<wbr>llvm.org/green/job/clang-<wbr>stage1-configure-RA/45399/</a></div><div><br></div><div>Cheers,</div><div>Amara</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div>