[PATCH] D26656: [COFF] Fix manifest resource file creation on Windows
Rudy Pons via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 18:15:41 PST 2016
Ilod created this revision.
Ilod added a reviewer: ruiu.
Ilod added a subscriber: llvm-commits.
Ilod added a project: lld.
createManifestRes was generating a MemoryBuffer from a TemporaryFile, keeping the data but removing the file, before passing the file path to CVTRES.exe, leading to the following error:
CVTRES : fatal error CVT1101: cannot open 'C:\Users\user\AppData\Local\Temp\lld-output-resource-bfee19.res' for reading
With this, we instead create a new MemoryBuffer kind, TemporaryFileMemoryBuffer, which keep the TemporaryFile alive while the MemoryBuffer is alive, allowing CVTRES to correctly handle this resource.
https://reviews.llvm.org/D26656
Files:
COFF/DriverUtils.cpp
Index: COFF/DriverUtils.cpp
===================================================================
--- COFF/DriverUtils.cpp
+++ COFF/DriverUtils.cpp
@@ -313,6 +313,27 @@
std::string Path;
};
+
+class TemporaryFileMemoryBuffer : public MemoryBuffer {
+ TemporaryFile File;
+ std::unique_ptr<MemoryBuffer> Buffer;
+public:
+ TemporaryFileMemoryBuffer(TemporaryFile&& file)
+ : MemoryBuffer() , File(std::move(file)) , Buffer(File.getMemoryBuffer()) {
+ init(Buffer->getBufferStart(), Buffer->getBufferEnd(), false);
+ }
+ /// Return an identifier for this buffer, typically the filename it was read
+ /// from.
+ virtual StringRef getBufferIdentifier() const override {
+ return Buffer->getBufferIdentifier();
+ }
+
+ /// Return information on the memory mechanism used to support the
+ /// MemoryBuffer.
+ virtual BufferKind getBufferKind() const override {
+ return Buffer->getBufferKind();
+ }
+};
}
// Create the default manifest file as a temporary file.
@@ -413,7 +434,7 @@
E.add("/nologo");
E.add(RCFile.Path);
E.run();
- return ResFile.getMemoryBuffer();
+ return llvm::make_unique<TemporaryFileMemoryBuffer>(std::move(ResFile));
}
void createSideBySideManifest() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26656.77936.patch
Type: text/x-patch
Size: 1218 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161115/758f9974/attachment.bin>
More information about the llvm-commits
mailing list