From: Simon Ruderich <simon@ruderich.org>
Date: Sun, 26 Jul 2020 06:51:00 +0000 (+0200)
Subject: Fix false positive with embedded gcc -print-* commands
X-Git-Tag: 0.12~2
X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=2468c015390d5de096a2b9ca15e6744eb0fb0447;p=blhc%2Fblhc.git

Fix false positive with embedded gcc -print-* commands
---

diff --git a/NEWS b/NEWS
index 575310f..023548b 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,8 @@ Version 0.XX
 - Add support to dynamically ignore lines from within the build log by
   embedding the string "blhc: ignore-line-regexp:" (Debian Bug #725484).
 - Fix false positive for meson build; reported by Yangfl (Debian Bug #953335).
+- Fix false positive with embedded gcc -print-* commands; reported by Andreas
+  Beckmann (Debian Bug #964160)
 
 
 Version 0.11
diff --git a/bin/blhc b/bin/blhc
index 44fa3ce..81d3b12 100755
--- a/bin/blhc
+++ b/bin/blhc
@@ -1078,6 +1078,8 @@ foreach my $file (@ARGV) {
             next if $line =~ m#(?:\b[0-9a-fA-F]{2,}\b\s*){5}#;
             # Meson build output
             next if $line =~ /^C\+\+ linker for the host machine: /;
+            # Embedded `gcc -print-*` commands
+            next if $line =~ /`$cc_regex_normal\s*[^`]*-print-\S+`/;
 
             # 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 3b7d18d..81343dc 100644
--- a/t/logs/false-positives
+++ b/t/logs/false-positives
@@ -68,3 +68,5 @@ Compiler executable checksum: 26648cf2c5cb5e5907eedabc7a0be2ce
 03f0 - 42 b6 a1 d9 b0 59 09 81-74 b1 1f c0 9c 3f c6 f1   B....Y..t....?..
 
 C++ linker for the host machine: c++ ld.bfd 2.34
+
+mv -f /build/nvidia-cuda-toolkit-10.1.243/debian/tmp/usr/lib/x86_64-linux-gnu/`gcc -g -O2 -fdebug-prefix-map=/build/nvidia-cuda-toolkit-10.1.243=. -fstack-protector-strong -Wformat -Werror=format-security -print-multi-os-directory`/./libiberty.an /build/nvidia-cuda-toolkit-10.1.243/debian/tmp/usr/lib/x86_64-linux-gnu/`gcc -g -O2 -fdebug-prefix-map=/build/nvidia-cuda-toolkit-10.1.243=. -fstack-protector-strong -Wformat -Werror=format-security -print-multi-os-directory`/./libiberty.a