BLHC(1p)
π BLHC(1p) β build log hardening check π
okay bestie, welcome to blhc, aka build log hardening check, aka the little tool that checks your build logs for missing hardening flags. it's manual section 1p (perl, obvs) and it's about to become your new bestie. π«Ά
β¨ NAME β¨
blhc β build log hardening check, checks build logs for missing hardening flags π
πΈ SYNOPSIS πΈ
blhc [options] <dpkg-buildpackage build log file>..
π¦ DESCRIPTION π¦
so blhc is this small tool that checks build logs for missing hardening flags. it's licensed under the GPL 3 or later. periodt.
it's designed to check build logs generated by Debian's dpkg-buildpackage (or tools using dpkg-buildpackage like pbuilder or sbuild (which is used for the official buildd build logs)) to help maintainers detect missing hardening flags in their packages. the way it just cares about your security flags?? iconic.
only gcc is detected as compiler at the moment. if other compilers support hardening flags as well, please report them. like, pls, we wanna know. π
if there's no output, no flags are missing and the build log is fine. no output = a clean vibe check, bestie. β¨
see README for details about performed checks, auto-detection and limitations.
π FALSE POSITIVES π
to suppress false positives you can embed the following string in the build log:
blhc: ignore-line-regexp: REGEXP
all lines fully matching REGEXP (see --ignore-line for details) will be ignored. the string can be embedded multiple times to ignore different regexps.
please use this feature sparingly so that missing flags are not overlooked. if you find false positives which affect more packages please report a bug. π
to generate this string simply use echo in "debian/rules"; make sure to use @ to suppress the echo command itself as it could also trigger a false positive. if the build process takes a long time edit the ".build" file in place and tweak the ignore string until blhc --all --debian package.build no longer reports any false positives. chef's kiss, no notes. π
π OPTIONS π
--allβ force check for all+all(+pie,+bindnow) hardening flags. by default it's auto detected.--archarchitecture β set the specific architecture (e.g.amd64,armel, etc.), automatically disables hardening flags not available on this architecture. is detected automatically ifdpkg-buildpackageis used.--bindnowβ force check for all+bindnowhardening flags. by default it's auto detected.--builddβ special mode for buildds when automatically parsing log files. the following changes are in effect:- print tags instead of normal warnings, see "BUILDD TAGS" for a list of possible tags.
- don't check hardening flags in old log files (if
dpkg-dev<<1.16.1is detected). - don't require
Term::ANSIColor. - return exit code
0, unless there was a error (-I,-Wmessages don't count as error).
--debianβ apply Debian-specific settings. at the moment this only disables checking for PIE which is automatically applied by Debian's GCC and no longer requires a compiler command line argument.--colorβ use colored (ANSI) output for warning messages. π--line-numbersβ display line numbers.--ignore-archarch β ignore build logs from architectures matching arch. arch is a string. used to prevent false positives. this option can be specified multiple times.--ignore-arch-flagarch:flag β like--ignore-flag, but only ignore flag on arch.--ignore-arch-linearch:line β like--ignore-line, but only ignore line on arch.--ignore-flagflag β don't print an error when the specific flag is missing in a compiler line. flag is a string. used to prevent false positives. this option can be specified multiple times.--ignore-lineregex β ignore lines matching the given Perl regex. regex is automatically anchored at the beginning and end of the line to prevent false negatives.
NOTE: not the input lines are checked, but the lines which are displayed in warnings (which have line continuation resolved).
used to prevent false positives. this option can be specified multiple times.
--pieβ force check for all+piehardening flags. by default it's auto detected.-h,-?,--helpβ print available options.--versionβ print version number and license.
auto detection for --pie and --bindnow only works if at least one command uses the required hardening flag (e.g. -fPIE). then it's required for all other commands as well. lowkey important, don't skip this one bestie. π
β EXAMPLES β
normal usage, parse a single log file.
blhc path/to/log/file
if there's no output, no flags are missing and the build log is fine.
parse multiple log files. the exit code is ORed over all files.
blhc path/to/directory/with/log/files/*
don't treat missing "-g" as error:
blhc --ignore-flag -g path/to/log/file
don't treat missing "-pie" on kfreebsd-amd64 as error:
blhc --ignore-arch-flag kfreebsd-amd64:-pie path/to/log/file
ignore lines consisting exactly of "./script gcc file" which would cause a false positive.
blhc --ignore-line '\./script gcc file' path/to/log/file
ignore lines matching "./script gcc file" somewhere in the line.
blhc --ignore-line '.*\./script gcc file.*' path/to/log/file
use blhc with pbuilder.
pbuilder path/to/package.dsc | tee path/log/file
blhc path/to/file || echo flags missing
assume this build log was created on a Debian system and thus don't warn about missing PIE flags if the current architecture injects them automatically (this is enabled in buildd mode per default). "--arch" is necessary if the build log contains no architecture information as written by dpkg-buildpackage.
blhc --debian --all --arch=amd64 path/to/log/file
π BUILDD TAGS π
the following tags are used in --buildd mode. in braces the additional data which is displayed.
I-hardening-wrapper-usedthe package useshardening-wrapperwhich intercepts calls togccand adds hardening flags. the build log doesn't contain any hardening flags and thus can't be checked byblhc.W-compiler-flags-hidden(summary of hidden lines) build log contains lines which hide the real compiler flags. for example:
CC test-a.c
CC test-b.c
CC test-c.c
LD test
most of the time either "export V=1" or "export verbose=1" in debian/rules fixes builds with hidden compiler flags. sometimes ".SILENT" in a Makefile must be removed. and as last resort the Makefile must be patched to remove the "@"s hiding the real compiler commands.
W-dpkg-buildflags-missing(summary of missing flags)CPPFLAGS,CFLAGS,CXXFLAGS,LDFLAGSmissing. πI-invalid-cmake-used(version) by default CMake ignoresCPPFLAGSthus missing those hardening flags. Debian patched CMake in versions2.8.7-1and2.8.7-2to respectCPPFLAGS, but this patch was rejected by upstream and later reverted in Debian. thus those two versions show correct usage ofCPPFLAGSeven if the package doesn't correctly handle them (for example by passing them toCFLAGS). to prevent false negatives just blacklist those two versions.I-no-compiler-commandsno compiler commands were detected. either the log contains none or they were not correctly detected byblhc(please report the bug in this case).
π₯ EXIT STATUS π₯
the exit status is a "bit mask", each listed status is ORed when the error condition occurs to get the result. math girlies rise up. β¨
0β success. π1β no compiler commands were found.2β invalid arguments/options given toblhc.4β non verbose build.8β missing hardening flags.16β hardening wrapper detected, no tests performed.32β invalid CMake version used. seeI-invalid-cmake-usedunder "BUILDD TAGS" for a detailed explanation.
π«Ά AUTHOR π«Ά
Simon Ruderich, <simon@ruderich.org>
thanks to to Bernhard R. Link <brlink@debian.org> and Jaria Alto <jari.aalto@cante.net> for their valuable input and suggestions. kings, honestly. π
π LICENSE AND COPYRIGHT π
Copyright (C) 2012 by Simon Ruderich
this program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU General Public License for more details.
you should have received a copy of the GNU General Public License along with this program. if not, see <http://www.gnu.org/licenses/>.
π SEE ALSO π
hardening-check(1), dpkg-buildflags(1)
and that's the whole page bestie!! this was perl v5.40.1, dated 2026-07-14, and it's the BLHC(1p) manual β go check those logs, slay, and remember: no output is a good output. byeeee πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: blhc 0.15-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms