X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fblhc;h=f11ba111028c3949fd526a8f89eee47f316fba2c;hb=14b61d421e2479318cb2971acc1c94812f5a8ac1;hp=b37bf6ee30d8605ce35903fd79eb488b4b03491e;hpb=3ea6e44ffc1cf56f95831c108825f39985d913c9;p=blhc%2Fblhc.git diff --git a/bin/blhc b/bin/blhc index b37bf6e..f11ba11 100755 --- a/bin/blhc +++ b/bin/blhc @@ -24,7 +24,7 @@ use warnings; use Getopt::Long (); use Text::ParseWords (); -our $VERSION = '0.07'; +our $VERSION = '0.08'; # CONSTANTS/VARIABLES @@ -431,17 +431,33 @@ sub all_flags_used { sub cppflags_fortify_broken { my ($line, $missing_flags) = @_; - # This doesn't take the position into account, but is a simple solution. - # And if the build system tries to force -D_FORTIFY_SOURCE=0/1, something - # is wrong anyway. + if (not any_flags_used($line, @def_cppflags_fortify_bad)) { + return 0; + } + + # $def_cppflags_fortify[0] must be -D_FORTIFY_SOURCE=2! + my $fortify_source = $def_cppflags_fortify[0]; - if (any_flags_used($line, @def_cppflags_fortify_bad)) { - # $def_cppflags_fortify[0] must be -D_FORTIFY_SOURCE=2! - push @{$missing_flags}, $def_cppflags_fortify[0]; - return 1; + # Some build systems enable/disable fortify source multiple times, check + # the final result. + my $disable_pos = 0; + foreach my $flag (@def_cppflags_fortify_bad) { + while ($line =~ /$flag/g) { + if ($disable_pos < $+[0]) { + $disable_pos = $+[0]; + } + } + } + my $enable_pos = 0; + while ($line =~ /$fortify_source/g) { + $enable_pos = $+[0]; + } + if ($enable_pos > $disable_pos) { + return 0; } - return 0; + push @{$missing_flags}, $fortify_source; + return 1; } # Modifies $missing_flags_ref array. @@ -872,7 +888,7 @@ foreach my $file (@ARGV) { # This flags is not always available, but if it is use it. if ($line =~ /^DEB_BUILD_OPTIONS=.*\bparallel=(\d+)/) { - $parallel = $1; + $parallel = $1 * 2; } # We skip over unimportant lines at the beginning of the log to