[lld] r294498 - [COFF] added support for /lldsavetemps

Bob Haarman via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 10:53:39 PST 2017


Thanks for the heads up, Douglas. I was not aware. I will take a look.

Any idea why rm is complaining? Looking at other tests, it seems that -f is fine and so are slashes in path names. Could it be the star that is the problem?

Bob




---- On Wed, 08 Feb 2017 18:18:22 -0800 Yung, Douglas <douglas.yung at sony.com> wrote ----




Hi Bob, 

 

I don't know if you are aware, but your change is causing the PS4 Windows bot to fail (http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/5144) on the test you added. The error given is: 

 

$ "rm" "-f" "C:\Buildbot\Slave\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\llvm.obj\tools\lld\test\COFF\Output/savetemps.*" 

# command stderr: 

rm: cannot remove `C:\\Buildbot\\Slave\\llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast\\llvm.obj\\tools\\lld\\test\\COFF\\Output/savetemps.*': Invalid argument 

 

 

error: command failed with exit status: 1 

 

 

Can you investigate? 

 

Douglas Yung 

 

> -----Original Message----- 

> From: llvm-commits [mailto:llvm-commits-bounces at lists.llvm.org] On Behalf Of 

> Bob Haarman via llvm-commits 

> Sent: Wednesday, February 08, 2017 10:37 

> To: llvm-commits at lists.llvm.org 

> Subject: [lld] r294498 - [COFF] added support for /lldsavetemps 

> 

> Author: inglorion 

> Date: Wed Feb 8 12:36:41 2017 

> New Revision: 294498 

> 

> URL: http://llvm.org/viewvc/llvm-project?rev=294498&view=rev 

> Log: 

> [COFF] added support for /lldsavetemps 

> 

> Summary: This adds an option to save temporary files generated during link- 

> time optimization. This can be useful for debugging. 

> 

> Reviewers: ruiu, pcc 

> 

> Reviewed By: ruiu, pcc 

> 

> Subscribers: mehdi_amini 

> 

> Differential Revision: https://reviews.llvm.org/D29518 

> 

> Added: 

> lld/trunk/test/COFF/savetemps.ll 

> Modified: 

> lld/trunk/COFF/Config.h 

> lld/trunk/COFF/Driver.cpp 

> lld/trunk/COFF/LTO.cpp 

> lld/trunk/COFF/Options.td 

> 

> Modified: lld/trunk/COFF/Config.h 

> URL: http://llvm.org/viewvc/llvm- 

> project/lld/trunk/COFF/Config.h?rev=294498&r1=294497&r2=294498&view=diff 

> ============================================================================== 

> --- lld/trunk/COFF/Config.h (original) 

> +++ lld/trunk/COFF/Config.h Wed Feb 8 12:36:41 2017 

> @@ -105,6 +105,8 @@ struct Configuration { 

> std::map<std::string, int> DLLOrder; 

> SymbolBody *DelayLoadHelper = nullptr; 

> 

> + bool SaveTemps = false; 

> + 

> // Used for SafeSEH. 

> Symbol *SEHTable = nullptr; 

> Symbol *SEHCount = nullptr; 

> 

> Modified: lld/trunk/COFF/Driver.cpp 

> URL: http://llvm.org/viewvc/llvm- 

> project/lld/trunk/COFF/Driver.cpp?rev=294498&r1=294497&r2=294498&view=diff 

> ============================================================================== 

> --- lld/trunk/COFF/Driver.cpp (original) 

> +++ lld/trunk/COFF/Driver.cpp Wed Feb 8 12:36:41 2017 

> @@ -622,6 +622,10 @@ void LinkerDriver::link(ArrayRef<const c 

> } 

> } 

> 

> + // Handle /lldsavetemps 

> + if (Args.hasArg(OPT_lldsavetemps)) 

> + Config->SaveTemps = true; 

> + 

> // Handle /failifmismatch 

> for (auto *Arg : Args.filtered(OPT_failifmismatch)) 

> checkFailIfMismatch(Arg->getValue()); 

> 

> Modified: lld/trunk/COFF/LTO.cpp 

> URL: http://llvm.org/viewvc/llvm- 

> project/lld/trunk/COFF/LTO.cpp?rev=294498&r1=294497&r2=294498&view=diff 

> ============================================================================== 

> --- lld/trunk/COFF/LTO.cpp (original) 

> +++ lld/trunk/COFF/LTO.cpp Wed Feb 8 12:36:41 2017 

> @@ -54,6 +54,14 @@ static void checkError(Error E) { 

> }); 

> } 

> 

> +static void saveBuffer(StringRef Buffer, const Twine &Path) { 

> + std::error_code EC; 

> + raw_fd_ostream OS(Path.str(), EC, sys::fs::OpenFlags::F_None); 

> + if (EC) 

> + error("cannot create " + Path + ": " + EC.message()); 

> + OS << Buffer; 

> +} 

> + 

> static std::unique_ptr<lto::LTO> createLTO() { 

> lto::Config Conf; 

> Conf.Options = InitTargetOptionsFromCodeGenFlags(); 

> @@ -61,6 +69,9 @@ static std::unique_ptr<lto::LTO> createL 

> Conf.DisableVerify = true; 

> Conf.DiagHandler = diagnosticHandler; 

> Conf.OptLevel = Config->LTOOptLevel; 

> + if (Config->SaveTemps) 

> + checkError(Conf.addSaveTemps(std::string(Config->OutputFile) + ".", 

> + /*UseInputModulePath*/ true)); 

> lto::ThinBackend Backend; 

> if (Config->LTOJobs != -1u) 

> Backend = lto::createInProcessThinBackend(Config->LTOJobs); 

> @@ -116,8 +127,16 @@ std::vector<StringRef> BitcodeCompiler:: 

> })); 

> 

> std::vector<StringRef> Ret; 

> - for (unsigned I = 0; I != MaxTasks; ++I) 

> - if (!Buff[I].empty()) 

> - Ret.emplace_back(Buff[I].data(), Buff[I].size()); 

> + for (unsigned I = 0; I != MaxTasks; ++I) { 

> + if (Buff[I].empty()) 

> + continue; 

> + if (Config->SaveTemps) { 

> + if (I == 0) 

> + saveBuffer(Buff[I], Config->OutputFile + ".lto.obj"); 

> + else 

> + saveBuffer(Buff[I], Config->OutputFile + Twine(I) + ".lto.obj"); 

> + } 

> + Ret.emplace_back(Buff[I].data(), Buff[I].size()); } 

> return Ret; 

> } 

> 

> Modified: lld/trunk/COFF/Options.td 

> URL: http://llvm.org/viewvc/llvm- 

> project/lld/trunk/COFF/Options.td?rev=294498&r1=294497&r2=294498&view=diff 

> ============================================================================== 

> --- lld/trunk/COFF/Options.td (original) 

> +++ lld/trunk/COFF/Options.td Wed Feb 8 12:36:41 2017 

> @@ -28,6 +28,8 @@ def heap : P<"heap", "Size of the hea 

> def implib : P<"implib", "Import library name">; def libpath : P<"libpath", 

> "Additional library search path">; def linkrepro : P<"linkrepro", "Dump 

> linker invocation and input files for debugging">; 

> +def lldsavetemps : F<"lldsavetemps">, 

> + HelpText<"Save temporary files instead of deleting them">; 

> def machine : P<"machine", "Specify target platform">; 

> def merge : P<"merge", "Combine sections">; 

> def mllvm : P<"mllvm", "Options to pass to LLVM">; 

> 

> Added: lld/trunk/test/COFF/savetemps.ll 

> URL: http://llvm.org/viewvc/llvm- 

> project/lld/trunk/test/COFF/savetemps.ll?rev=294498&view=auto 

> ============================================================================== 

> --- lld/trunk/test/COFF/savetemps.ll (added) 

> +++ lld/trunk/test/COFF/savetemps.ll Wed Feb 8 12:36:41 2017 

> @@ -0,0 +1,24 @@ 

> +; RUN: rm -f %T/savetemps.* 

> +; RUN: llvm-as -o %T/savetemps.obj %s 

> +; RUN: lld-link /out:%T/savetemps.exe /entry:main /subsystem:console 

> +%T/savetemps.obj ; RUN: not llvm-dis -o - 

> +%T/savetemps.exe.0.0.preopt.bc ; RUN: not llvm-dis -o - 

> +%T/savetemps.exe.0.2.internalize.bc 

> +; RUN: not llvm-dis -o - %T/savetemps.exe.0.4.opt.bc ; RUN: not 

> +llvm-dis -o - %T/savetemps.exe.0.5.precodegen.bc 

> +; RUN: not llvm-objdump -s %T/savetemps.exe.lto.obj ; RUN: lld-link 

> +/lldsavetemps /out:%T/savetemps.exe /entry:main /subsystem:console 

> +%T/savetemps.obj ; RUN: llvm-dis -o - %T/savetemps.exe.0.0.preopt.bc | 

> +FileCheck %s ; RUN: llvm-dis -o - %T/savetemps.exe.0.2.internalize.bc | 

> +FileCheck %s ; RUN: llvm-dis -o - %T/savetemps.exe.0.4.opt.bc | 

> +FileCheck %s ; RUN: llvm-dis -o - %T/savetemps.exe.0.5.precodegen.bc | 

> +FileCheck %s ; RUN: llvm-objdump -s %T/savetemps.exe.lto.obj | 

> +FileCheck --check-prefix=CHECK-OBJDUMP %s 

> + 

> +; CHECK: define i32 @main() 

> +; CHECK-OBJDUMP: file format COFF 

> + 

> +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 

> +target triple = "x86_64-pc-windows-msvc" 

> + 

> +define i32 @main() { 

> + ret i32 0 

> +} 

> 

> 

> _______________________________________________ 

> llvm-commits mailing list 

> llvm-commits at lists.llvm.org 

> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits 






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170209/c7c1d4e8/attachment.html>


More information about the llvm-commits mailing list