From 93afe23c678d5fdc749a07c94e7ee9ddb4d5e9bb Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 26 Jun 2012 00:54:16 +0200 Subject: [PATCH] Ignore false positives from CC=gcc. If there's no "normal" compiler command before or after CC=gcc, skip the line. --- bin/blhc | 14 +++++++++++++- t/logs/false-positives | 2 ++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/blhc b/bin/blhc index fa2c507..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: (.+?) \[(.+?)\]$/; @@ -769,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 @@ -793,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. diff --git a/t/logs/false-positives b/t/logs/false-positives index 3e63b8d..35e71e9 100644 --- a/t/logs/false-positives +++ b/t/logs/false-positives @@ -3,3 +3,5 @@ dpkg-buildpackage: source package test # Some false positives. swig -Wall -c++ -python test.i + ++ CC=gcc CFLAGS=-g -O2 ... sh ../../build.sh -r -c lto -- 2.43.2