llvm-mc: error when -compress-debug-sections is requested and zlib is not linked
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 28 Mar 2014 20:45:24 +0000 (20:45 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 28 Mar 2014 20:45:24 +0000 (20:45 +0000)
This is a bit of a stab in the dark, since I have zlib on my machine.
Just going to bounce it off the bots & see if it sticks.

Do we have some convention for negative REQUIRES: checks? Or do I just
need to add a feature like I've done here?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205050 91177308-0d34-0410-b5e6-96231b3b80d8

test/MC/ELF/nocompression.s [new file with mode: 0644]
test/lit.cfg
tools/llvm-mc/llvm-mc.cpp

diff --git a/test/MC/ELF/nocompression.s b/test/MC/ELF/nocompression.s
new file mode 100644 (file)
index 0000000..c584e18
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: llvm-mc -filetype=obj -compress-debug-sections -triple x86_64-pc-linux-gnu %s -o - 2>&1 | FileCheck %s
+
+// REQUIRES: nozlib
+
+// CHECK: llvm-mc: build tools with zlib to enable -compress-debug-sections
index ec5b52ef47dc4188a766ded8b1e938fcc236e08a..df1850a663dca92f8388705fa70d571387e1ff90 100644 (file)
@@ -297,6 +297,8 @@ if not 'hexagon' in config.target_triple:
 
 if config.have_zlib == "1":
     config.available_features.add("zlib")
+else:
+    config.available_features.add("nozlib")
 
 # Native compilation: host arch == target arch
 # FIXME: Consider cases that target can be executed
index b2e7a81488dceec2a978337998789cd90e8bfe6c..dfa347e764a812a8176ca22b3313b6dab574e2d3 100644 (file)
@@ -384,8 +384,13 @@ int main(int argc, char **argv) {
   std::unique_ptr<MCAsmInfo> MAI(TheTarget->createMCAsmInfo(*MRI, TripleName));
   assert(MAI && "Unable to create target asm info!");
 
-  if (CompressDebugSections)
+  if (CompressDebugSections) {
+    if (!zlib::isAvailable()) {
+      errs() << ProgName << ": build tools with zlib to enable -compress-debug-sections";
+      return 1;
+    }
     MAI->setCompressDebugSections(true);
+  }
 
   // FIXME: This is not pretty. MCContext has a ptr to MCObjectFileInfo and
   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.