[PATCH] D26656: [COFF] Fix manifest resource file creation on Windows
Rudy Pons via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 15 11:33:11 PST 2016
Ilod updated this revision to Diff 78042.
Ilod added a comment.
Added comment.
I don't have commit rights, so I will depend on you for this.
https://reviews.llvm.org/D26656
Files:
COFF/DriverUtils.cpp
Index: COFF/DriverUtils.cpp
===================================================================
--- COFF/DriverUtils.cpp
+++ COFF/DriverUtils.cpp
@@ -587,8 +587,29 @@
E.add("/readonly");
E.add("/nologo");
E.add("/out:" + Twine(File.Path));
- for (MemoryBufferRef MB : MBs)
- E.add(MB.getBufferIdentifier());
+
+ // We must create new files because the memory buffers we have may have no
+ // underlying file still existing on the disk.
+ // It happens if it was created from a TemporaryFile, which usually delete
+ // the file just after creating the MemoryBuffer.
+ std::vector<TemporaryFile> ResFiles;
+ ResFiles.reserve(MBs.size());
+ for (MemoryBufferRef MB : MBs) {
+ // We store the temporary file in a vector to avoid deletion
+ // before running cvtres
+ ResFiles.emplace_back("resource-file", "res");
+ TemporaryFile& ResFile = ResFiles.back();
+ // Write the content of the resource in a temporary file
+ std::error_code EC;
+ llvm::raw_fd_ostream OS(ResFile.Path, EC, sys::fs::F_None);
+ if (EC)
+ fatal(EC, "failed to open " + ResFile.Path);
+ OS << MB.getBuffer();
+ OS.close();
+
+ E.add(ResFile.Path);
+ }
+
E.run();
return File.getMemoryBuffer();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26656.78042.patch
Type: text/x-patch
Size: 1231 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/70365544/attachment.bin>
More information about the llvm-commits
mailing list