[lld] r312604 - Fix crbug 759265 by suppressing llvm mt warnings.
Eric Beckmann via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 5 18:50:36 PDT 2017
Author: ecbeckmann
Date: Tue Sep 5 18:50:36 2017
New Revision: 312604
URL: http://llvm.org/viewvc/llvm-project?rev=312604&view=rev
Log:
Fix crbug 759265 by suppressing llvm mt warnings.
Summary:
Previous would throw warning whenever libxml2 is not installed. Now
only give this warning if merging manifest fails.
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D37240
Added:
lld/trunk/test/COFF/manifestinput-error.test
lld/trunk/test/COFF/manifestinput-nowarning.test
Modified:
lld/trunk/COFF/DriverUtils.cpp
lld/trunk/test/lit.cfg
Modified: lld/trunk/COFF/DriverUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DriverUtils.cpp?rev=312604&r1=312603&r2=312604&view=diff
==============================================================================
--- lld/trunk/COFF/DriverUtils.cpp (original)
+++ lld/trunk/COFF/DriverUtils.cpp Tue Sep 5 18:50:36 2017
@@ -20,7 +20,6 @@
#include "Symbols.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Triple.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/WindowsResource.h"
@@ -58,7 +57,7 @@ public:
void run() {
ErrorOr<std::string> ExeOrErr = sys::findProgramByName(Prog);
if (auto EC = ExeOrErr.getError())
- fatal(EC, "unable to find " + Prog + " in PATH: ");
+ fatal(EC, "unable to find " + Prog + " in PATH");
StringRef Exe = Saver.save(*ExeOrErr);
Args.insert(Args.begin(), Exe);
@@ -358,32 +357,25 @@ static std::string createDefaultXml() {
return OS.str();
}
-static Expected<std::unique_ptr<MemoryBuffer>>
-createManifestXmlWithInternalMt(std::string &DefaultXml) {
+static std::string createManifestXmlWithInternalMt(StringRef DefaultXml) {
std::unique_ptr<MemoryBuffer> DefaultXmlCopy =
MemoryBuffer::getMemBufferCopy(DefaultXml);
windows_manifest::WindowsManifestMerger Merger;
if (auto E = Merger.merge(*DefaultXmlCopy.get()))
- return std::move(E);
+ fatal(E, "internal manifest tool failed on default xml");
for (StringRef Filename : Config->ManifestInput) {
std::unique_ptr<MemoryBuffer> Manifest =
check(MemoryBuffer::getFile(Filename));
- if (auto E = Merger.merge(*Manifest.get())) {
- warn("internal manifest tool failed on file " + Filename);
- return std::move(E);
- }
+ if (auto E = Merger.merge(*Manifest.get()))
+ fatal(E, "internal manifest tool failed on file " + Filename);
}
- return Merger.getMergedManifest();
+ return Merger.getMergedManifest().get()->getBuffer();
}
-static std::unique_ptr<MemoryBuffer>
-createManifestXmlWithExternalMt(std::string &DefaultXml) {
- const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE));
- if (!HostTriple.isOSWindows())
- fatal("manifest ignored because no external manifest tool available");
+static std::string createManifestXmlWithExternalMt(StringRef DefaultXml) {
// Create the default manifest file as a temporary file.
TemporaryFile Default("defaultxml", "manifest");
std::error_code EC;
@@ -408,7 +400,9 @@ createManifestXmlWithExternalMt(std::str
E.add("/out:" + StringRef(User.Path));
E.run();
- return check(MemoryBuffer::getFile(User.Path), "could not open " + User.Path);
+ return check(MemoryBuffer::getFile(User.Path), "could not open " + User.Path)
+ .get()
+ ->getBuffer();
}
static std::string createManifestXml() {
@@ -416,22 +410,10 @@ static std::string createManifestXml() {
if (Config->ManifestInput.empty())
return DefaultXml;
- // If manifest files are supplied by the user using /MANIFESTINPUT
- // option, we need to merge them with the default manifest. If libxml2
- // is enabled, we may merge them with LLVM's own library.
- Expected<std::unique_ptr<MemoryBuffer>> OutputBufferOrError =
- createManifestXmlWithInternalMt(DefaultXml);
- if (OutputBufferOrError)
- return OutputBufferOrError.get()->getBuffer();
- // Using built-in library failed, possibly because libxml2 is not installed.
- // Shell out to mt.exe instead.
- handleAllErrors(OutputBufferOrError.takeError(),
- [&](ErrorInfoBase &EIB) {
- warn("error with internal manifest tool: " + EIB.message());
- });
- std::unique_ptr<MemoryBuffer> OutputBuffer;
- OutputBuffer = createManifestXmlWithExternalMt(DefaultXml);
- return OutputBuffer->getBuffer();
+ if (windows_manifest::isAvailable())
+ return createManifestXmlWithInternalMt(DefaultXml);
+
+ return createManifestXmlWithExternalMt(DefaultXml);
}
static std::unique_ptr<MemoryBuffer>
Added: lld/trunk/test/COFF/manifestinput-error.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/manifestinput-error.test?rev=312604&view=auto
==============================================================================
--- lld/trunk/test/COFF/manifestinput-error.test (added)
+++ lld/trunk/test/COFF/manifestinput-error.test Tue Sep 5 18:50:36 2017
@@ -0,0 +1,10 @@
+# UNSUPPORTED: manifest_tool
+# UNSUPPORTED: libxml2
+
+# RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj
+# RUN: not lld-link /out:%t.exe /entry:main \
+# RUN: /manifest:embed \
+# RUN: /manifestuac:"level='requireAdministrator'" \
+# RUN: /manifestinput:%p/Inputs/manifestinput.test %t.obj 2>&1 | FileCheck %s
+
+# CHECK: error: unable to find mt.exe in PATH: No such file or directory
Added: lld/trunk/test/COFF/manifestinput-nowarning.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/manifestinput-nowarning.test?rev=312604&view=auto
==============================================================================
--- lld/trunk/test/COFF/manifestinput-nowarning.test (added)
+++ lld/trunk/test/COFF/manifestinput-nowarning.test Tue Sep 5 18:50:36 2017
@@ -0,0 +1,11 @@
+# UNSUPPORTED: libxml2
+# REQUIRES: manifest_tool
+
+# RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj
+# RUN: lld-link /out:%t.exe /entry:main \
+# RUN: /manifest:embed \
+# RUN: /manifestuac:"level='requireAdministrator'" \
+# RUN: /manifestinput:%p/Inputs/manifestinput.test %t.obj | \
+# RUN: FileCheck -allow-empty %s
+
+# CHECK-NOT: warning: error with internal manifest tool: no libxml2
Modified: lld/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/lit.cfg?rev=312604&r1=312603&r2=312604&view=diff
==============================================================================
--- lld/trunk/test/lit.cfg (original)
+++ lld/trunk/test/lit.cfg Tue Sep 5 18:50:36 2017
@@ -270,3 +270,7 @@ config.environment['LLD_VERSION'] = 'LLD
if (lit.util.which('cvtres', config.environment['PATH'])) or \
(config.llvm_libxml2_enabled == "1"):
config.available_features.add('manifest_tool')
+
+if (config.llvm_libxml2_enabled == "1"):
+ config.available_features.add('libxml2')
+
\ No newline at end of file
More information about the llvm-commits
mailing list