]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - bin/blhc
Fix false positive with file names containg "cc".
[blhc/blhc.git] / bin / blhc
index 210f0ac5a0511f8fcb829493c491b07d94015c9f..d966f9340248c5331157568f1fe2673f852d99cb 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -44,6 +44,14 @@ sub error_flags {
            error_color($message, 'red'), $flags, error_color(':', 'yellow'),
            $line;
 }
+sub error_nonverbose_build {
+    my ($line) = @_;
+
+    printf "%s%s %s",
+           error_color('NONVERBOSE BUILD', 'red'),
+           error_color(':', 'yellow'),
+           $line;
+}
 sub error_color {
     my ($message, $color) = @_;
 
@@ -206,6 +214,16 @@ while (my $line = <>) {
     # Ignore compiler warnings for now.
     next if $line =~ /$warning_regex/;
 
+    # Try to detect non verbose build logs.
+    if ($line =~ /^checking if you want to see long compiling messages\.\.\. no/
+            or $line =~ /^\s*(CC|CCLD)\s+/
+            or $line =~ /^\s*(C|c)ompiling\s+/
+            or $line =~ /^\s*\[[\d ]+%\] Building /) {
+        error_nonverbose_build($line);
+        $exit |= 1 << 2;
+    }
+
+
     # One line may contain multiple commands (";"). Treat each one as single
     # line.
     my @line = split /(?<!\\);/, $line;
@@ -224,7 +242,7 @@ while (my $line = <>) {
 
         } else {
             # Ignore lines with no compiler commands.
-            next if $line !~ /\b(cc|gcc|g\+\+|c\+\+)(\s|\\)/;
+            next if $line !~ /\b((?<!\.)cc|gcc|g\+\+|c\+\+)(\s|\\)/;
 
             # Ignore false positives.
             #
@@ -268,7 +286,10 @@ foreach my $line (@input) {
     # Ignore false positives.
     #
     # ./configure summary.
-    next if $line =~ /^Compiler:\s+(cc|gcc|g\+\+|c\+\+)$/;
+    my $cc_regex = qr/(cc|(x86_64-linux-gnu-)?gcc|g\+\+|c\+\+)/;
+    next if $line =~ /^\s*(C|c)ompiler[\s.]*:\s+$cc_regex(\s-std=[a-z0-9:+]+)?\s*$/
+            or $line =~ /^\s*- (CC|CXX)\s*=\s*$cc_regex\s*$/
+            or $line =~ /^\s*-- Check for working (C|CXX) compiler: /;
 
     # Is this a compiler or linker command?
     my $compiler = 1;
@@ -302,17 +323,17 @@ foreach my $line (@input) {
             # with -fPIE as well. It's no error if only PIE flags are missing.
             and not pic_pie_conflict($line, $pie, \@missing, @cflags_pie)) {
         error_flags('CFLAGS missing', \@missing, \%flag_renames, $line);
-        $exit |= 1 << 2;
+        $exit |= 1 << 3;
     }
     if ($compiler and not all_flags_used($line, \@missing, @cppflags)) {
         error_flags('CPPFLAGS missing', \@missing, \%flag_renames, $line);
-        $exit |= 1 << 2;
+        $exit |= 1 << 3;
     }
     if ($linker and not all_flags_used($line, \@missing, @ldflags)
             # Same here, -fPIC conflicts with -fPIE.
             and not pic_pie_conflict($line, $pie, \@missing, @ldflags_pie)) {
         error_flags('LDFLAGS missing', \@missing, \%flag_renames, $line);
-        $exit |= 1 << 2;
+        $exit |= 1 << 3;
     }
 }
 
@@ -393,6 +414,10 @@ Invalid arguments/options given to blhc.
 
 =item B<4>
 
+Non verbose build.
+
+=item B<8>
+
 Missing hardening flags.
 
 =back