[lld] r240948 - COFF: Create an empty file for /pdb.

Rui Ueyama ruiu at google.com
Mon Jun 29 07:27:13 PDT 2015


Author: ruiu
Date: Mon Jun 29 09:27:12 2015
New Revision: 240948

URL: http://llvm.org/viewvc/llvm-project?rev=240948&view=rev
Log:
COFF: Create an empty file for /pdb.

Most build system depends on existence or time stamp of a file.
This patch is to create an empty file for /pdb:<filename> option
just to satisfy some build rules.

Modified:
    lld/trunk/COFF/Driver.cpp
    lld/trunk/COFF/Driver.h
    lld/trunk/COFF/DriverUtils.cpp

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=240948&r1=240947&r2=240948&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Mon Jun 29 09:27:12 2015
@@ -630,6 +630,10 @@ bool LinkerDriver::link(llvm::ArrayRef<c
     if (createSideBySideManifest())
       return false;
 
+  // Create a dummy PDB file to satisfy build sytem rules.
+  if (auto *Arg = Args.getLastArg(OPT_pdb))
+    touchFile(Arg->getValue());
+
   // Write the result.
   Writer Out(&Symtab);
   if (auto EC = Out.write(Config->OutputFile)) {

Modified: lld/trunk/COFF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.h?rev=240948&r1=240947&r2=240948&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.h (original)
+++ lld/trunk/COFF/Driver.h Mon Jun 29 09:27:12 2015
@@ -158,6 +158,8 @@ std::error_code checkFailIfMismatch(Stri
 ErrorOr<std::unique_ptr<MemoryBuffer>>
 convertResToCOFF(const std::vector<MemoryBufferRef> &MBs);
 
+void touchFile(StringRef Path);
+
 // Create enum with OPT_xxx values for each option in Options.td
 enum {
   OPT_INVALID = 0,

Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=240948&r1=240947&r2=240948&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Mon Jun 29 09:27:12 2015
@@ -517,6 +517,13 @@ std::error_code writeImportLibrary() {
   return E.run();
 }
 
+void touchFile(StringRef Path) {
+  int FD;
+  if (sys::fs::openFileForWrite(Path, FD, sys::fs::F_Append))
+    report_fatal_error("failed to create a file");
+  sys::Process::SafelyCloseFileDescriptor(FD);
+}
+
 // Create OptTable
 
 // Create prefix string literals used in Options.td





More information about the llvm-commits mailing list