X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fblhc;h=89cde257f5a7e5c39619759578a06b6ee88d0280;hb=93afe23c678d5fdc749a07c94e7ee9ddb4d5e9bb;hp=704d323694031709909d15becefea70ab006ffee;hpb=ae5da64f4f6f53ca3eb055d2124988847b2e8d50;p=blhc%2Fblhc.git diff --git a/bin/blhc b/bin/blhc index 704d323..89cde25 100755 --- a/bin/blhc +++ b/bin/blhc @@ -42,6 +42,10 @@ my $cc_regex_full = qr/ (?:[a-z0-9_]+-(?:linux-|kfreebsd-)?gnu(?:eabi|eabihf)?-)? $cc_regex /x; +# Regex to check if a line contains a compiler command. +my $cc_regex_normal = qr/ + \b$cc_regex(?:\s|\\) + /x; # Regex to catch (GCC) compiler warnings. my $warning_regex = qr/^(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]$/; @@ -117,6 +121,7 @@ my @object = ( # Hashes for fast extensions lookup to check if a file falls in one of these # categories. my %extensions_no_preprocess = map { $_ => 1 } ( + # There's no @header_no_preprocess. @source_no_preprocess, ); my %extensions_preprocess = map { $_ => 1 } ( @@ -768,7 +773,7 @@ foreach my $file (@ARGV) { # Ignore lines with no compiler commands. next if not $non_verbose - and not $line =~ /\b$cc_regex(?:\s|\\)/o; + and not $line =~ /$cc_regex_normal/o; # Ignore lines with no filenames with extensions. May miss some # non-verbose builds (e.g. "gcc -o test" [sic!]), but shouldn't be # a problem as the log will most likely contain other non-verbose @@ -792,6 +797,14 @@ foreach my $file (@ARGV) { \s.+\s -I/usr/share/qt4/mkspecs/[a-z]+-g\++(?:-64)? \s}x; + # Ignore false positives when the line contains only CC=gcc but no + # other gcc command. + if ($line =~ /(.*)CC=$cc_regex_full(.*)/o) { + my $before = $1; + my $after = $2; + next if not $before =~ /$cc_regex_normal/o + and not $after =~ /$cc_regex_normal/o; + } # Check if additional hardening options were used. Used to ensure # they are used for the complete build. @@ -979,18 +992,18 @@ LINE: } if (not $flag_preprocess) { - # If there are source files then it's compiling/linking in one step - # and we must check both. We only check for source files here, because - # header files cause too many false positives. + # If there are source files then it's compiling/linking in one + # step and we must check both. We only check for source files + # here, because header files cause too many false positives. if (extension_found(\%extensions_compile_link, @extensions)) { - # Assembly files don't need CFLAGS. - if (not extension_found(\%extensions_compile, @extensions) - and extension_found(\%extensions_no_compile, @extensions)) { - $compile = 0; - # But the rest does. - } else { - $compile = 1; - } + # Assembly files don't need CFLAGS. + if (not extension_found(\%extensions_compile, @extensions) + and extension_found(\%extensions_no_compile, @extensions)) { + $compile = 0; + # But the rest does. + } else { + $compile = 1; + } # No compilable extensions found, either linking or compiling # header flags. # @@ -1184,7 +1197,8 @@ Don't require Term::ANSIColor. =item * -Return exit code 0, unless there was a error. +Return exit code 0, unless there was a error (-I, -W messages don't count as +error). =back