From: Simon Ruderich Date: Wed, 28 Feb 2024 08:29:46 +0000 (+0100) Subject: Properly ignore cargo/rust output X-Git-Tag: 0.14~7 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=1368fa468fd4e62ebdb4efa40efb5c19e39bacd7;p=blhc%2Fblhc.git Properly ignore cargo/rust output --- diff --git a/MANIFEST b/MANIFEST index 4455bad..af71ee8 100644 --- a/MANIFEST +++ b/MANIFEST @@ -33,6 +33,7 @@ t/logs/buildd-gcc-pie-builtin-wrong-arch t/logs/buildd-package-details t/logs/buildd-verbose-build t/logs/c++ +t/logs/cargo t/logs/cc t/logs/configure t/logs/configure-check diff --git a/NEWS b/NEWS index 72f9364..9aafae0 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,7 @@ Version 0.XX (Debian Bug #1050942). - Accept -g3 instead of -g which enables more debug information (reported in IRC OFTC/#debian-mentors). +- Properly ignore cargo/rust output (reported by Alexander Kjäll via mail). Version 0.13 diff --git a/bin/blhc b/bin/blhc index dda9612..2e48bbc 100755 --- a/bin/blhc +++ b/bin/blhc @@ -49,6 +49,9 @@ my $cc_regex_full = qr/ my $cc_regex_normal = qr/ \b$cc_regex(?:\s|\\) /x; +my $rustc_regex = qr/ + \brustc\b + /x; # Regex to catch (GCC) compiler warnings. my $warning_regex = qr/^(.+?):(\d+):\d+: warning: (.+?) \[(.+?)\]$/; # Regex to catch libtool commands and not lines which show commands executed @@ -522,7 +525,7 @@ sub pic_pie_conflict { } sub is_non_verbose_build { - my ($line, $skip_ref, $input_ref, $line_offset, $line_count) = @_; + my ($line, $cargo, $skip_ref, $input_ref, $line_offset, $line_count) = @_; if ($line =~ /$libtool_regex/o) { # libtool's --silent hides the real compiler flags. @@ -554,6 +557,8 @@ sub is_non_verbose_build { # "Compiling" non binary files. return 0 if $line =~ /^\s*Compiling \S+\.(?:py|pyx|el)['"]?\s*(?:\.\.\.|because it changed\.)?$/; return 0 if $line =~ /^\s*[Cc]ompiling catalog \S+\.po\b/; + # cargo build + return 0 if $cargo and $line =~ m{^\s*Compiling\s+\S+\s+v\S+(?:\s+\(/<>\))?$}; # "Compiling" with no file name. if ($line =~ /^\s*[Cc]ompiling\s+(.+?)(?:\.\.\.)?$/) { # $file_extension_regex may need spaces around the filename. @@ -813,6 +818,9 @@ foreach my $file (@ARGV) { $disable_harden_pie = 1; } + # Ignore additional false positives if cargo/rust is used + my $cargo = 0; + my $number = 0; while (my $line = <$fh>) { $number++; @@ -909,6 +917,10 @@ foreach my $file (@ARGV) { } next FILE; } + + if ($line =~ /\bcargo\b/) { + $cargo = 1; + } } # This flags is not always available, but if it is use it. @@ -990,7 +1002,7 @@ foreach my $file (@ARGV) { # Check if this line indicates a non verbose build. my $skip = 0; - $non_verbose |= is_non_verbose_build($line, \$skip); + $non_verbose |= is_non_verbose_build($line, $cargo, \$skip); next if $skip; # Treat each command as a single line so we don't ignore valid @@ -1113,6 +1125,8 @@ foreach my $file (@ARGV) { next if $line =~ /`$cc_regex_normal\s*[^`]*-print-\S+`/; # cmake checking for compiler flags without setting CPPFLAGS next if $line =~ m{^\s*/usr/(bin|lib)/(ccache/)?c\+\+ -dM -E -c /usr/share/cmake-\S+/Modules/CMakeCXXCompilerABI\.cpp}; + # Some rustc lines look like linker commands + next if $cargo and $line =~ /$rustc_regex/o; # Check if additional hardening options were used. Used to ensure # they are used for the complete build. @@ -1298,7 +1312,7 @@ LINE: my $skip = 0; if ($input_nonverbose[$i] - and is_non_verbose_build($line, \$skip, + and is_non_verbose_build($line, $cargo, \$skip, \@input, $i, $parallel)) { if (not $option_buildd) { error_non_verbose_build($line, $input_number[$i]); diff --git a/t/logs/cargo b/t/logs/cargo new file mode 100644 index 0000000..61ba8cc --- /dev/null +++ b/t/logs/cargo @@ -0,0 +1,36 @@ +Filtered Build-Depends: debhelper (>= 12), dh-cargo (>= 25), cargo, rustc (>= 1.70), ... + +dpkg-buildpackage: info: source package test + + +debian cargo wrapper: options, profiles, parallel, lto: ['parallel=6'] [] ['-j6'] 0 +debian cargo wrapper: rust_type, gnu_type: x86_64-unknown-linux-gnu, x86_64-linux-gnu +debian cargo wrapper: running subprocess (['env', 'RUST_BACKTRACE=1', '/usr/bin/cargo', '-Zavoid-dev-deps', 'build', '--verbose', '--verbose', '-j6', '--target', 'x86_64-unknown-linux-gnu'],) {} + Compiling libc v0.2.152 + Compiling proc-macro2 v1.0.76 + Compiling unicode-ident v1.0.12 + Compiling autocfg v1.1.0 + Compiling cfg-if v1.0.0 + Compiling rustix v0.38.30 + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/libc-0.2.152 CARGO_PKG_AUTHORS='The Rust Project Developers' CARGO_PKG_DESCRIPTION='Raw FFI bindings to platform libraries like libc. +' CARGO_PKG_HOMEPAGE='https://github.com/rust-lang/libc' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=libc CARGO_PKG_REPOSITORY='https://github.com/rust-lang/libc' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.2.152 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=2 CARGO_PKG_VERSION_PATCH=152 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name build_script_build /<>/debian/cargo_registry/libc-0.2.152/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=a3a5eef27054c9db -C extra-filename=-a3a5eef27054c9db --out-dir /<>/target/debug/build/libc-a3a5eef27054c9db -L dependency=/<>/target/debug/deps --cap-lints warn` + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/proc-macro2-1.0.76 CARGO_PKG_AUTHORS='David Tolnay :Alex Crichton ' CARGO_PKG_DESCRIPTION='A substitute implementation of the compiler'\''s `proc_macro` API to decouple token-based libraries from the procedural macro use case.' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=proc-macro2 CARGO_PKG_REPOSITORY='https://github.com/dtolnay/proc-macro2' CARGO_PKG_RUST_VERSION=1.56 CARGO_PKG_VERSION=1.0.76 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=76 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name build_script_build --edition=2021 /<>/debian/cargo_registry/proc-macro2-1.0.76/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="proc-macro"' -C metadata=8dc086d750bf2531 -C extra-filename=-8dc086d750bf2531 --out-dir /<>/target/debug/build/proc-macro2-8dc086d750bf2531 -L dependency=/<>/target/debug/deps --cap-lints warn` + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=unicode_ident CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/unicode-ident-1.0.12 CARGO_PKG_AUTHORS='David Tolnay ' CARGO_PKG_DESCRIPTION='Determine whether characters have the XID_Start or XID_Continue properties according to Unicode Standard Annex #31' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='(MIT OR Apache-2.0) AND Unicode-DFS-2016' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=unicode-ident CARGO_PKG_REPOSITORY='https://github.com/dtolnay/unicode-ident' CARGO_PKG_RUST_VERSION=1.31 CARGO_PKG_VERSION=1.0.12 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=12 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name unicode_ident --edition=2018 /<>/debian/cargo_registry/unicode-ident-1.0.12/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=831c1ff3a21d0075 -C extra-filename=-831c1ff3a21d0075 --out-dir /<>/target/debug/deps -L dependency=/<>/target/debug/deps --cap-lints warn` + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=autocfg CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/autocfg-1.1.0 CARGO_PKG_AUTHORS='Josh Stone ' CARGO_PKG_DESCRIPTION='Automatic cfg for Rust compiler features' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='Apache-2.0 OR MIT' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=autocfg CARGO_PKG_REPOSITORY='https://github.com/cuviper/autocfg' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=1.1.0 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name autocfg /<>/debian/cargo_registry/autocfg-1.1.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=6818d4eba8c02e55 -C extra-filename=-6818d4eba8c02e55 --out-dir /<>/target/debug/deps -L dependency=/<>/target/debug/deps --cap-lints warn` + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=cfg_if CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/cfg-if-1.0.0 CARGO_PKG_AUTHORS='Alex Crichton ' CARGO_PKG_DESCRIPTION='A macro to ergonomically define an item depending on a large number of #[cfg] +parameters. Structured like an if-else chain, the first matching branch is the +item that gets emitted. +' CARGO_PKG_HOMEPAGE='https://github.com/alexcrichton/cfg-if' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=cfg-if CARGO_PKG_REPOSITORY='https://github.com/alexcrichton/cfg-if' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=1.0.0 CARGO_PKG_VERSION_MAJOR=1 CARGO_PKG_VERSION_MINOR=0 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name cfg_if --edition=2018 /<>/debian/cargo_registry/cfg-if-1.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=ad74a372cb2fb5a2 -C extra-filename=-ad74a372cb2fb5a2 --out-dir /<>/target/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -L dependency=/<>/target/x86_64-unknown-linux-gnu/debug/deps -L dependency=/<>/target/debug/deps --cap-lints warn -C debuginfo=2 --cap-lints warn -C linker=x86_64-linux-gnu-gcc -C link-arg=-Wl,-z,relro --remap-path-prefix /<>=/usr/share/cargo/registry/sequoia-chameleon-gnupg-0.5.1 --remap-path-prefix /<>/debian/cargo_registry=/usr/share/cargo/registry` + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=build_script_build CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/rustix-0.38.30 CARGO_PKG_AUTHORS='Dan Gohman :Jakub Konka ' CARGO_PKG_DESCRIPTION='Safe Rust bindings to POSIX/Unix/Linux/Winsock-like syscalls' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=rustix CARGO_PKG_REPOSITORY='https://github.com/bytecodealliance/rustix' CARGO_PKG_RUST_VERSION=1.63 CARGO_PKG_VERSION=0.38.30 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=38 CARGO_PKG_VERSION_PATCH=30 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name build_script_build --edition=2021 /<>/debian/cargo_registry/rustix-0.38.30/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="alloc"' --cfg 'feature="default"' --cfg 'feature="fs"' --cfg 'feature="std"' --cfg 'feature="termios"' --cfg 'feature="use-libc-auxv"' -C metadata=75b307726f73a106 -C extra-filename=-75b307726f73a106 --out-dir /<>/target/debug/build/rustix-75b307726f73a106 -L dependency=/<>/target/debug/deps --cap-lints warn` + Compiling pkg-config v0.3.27 + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=pkg_config CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/pkg-config-0.3.27 CARGO_PKG_AUTHORS='Alex Crichton ' CARGO_PKG_DESCRIPTION='A library to run the pkg-config system tool at build time in order to be used in +Cargo build scripts. +' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=pkg-config CARGO_PKG_REPOSITORY='https://github.com/rust-lang/pkg-config-rs' CARGO_PKG_RUST_VERSION=1.30 CARGO_PKG_VERSION=0.3.27 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=3 CARGO_PKG_VERSION_PATCH=27 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name pkg_config /<>/debian/cargo_registry/pkg-config-0.3.27/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=b78c2bb740f170e6 -C extra-filename=-b78c2bb740f170e6 --out-dir /<>/target/debug/deps -L dependency=/<>/target/debug/deps --cap-lints warn` + Compiling version_check v0.9.4 + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=version_check CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/version_check-0.9.4 CARGO_PKG_AUTHORS='Sergio Benitez ' CARGO_PKG_DESCRIPTION='Tiny crate to check the version of the installed/running rustc.' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE=MIT/Apache-2.0 CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=version_check CARGO_PKG_REPOSITORY='https://github.com/SergioBenitez/version_check' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.9.4 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=9 CARGO_PKG_VERSION_PATCH=4 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/debug/deps:/usr/lib' rustc --crate-name version_check /<>/debian/cargo_registry/version_check-0.9.4/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=8fbcc0cfecc6d0cb -C extra-filename=-8fbcc0cfecc6d0cb --out-dir /<>/target/debug/deps -L dependency=/<>/target/debug/deps --cap-lints warn` + +[...] + + Compiling hickory-proto v0.24.0 + Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=hickory_proto CARGO_MANIFEST_DIR=/<>/debian/cargo_registry/hickory-proto-0.24.0 CARGO_PKG_AUTHORS='The contributors to Hickory DNS' CARGO_PKG_DESCRIPTION='Hickory DNS is a safe and secure DNS library. This is the foundational DNS protocol library for all Hickory DNS projects. +' CARGO_PKG_HOMEPAGE='https://hickory-dns.org/' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=hickory-proto CARGO_PKG_REPOSITORY='https://github.com/hickory-dns/hickory-dns' CARGO_PKG_RUST_VERSION=1.67.0 CARGO_PKG_VERSION=0.24.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=24 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/<>/target/release/deps:/usr/lib' rustc --crate-name hickory_proto --edition=2021 /<>/debian/cargo_registry/hickory-proto-0.24.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="dnssec"' --cfg 'feature="dnssec-openssl"' --cfg 'feature="openssl"' --cfg 'feature="text-parsing"' --cfg 'feature="tokio"' --cfg 'feature="tokio-runtime"' -C metadata=f979ffc854cc5f10 -C extra-filename=-f979ffc854cc5f10 --out-dir /<>/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/<>/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/<>/target/release/deps --extern async_trait=/<>/target/release/deps/libasync_trait-df69a4acba09d283.so --extern cfg_if=/<>/target/x86_64-unknown-linux-gnu/release/deps/libcfg_if-419b8f7f1d117524.rmeta --extern data_encoding=/<>/target/x86_64-unknown-linux-gnu/release/deps/libdata_encoding-822c5aab9966b981.rmeta --extern enum_as_inner=/<>/target/release/deps/libenum_as_inner-d84db2133bad653a.so --extern futures_channel=/<>/target/x86_64-unknown-linux-gnu/release/deps/libfutures_channel-a1c4398ad131d176.rmeta --extern futures_io=/<>/target/x86_64-unknown-linux-gnu/release/deps/libfutures_io-fa3cb5b221c1cbcb.rmeta --extern futures_util=/<>/target/x86_64-unknown-linux-gnu/release/deps/libfutures_util-6416ccae8ede3d19.rmeta --extern idna=/<>/target/x86_64-unknown-linux-gnu/release/deps/libidna-3ac24961e95d2107.rmeta --extern ipnet=/<>/target/x86_64-unknown-linux-gnu/release/deps/libipnet-75eac24a0db7e143.rmeta --extern once_cell=/<>/target/x86_64-unknown-linux-gnu/release/deps/libonce_cell-a6a742d6555a5b0e.rmeta --extern openssl=/<>/target/x86_64-unknown-linux-gnu/release/deps/libopenssl-f004e001e1af9b9b.rmeta --extern rand=/<>/target/x86_64-unknown-linux-gnu/release/deps/librand-960924b39db562a2.rmeta --extern thiserror=/<>/target/x86_64-unknown-linux-gnu/release/deps/libthiserror-b7ba303895f276dc.rmeta --extern tinyvec=/<>/target/x86_64-unknown-linux-gnu/release/deps/libtinyvec-ca5d3e62d102b212.rmeta --extern tokio=/<>/target/x86_64-unknown-linux-gnu/release/deps/libtokio-8ff8126f1bcb6142.rmeta --extern tracing=/<>/target/x86_64-unknown-linux-gnu/release/deps/libtracing-55baabb9fa6c9887.rmeta --extern url=/<>/target/x86_64-unknown-linux-gnu/release/deps/liburl-87876948633d6bd5.rmeta --cap-lints warn -C debuginfo=2 --cap-lints warn -C linker=x86_64-linux-gnu-gcc -C link-arg=-Wl,-z,relro --remap-path-prefix /<>=/usr/share/cargo/registry/sequoia-chameleon-gnupg-0.5.1 --remap-path-prefix /<>/debian/cargo_registry=/usr/share/cargo/registry` diff --git a/t/tests.t b/t/tests.t index b1c1e86..4216c35 100644 --- a/t/tests.t +++ b/t/tests.t @@ -19,7 +19,7 @@ use strict; use warnings; -use Test::More tests => 246; +use Test::More tests => 248; sub is_blhc { @@ -885,6 +885,12 @@ NONVERBOSE BUILD: /bin/bash ../libtool --silent --tag=CC --mode=compile gcc -D NONVERBOSE BUILD: /bin/bash ../libtool --silent --tag=CC --mode=link gcc -Wall -Wextra -Wconversion -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fPIE -pie -Wl,-z,relro -Wl,-z,now -o libcoloredstderr.la -rpath /usr/local/lib coloredstderr.lo -ldl '; +# cargo/rust + +is_blhc 'cargo', '', 1, + $empty; + + # different architectures