From e3989ea116ea77ecbfc1699dd862692f817ddae9 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 31 Mar 2014 23:29:38 +0000 Subject: [PATCH] Warn when requesting compress-debug-sections and zlib is not available 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 | 2 ++ lib/Driver/Tools.cpp | 9 +++++++-- test/Driver/compress.c | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 test/Driver/compress.c diff --git a/include/clang/Basic/DiagnosticDriverKinds.td b/include/clang/Basic/DiagnosticDriverKinds.td index ebaf0211e3..71080ba552 100644 --- a/include/clang/Basic/DiagnosticDriverKinds.td +++ b/include/clang/Basic/DiagnosticDriverKinds.td @@ -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>; +def warn_debug_compression_unavailable : Warning<"cannot compress debug sections (zlib not installed)">, + InGroup>; def note_drv_command_failed_diag_msg : Note< "diagnostic msg: %0">; diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index f354d7c407..ba4204a391 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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 index 0000000000..dcc443e273 --- /dev/null +++ b/test/Driver/compress.c @@ -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) -- 2.40.0