]> granicus.if.org Git - clang/commitdiff
Warn when requesting compress-debug-sections and zlib is not available
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 31 Mar 2014 23:29:38 +0000 (23:29 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 31 Mar 2014 23:29:38 +0000 (23:29 +0000)
Another shot in the dark, since I do have zlib installed. Will be
watching the bots for fallout.

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

include/clang/Basic/DiagnosticDriverKinds.td
lib/Driver/Tools.cpp
test/Driver/compress.c [new file with mode: 0644]

index ebaf0211e36df785aae12cfb0a0bcd151e4ec641..71080ba552f74f90c3604b086c226a27efa2dbf8 100644 (file)
@@ -152,6 +152,8 @@ def warn_drv_pch_not_first_include : Warning<
   "precompiled header '%0' was ignored because '%1' is not first '-include'">;
 def warn_missing_sysroot : Warning<"no such sysroot directory: '%0'">,
   InGroup<DiagGroup<"missing-sysroot">>;
+def warn_debug_compression_unavailable : Warning<"cannot compress debug sections (zlib not installed)">,
+  InGroup<DiagGroup<"debug-compression-unavailable">>;
 
 def note_drv_command_failed_diag_msg : Note<
   "diagnostic msg: %0">;
index f354d7c40700c65b1a129e2a5d67da21951c8ee1..ba4204a3915de64528a4f5f97e8e52861076c3ff 100644 (file)
@@ -29,6 +29,7 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/Option.h"
+#include "llvm/Support/Compression.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Format.h"
@@ -1823,8 +1824,12 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
         }
       }
     }
-    if (CompressDebugSections)
-      CmdArgs.push_back("-compress-debug-sections");
+    if (CompressDebugSections) {
+      if (llvm::zlib::isAvailable())
+        CmdArgs.push_back("-compress-debug-sections");
+      else
+        D.Diag(diag::warn_debug_compression_unavailable);
+    }
 }
 
 // Until ARM libraries are build separately, we have them all in one library
diff --git a/test/Driver/compress.c b/test/Driver/compress.c
new file mode 100644 (file)
index 0000000..dcc443e
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: %clang -c %s -Wa,--compress-debug-sections 2>&1 | FileCheck %s
+// REQUIRES: nozlib
+
+// CHECK: warning: cannot compress debug sections (zlib not installed)