| 1 | # Copyright © 2009-2011 Raphaël Hertzog <hertzog@debian.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright © 2009-2024 Guillem Jover <guillem@debian.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Hardening build flags handling derived from work of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Copyright © 2009-2011 Kees Cook <kees@debian.org> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Copyright © 2007-2008 Canonical, Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # the Free Software Foundation; either version 2 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | Dpkg::Vendor::Debian - Debian vendor class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | This vendor class customizes the behavior of dpkg scripts for Debian | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | specific behavior and policies. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | B<Note>: This is a private module, its API can change at any time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | package Dpkg::Vendor::Debian 0.01; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 14 | ▶ | use List::Util qw(any none); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 14 | ▶ | use Dpkg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 14 | ▶ | use Dpkg::Gettext; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 14 | ▶ | use Dpkg::ErrorHandling; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 14 | ▶ | use Dpkg::Control::Types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 14 | ▶ | use parent qw(Dpkg::Vendor::Default); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 287 | ▶ | sub run_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_hook: called CC=19 SCAR=48.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 287 | my ($self, $hook, @params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 287 | ▶ | if ($hook eq 'package-keyrings') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 13 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return ('/usr/share/keyrings/debian-keyring.pgp', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | '/usr/share/keyrings/debian-tag2upload.pgp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | '/usr/share/keyrings/debian-nonupload.pgp', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | '/usr/share/keyrings/debian-maintainers.pgp'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } elsif ($hook eq 'archive-keyrings') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return ('/usr/share/keyrings/debian-archive-keyring.pgp'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } elsif ($hook eq 'archive-keyrings-historic') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | return ('/usr/share/keyrings/debian-archive-removed-keys.pgp'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } elsif ($hook eq 'builtin-build-depends') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | return qw(build-essential:native); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } elsif ($hook eq 'builtin-build-conflicts') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } elsif ($hook eq 'register-custom-fields') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } elsif ($hook eq 'extend-patch-header') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($textref, $ch_info) = @params; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ($ch_info->{'Closes'}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | foreach my $bug (split(/\s+/, $ch_info->{'Closes'})) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $$textref .= "Bug-Debian: https://bugs.debian.org/$bug\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # XXX: Layer violation... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | require Dpkg::Vendor::Ubuntu; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $b = Dpkg::Vendor::Ubuntu::find_launchpad_closes($ch_info->{'Changes'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | foreach my $bug (@$b) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $$textref .= "Bug-Ubuntu: https://bugs.launchpad.net/bugs/$bug\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } elsif ($hook eq 'update-buildflags') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 26 | $self->set_build_features(@params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 26 | $self->add_build_flags(@params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } elsif ($hook eq 'builtin-system-build-paths') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return qw(/build/); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } elsif ($hook eq 'build-tainted-by') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | return $self->_build_tainted_by(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } elsif ($hook eq 'sanitize-environment') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # Reset umask to a sane default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | umask 0o022; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # Reset locale to a sane default. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # We ignore the LANGUAGE GNU extension, as that only affects | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # LC_MESSAGES which will use LC_CTYPE for its codeset. We need to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # move the high priority LC_ALL catch-all into the low-priority | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # LANG catch-all so that we can override LC_* variables, and remove | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # any existing LC_* variables which would have been ignored anyway, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # and would now take precedence over LANG. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (length $ENV{LC_ALL}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $ENV{LANG} = delete $ENV{LC_ALL}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | foreach my $lc (grep { m/^LC_/ } keys %ENV) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | delete $ENV{$lc}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $ENV{LC_COLLATE} = 'C.UTF-8'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $ENV{LC_CTYPE} = 'C.UTF-8'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } elsif ($hook eq 'backport-version-regex') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | return qr/~(bpo|deb)/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | } elsif ($hook eq 'has-fuzzy-native-source') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 250 | return $self->SUPER::run_hook($hook, @params); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 26 | ▶ | sub init_build_features { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_build_features: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 26 | my ($self, $use_feature, $builtin_feature) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 26 | ▶ | sub set_build_features { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_build_features: called CC=47 SCAR=45.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 26 | my ($self, $flags) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # Default feature states. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 26 | my %use_feature = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | future => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # XXX: Should start a deprecation cycle at some point. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | lfs => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | abi => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # XXX: This is set to undef so that we can handle the alias from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # the future feature area. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | lfs => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # XXX: This is set to undef to handle mask on the default setting. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | time64 => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | qa => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | bug => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 'bug-implicit-func' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | canary => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | reproducible => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | timeless => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | fixfilepath => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | fixdebugpath => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | optimize => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | lto => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | sanitize => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | address => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | thread => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | leak => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | undefined => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | hardening => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # XXX: This is set to undef so that we can cope with the brokenness | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # of gcc managing this feature builtin. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | pie => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | stackprotector => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | stackprotectorstrong => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | stackclash => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | fortify => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | format => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | relro => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | bindnow => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | branch => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 26 | my %builtin_feature = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | abi => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | lfs => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | time64 => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | hardening => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | pie => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 26 | require Dpkg::Arch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 26 | my $arch = Dpkg::Arch::get_host_arch(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 26 | my ($abi, $libc, $os, $cpu) = Dpkg::Arch::debarch_to_debtuple($arch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 26 | my ($abi_bits, $abi_endian) = Dpkg::Arch::debarch_to_abiattrs($arch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 26 | ▶ | unless (defined $abi and defined $libc and defined $os and defined $cpu) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
defined $abi and defined $libc and defined $os and defined $cpu
defined $abi and defined $libc and defined $os
defined $abi and defined $libc
MC/DC0%0/4
defined $abi and defined $libc and defined $os and defined $cpu
defined $abi
defined $libc
defined $os
defined $cpu
Truth table20%1/5
A and B and C and D
A= defined $abiB= defined $libcC= defined $osD= defined $cpu
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | warning(g_("unknown host architecture '%s'"), $arch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ($abi, $os, $cpu) = ('', '', ''); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 26 | ▶ | unless (defined $abi_bits and defined $abi_endian) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $abi_bits and defined $abi_endian
MC/DC0%0/2
defined $abi_bits and defined $abi_endian
defined $abi_bits
defined $abi_endian
Truth table33%1/3
A and B
A= defined $abi_bitsB= defined $abi_endian
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | warning(g_("unknown abi attributes for architecture '%s'"), $arch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ($abi_bits, $abi_endian) = (0, 'unknown'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # Mask builtin features that are not enabled by default in the compiler. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 26 | my %builtin_pie_arch = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | arm64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | armel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | armhf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | hurd-amd64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | hurd-i386 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | i386 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | loong64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | mips | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | mips64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | mips64el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | mips64r6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | mips64r6el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | mipsel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | mipsn32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | mipsn32el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | mipsn32r6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | mipsn32r6el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | mipsr6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | mipsr6el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | powerpc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | ppc64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | ppc64el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | riscv64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | s390x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | sparc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | sparc64 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 26 | ▶ | if (not exists $builtin_pie_arch{$arch}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $builtin_feature{hardening}{pie} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 26 | ▶ | if ($abi_bits != 32) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 13 | $builtin_feature{abi}{lfs} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # On glibc, new ports default to time64, old ports currently default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # to time32, so we track the latter as that is a list that is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | # going to grow further, and might shrink. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # On musl libc based systems all ports use time64. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 26 | my %time32_arch = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | arm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | armeb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | armel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | armhf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | hppa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | i386 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | hurd-i386 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | m68k | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | mips | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | mipsel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | mipsn32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | mipsn32el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | mipsn32r6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | mipsn32r6el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | mipsr6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | mipsr6el | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | nios2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | powerpc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | powerpcel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | s390 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | sh3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | sh3eb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | sh4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | sh4eb | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | sparc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 26 | ▶ | if ($abi_bits != 32 or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$abi_bits != 32 or not exists $time32_arch{$arch} or $libc eq "musl"
$abi_bits != 32 or not exists $time32_arch{$arch}
MC/DC33%1/3
$abi_bits != 32 or not exists $time32_arch{$arch} or $libc eq "musl"
$abi_bits != 32
not exists $time32_arch{$arch}
$libc eq "musl"
Truth table50%2/4
A or not(B) or C
A= $abi_bits != 32B= not exists $time32_arch{$arch}C= $libc eq "musl"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | not exists $time32_arch{$arch} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | $libc eq 'musl') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 13 | $builtin_feature{abi}{time64} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 26 | $self->init_build_features(\%use_feature, \%builtin_feature); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | ## Setup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 26 | require Dpkg::BuildOptions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # Adjust features based on user or maintainer's desires. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 26 | my $opts_build = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_OPTIONS'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 26 | my $opts_maint = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_MAINT_OPTIONS'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 26 | foreach my $area (sort keys %use_feature) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 182 | $opts_build->parse_features($area, $use_feature{$area}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 182 | $opts_maint->parse_features($area, $use_feature{$area}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | ## Area: abi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 26 | ▶ | if ($arch eq 'hurd-i386') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # Mask time64 on hurd-i386, as its kernel lacks support for that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # feature and it will not be implemented. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 3 | $use_feature{abi}{time64} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } elsif (not defined $use_feature{abi}{time64}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | # If the user has not requested a specific setting, by default only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # enable time64 everywhere except for i386, where we preserve it for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # binary backwards compatibility. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 17 | ▶ | if ($arch eq 'i386') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 5 | $use_feature{abi}{time64} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 12 | $use_feature{abi}{time64} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | # In Debian gcc enables time64 (and lfs) for the following architectures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # by injecting pre-processor flags, though the libc ABI has not changed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 26 | ▶ | if (any { $arch eq $_ } qw(armel armhf hppa m68k mips mipsel powerpc sh4)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | $flags->set_option_value('cc-abi-time64', 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 23 | $flags->set_option_value('cc-abi-time64', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 26 | ▶ | if ($use_feature{abi}{time64} && ! $builtin_feature{abi}{time64}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$use_feature{"abi"}{"time64"} and not $builtin_feature{"abi"}{"time64"}
MC/DC100%2/2
$use_feature{"abi"}{"time64"} and not $builtin_feature{"abi"}{"time64"}
$use_feature{"abi"}{"time64"}
not $builtin_feature{"abi"}{"time64"}
Truth table100%3/3
A and not(B)
A= $use_feature{"abi"}{"time64"}B= not $builtin_feature{"abi"}{"time64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # On glibc 64-bit time_t support requires LFS. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 3 | ▶ | $use_feature{abi}{lfs} = 1 if $libc eq 'gnu'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # XXX: Handle lfs alias from future abi feature area. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 26 | ▶ | $use_feature{abi}{lfs} //= $use_feature{future}{lfs}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$use_feature{"abi"}{"lfs"} //= $use_feature{"future"}{"lfs"}
MC/DC0%0/2
$use_feature{"abi"}{"lfs"} //= $use_feature{"future"}{"lfs"}
$use_feature{"abi"}{"lfs"}
$use_feature{"future"}{"lfs"}
Truth table66%2/3
A //= B
A= $use_feature{"abi"}{"lfs"}B= $use_feature{"future"}{"lfs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | # XXX: Once the feature is set in the abi area, we always override the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # one in the future area. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 26 | $use_feature{future}{lfs} = $use_feature{abi}{lfs}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | ## Area: qa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # For time64 we require -Werror=implicit-function-declaration, to avoid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # linking against the wrong symbol. Instead of enabling this conditionally | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # on time64 being enabled, do it unconditionally so that the effects are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # uniform and visible on all architectures. Unless it has been set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # explicitly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 26 | ▶ | $use_feature{qa}{'bug-implicit-func'} //= $use_feature{qa}{bug} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$use_feature{"qa"}{"bug-implicit-func"} //= $use_feature{"qa"}{"bug"} // 1
$use_feature{"qa"}{"bug"} // 1
MC/DC100%1/1
$use_feature{"qa"}{"bug-implicit-func"} //= $use_feature{"qa"}{"bug"} // 1
$use_feature{"qa"}{"bug-implicit-func"}
Truth table100%2/2
A
A= $use_feature{"qa"}{"bug-implicit-func"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 26 | ▶ | $use_feature{qa}{bug} //= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$use_feature{"qa"}{"bug"} //= 0
MC/DC100%1/1
$use_feature{"qa"}{"bug"} //= 0
$use_feature{"qa"}{"bug"}
Truth table100%2/2
A
A= $use_feature{"qa"}{"bug"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | ## Area: reproducible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | # Mask features that might have an unsafe usage. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 26 | ▶ | if ($use_feature{reproducible}{fixfilepath} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$use_feature{"reproducible"}{"fixfilepath"} or $use_feature{"reproducible"}{"fixdebugpath"}
MC/DC0%0/2
$use_feature{"reproducible"}{"fixfilepath"} or $use_feature{"reproducible"}{"fixdebugpath"}
$use_feature{"reproducible"}{"fixfilepath"}
$use_feature{"reproducible"}{"fixdebugpath"}
Truth table33%1/3
A or B
A= $use_feature{"reproducible"}{"fixfilepath"}B= $use_feature{"reproducible"}{"fixdebugpath"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | $use_feature{reproducible}{fixdebugpath}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 26 | require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 26 | ▶ | my $build_path = $ENV{DEB_BUILD_PATH} || Cwd::getcwd(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{'DEB_BUILD_PATH'} || Cwd::getcwd()
MC/DC0%0/2
$ENV{'DEB_BUILD_PATH'} || Cwd::getcwd()
$ENV{'DEB_BUILD_PATH'}
Cwd::getcwd()
Truth table33%1/3
A || B
A= $ENV{'DEB_BUILD_PATH'}B= Cwd::getcwd()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 26 | $flags->set_option_value('build-path', $build_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # If we have any unsafe character in the path, disable the flag, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # so that we do not need to worry about escaping the characters | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # on output. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 26 | ▶ | if ($build_path =~ m/[^-+:.0-9a-zA-Z~\/_]/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $use_feature{reproducible}{fixfilepath} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $use_feature{reproducible}{fixdebugpath} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | ## Area: optimize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 26 | ▶ | if ($opts_build->has('noopt')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $flags->set_option_value('optimize-level', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 26 | $flags->set_option_value('optimize-level', 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ## Area: sanitize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # Handle logical feature interactions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 26 | ▶ | if ($use_feature{sanitize}{address} and $use_feature{sanitize}{thread}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$use_feature{"sanitize"}{"address"} and $use_feature{"sanitize"}{"thread"}
MC/DC0%0/2
$use_feature{"sanitize"}{"address"} and $use_feature{"sanitize"}{"thread"}
$use_feature{"sanitize"}{"address"}
$use_feature{"sanitize"}{"thread"}
Truth table33%1/3
A and B
A= $use_feature{"sanitize"}{"address"}B= $use_feature{"sanitize"}{"thread"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # Disable the thread sanitizer when the address one is active, they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # are mutually incompatible. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $use_feature{sanitize}{thread} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 26 | ▶ | if ($use_feature{sanitize}{address} or $use_feature{sanitize}{thread}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$use_feature{"sanitize"}{"address"} or $use_feature{"sanitize"}{"thread"}
MC/DC0%0/2
$use_feature{"sanitize"}{"address"} or $use_feature{"sanitize"}{"thread"}
$use_feature{"sanitize"}{"address"}
$use_feature{"sanitize"}{"thread"}
Truth table33%1/3
A or B
A= $use_feature{"sanitize"}{"address"}B= $use_feature{"sanitize"}{"thread"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # Disable leak sanitizer, it is implied by the address or thread ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $use_feature{sanitize}{leak} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ## Area: hardening | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # Mask features that are not available on certain architectures. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 26 | ▶ | if (none { $os eq $_ } qw(linux hurd) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.8
Branch: 1 branch
Condition33%1/3
&none(sub {
$os eq $_;
}
, "linux", "hurd") or &any(sub {
$cpu eq $_;
}
, "alpha", "hppa", "ia64", "m68k", "sh4", "x32")
MC/DC0%0/2
&none(sub {
$os eq $_;
}
, "linux", "hurd") or &any(sub {
$cpu eq $_;
}
, "alpha", "hppa", "ia64", "m68k", "sh4", "x32")
&none(sub {
$os eq $_;
}
, "linux", "hurd")
&any(sub {
$cpu eq $_;
}
, "alpha", "hppa", "ia64", "m68k", "sh4", "x32")
Truth table33%1/3
A or B
A= &none(sub {
$os eq $_;
}
, "linux", "hurd")B= &any(sub {
$cpu eq $_;
}
, "alpha", "hppa", "ia64", "m68k", "sh4", "x32")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 156 | ▶ | any { $cpu eq $_ } qw(alpha hppa ia64 m68k sh4 x32)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Disabled on non-(linux/hurd). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # Disabled on alpha, hppa, ia64, m68k, sh4, x32. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $use_feature{hardening}{pie} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 26 | ▶ | if (any { $cpu eq $_ } qw(ia64 alpha hppa nios2) or $arch eq 'arm') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.8
Branch: 1 branch
Condition33%1/3
&any(sub {
$cpu eq $_;
}
, "ia64", "alpha", "hppa", "nios2") or $arch eq "arm"
MC/DC0%0/2
&any(sub {
$cpu eq $_;
}
, "ia64", "alpha", "hppa", "nios2") or $arch eq "arm"
&any(sub {
$cpu eq $_;
}
, "ia64", "alpha", "hppa", "nios2")
$arch eq "arm"
Truth table33%1/3
A or B
A= &any(sub {
$cpu eq $_;
}
, "ia64", "alpha", "hppa", "nios2")B= $arch eq "arm"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # Stack protector disabled on ia64, alpha, hppa, nios2. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # "warning: -fstack-protector not supported for this target" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | # Stack protector disabled on arm (ok on armel). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | # compiler supports it incorrectly (leads to SEGV) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | $use_feature{hardening}{stackprotector} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 26 | ▶ | if (none { $arch eq $_ } qw(amd64 arm64 armhf armel)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # Stack clash protector only available on amd64 and arm. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 13 | $use_feature{hardening}{stackclash} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 26 | ▶ | if (any { $cpu eq $_ } qw(ia64 hppa)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | # relro not implemented on ia64, hppa. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $use_feature{hardening}{relro} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 26 | ▶ | if (none { $cpu eq $_ } qw(amd64 arm64)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # On amd64 use -fcf-protection. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # On arm64 use -mbranch-protection=standard. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 16 | $use_feature{hardening}{branch} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 26 | $flags->set_option_value('hardening-branch-cpu', $cpu); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # Mask features that might be influenced by other flags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 26 | ▶ | if ($flags->get_option_value('optimize-level') == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # glibc 2.16 and later warn when using -O0 and _FORTIFY_SOURCE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $use_feature{hardening}{fortify} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 26 | $flags->set_option_value('fortify-level', 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | # Handle logical feature interactions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 26 | ▶ | if ($use_feature{hardening}{relro} == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | # Disable bindnow if relro is not enabled, since it has no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | # hardening ability without relro and may incur load penalties. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $use_feature{hardening}{bindnow} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 26 | ▶ | if ($use_feature{hardening}{stackprotector} == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # Disable stackprotectorstrong if stackprotector is disabled. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $use_feature{hardening}{stackprotectorstrong} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | ## Commit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # Set used features to their builtin setting if unset. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 26 | foreach my $area (sort keys %builtin_feature) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 52 | ▶ | while (my ($feature, $enabled) = each %{$builtin_feature{$area}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 78 | $flags->set_builtin($area, $feature, $enabled); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # Store the feature usage. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 26 | foreach my $area (sort keys %use_feature) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 182 | ▶ | while (my ($feature, $enabled) = each %{$use_feature{$area}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 598 | $flags->set_feature($area, $feature, $enabled); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 26 | ▶ | sub add_build_flags { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_build_flags: called CC=56 SCAR=50.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 26 | my ($self, $flags) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | ## Global default flags | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 26 | my @compile_flags = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | CFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | CXXFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | OBJCFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | OBJCXXFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | FFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | FCFLAGS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 26 | my $default_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | my $default_d_flags; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 26 | my $optimize_level = $flags->get_option_value('optimize-level'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 26 | $default_flags = "-g -O$optimize_level"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 26 | ▶ | if ($optimize_level == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $default_d_flags = '-fdebug'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 26 | $default_d_flags = '-frelease'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 26 | $flags->append($_, $default_flags) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 26 | $flags->append('DFLAGS', $default_d_flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ## Area: abi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 26 | my %abi_builtins = $flags->get_builtins('abi'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 26 | my $cc_abi_time64 = $flags->get_option_value('cc-abi-time64'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 26 | ▶ | if ($flags->use_feature('abi', 'lfs') && ! $abi_builtins{lfs}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$flags->use_feature("abi", "lfs") and not $abi_builtins{"lfs"}
MC/DC50%1/2
$flags->use_feature("abi", "lfs") and not $abi_builtins{"lfs"}
$flags->use_feature("abi", "lfs")
not $abi_builtins{"lfs"}
Truth table66%2/3
A and not(B)
A= $flags->use_feature("abi", "lfs")B= not $abi_builtins{"lfs"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 6 | $flags->append('CPPFLAGS', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | '-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | ▶ | } elsif (! $flags->use_feature('abi', 'lfs') && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
not $flags->use_feature("abi", "lfs") || $abi_builtins{"lfs"} and $cc_abi_time64
$flags->use_feature('abi', 'lfs') || $abi_builtins{'lfs'}
MC/DC66%2/3
not $flags->use_feature("abi", "lfs") || $abi_builtins{"lfs"} and $cc_abi_time64
$flags->use_feature('abi', 'lfs')
$abi_builtins{'lfs'}
$cc_abi_time64
Truth table75%3/4
not(A || B) and C
A= $flags->use_feature('abi', 'lfs')B= $abi_builtins{'lfs'}C= $cc_abi_time64
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | ! $abi_builtins{lfs} && $cc_abi_time64) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | $flags->append('CPPFLAGS', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | '-U_LARGEFILE_SOURCE -U_FILE_OFFSET_BITS'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 26 | ▶ | if ($flags->use_feature('abi', 'time64') && ! $abi_builtins{time64}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$flags->use_feature("abi", "time64") and not $abi_builtins{"time64"}
MC/DC100%2/2
$flags->use_feature("abi", "time64") and not $abi_builtins{"time64"}
$flags->use_feature("abi", "time64")
not $abi_builtins{"time64"}
Truth table100%3/3
A and not(B)
A= $flags->use_feature("abi", "time64")B= not $abi_builtins{"time64"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 3 | $flags->append('CPPFLAGS', '-D_TIME_BITS=64'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | ▶ | } elsif (! $flags->use_feature('abi', 'time64') && | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
not $flags->use_feature("abi", "time64") || $abi_builtins{"time64"} and $cc_abi_time64
$flags->use_feature('abi', 'time64') || $abi_builtins{'time64'}
MC/DC100%3/3
not $flags->use_feature("abi", "time64") || $abi_builtins{"time64"} and $cc_abi_time64
$flags->use_feature('abi', 'time64')
$abi_builtins{'time64'}
$cc_abi_time64
Truth table100%4/4
not(A || B) and C
A= $flags->use_feature('abi', 'time64')B= $abi_builtins{'time64'}C= $cc_abi_time64
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ! $abi_builtins{time64} && $cc_abi_time64) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | $flags->append('CPPFLAGS', '-U_TIME_BITS'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ## Area: qa | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # Warnings that detect actual bugs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 26 | ▶ | if ($flags->use_feature('qa', 'bug-implicit-func')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 24 | $flags->append('CFLAGS', '-Werror=implicit-function-declaration'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 2 | $flags->append('CFLAGS', '-Wno-error=implicit-function-declaration'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 26 | ▶ | if ($flags->use_feature('qa', 'bug')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # C/C++ flags. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 2 | my @cfamilyflags = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | array-bounds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | clobbered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | volatile-register-var | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | foreach my $warnflag (@cfamilyflags) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 6 | $flags->append('CFLAGS', "-Werror=$warnflag"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 6 | $flags->append('CXXFLAGS', "-Werror=$warnflag"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # Inject dummy canary options to detect issues with build flag propagation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 26 | ▶ | if ($flags->use_feature('qa', 'canary')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | require Digest::MD5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $id = Digest::MD5::md5_hex(int rand 4096); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | foreach my $flag (qw(CPPFLAGS CFLAGS OBJCFLAGS CXXFLAGS OBJCXXFLAGS)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $flags->append($flag, "-D__DEB_CANARY_${flag}_${id}__"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $flags->append('LDFLAGS', "-Wl,-z,deb-canary-${id}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ## Area: reproducible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # Warn when the __TIME__, __DATE__ and __TIMESTAMP__ macros are used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 26 | ▶ | if ($flags->use_feature('reproducible', 'timeless')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 26 | $flags->append('CPPFLAGS', '-Wdate-time'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | # Avoid storing the build path in the binaries. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 26 | ▶ | if ($flags->use_feature('reproducible', 'fixfilepath') or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$flags->use_feature("reproducible", "fixfilepath") or $flags->use_feature("reproducible", "fixdebugpath")
MC/DC0%0/2
$flags->use_feature("reproducible", "fixfilepath") or $flags->use_feature("reproducible", "fixdebugpath")
$flags->use_feature("reproducible", "fixfilepath")
$flags->use_feature("reproducible", "fixdebugpath")
Truth table33%1/3
A or B
A= $flags->use_feature("reproducible", "fixfilepath")B= $flags->use_feature("reproducible", "fixdebugpath")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | $flags->use_feature('reproducible', 'fixdebugpath')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 26 | my $build_path = $flags->get_option_value('build-path'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 26 | my $map; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | # -ffile-prefix-map is a superset of -fdebug-prefix-map, prefer it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # if both are set. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 26 | ▶ | if ($flags->use_feature('reproducible', 'fixfilepath')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 26 | $map = '-ffile-prefix-map=' . $build_path . '=.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $map = '-fdebug-prefix-map=' . $build_path . '=.'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 26 | $flags->append($_, $map) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | ## Area: optimize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 26 | ▶ | if ($flags->use_feature('optimize', 'lto')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 3 | my $flag = '-flto=auto -ffat-lto-objects'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 3 | $flags->append($_, $flag) foreach (@compile_flags, 'LDFLAGS'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | ## Area: sanitize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 26 | ▶ | if ($flags->use_feature('sanitize', 'address')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | my $flag = '-fsanitize=address -fno-omit-frame-pointer'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | $flags->append('CFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $flags->append('CXXFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | $flags->append('LDFLAGS', '-fsanitize=address'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 26 | ▶ | if ($flags->use_feature('sanitize', 'thread')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | my $flag = '-fsanitize=thread'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $flags->append('CFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $flags->append('CXXFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $flags->append('LDFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 26 | ▶ | if ($flags->use_feature('sanitize', 'leak')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $flags->append('LDFLAGS', '-fsanitize=leak'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 26 | ▶ | if ($flags->use_feature('sanitize', 'undefined')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my $flag = '-fsanitize=undefined'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | $flags->append('CFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $flags->append('CXXFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $flags->append('LDFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | ## Area: hardening | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # PIE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 26 | my $use_pie = $flags->get_feature('hardening', 'pie'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 26 | my %hardening_builtins = $flags->get_builtins('hardening'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 26 | ▶ | if (defined $use_pie && $use_pie && ! $hardening_builtins{pie}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined $use_pie and $use_pie and not $hardening_builtins{"pie"}
defined $use_pie and $use_pie
MC/DC0%0/3
defined $use_pie and $use_pie and not $hardening_builtins{"pie"}
defined $use_pie
$use_pie
not $hardening_builtins{"pie"}
Truth table25%1/4
A and B and not(C)
A= defined $use_pieB= $use_pieC= not $hardening_builtins{"pie"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $flag = "-specs=$Dpkg::DATADIR/pie-compile.specs"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $flags->append($_, $flag) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $flags->append('LDFLAGS', "-specs=$Dpkg::DATADIR/pie-link.specs"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | ▶ | } elsif (defined $use_pie && ! $use_pie && $hardening_builtins{pie}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
defined $use_pie and not $use_pie and $hardening_builtins{"pie"}
defined $use_pie and not $use_pie
MC/DC0%0/3
defined $use_pie and not $use_pie and $hardening_builtins{"pie"}
defined $use_pie
not $use_pie
$hardening_builtins{"pie"}
Truth table25%1/4
A and not(B) and C
A= defined $use_pieB= not $use_pieC= $hardening_builtins{"pie"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | my $flag = "-specs=$Dpkg::DATADIR/no-pie-compile.specs"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $flags->append($_, $flag) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | $flags->append('LDFLAGS', "-specs=$Dpkg::DATADIR/no-pie-link.specs"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | # Stack protector. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 26 | ▶ | if ($flags->use_feature('hardening', 'stackprotectorstrong')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 26 | my $flag = '-fstack-protector-strong'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 26 | $flags->append($_, $flag) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } elsif ($flags->use_feature('hardening', 'stackprotector')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $flag = '-fstack-protector --param=ssp-buffer-size=4'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | $flags->append($_, $flag) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | # Stack clash. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 26 | ▶ | if ($flags->use_feature('hardening', 'stackclash')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 13 | my $flag = '-fstack-clash-protection'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 13 | $flags->append($_, $flag) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # Fortify Source. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 26 | ▶ | if ($flags->use_feature('hardening', 'fortify')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 26 | my $fortify_level = $flags->get_option_value('fortify-level'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 26 | $flags->append('CPPFLAGS', "-D_FORTIFY_SOURCE=$fortify_level"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | # Format Security. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 26 | ▶ | if ($flags->use_feature('hardening', 'format')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 26 | my $flag = '-Wformat -Werror=format-security'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 26 | $flags->append('CFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 26 | $flags->append('CXXFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 26 | $flags->append('OBJCFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 26 | $flags->append('OBJCXXFLAGS', $flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | # Read-only Relocations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 26 | ▶ | if ($flags->use_feature('hardening', 'relro')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 26 | $flags->append('LDFLAGS', '-Wl,-z,relro'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # Bindnow. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 26 | ▶ | if ($flags->use_feature('hardening', 'bindnow')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | $flags->append('LDFLAGS', '-Wl,-z,now'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | # Branch protection. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 26 | ▶ | if ($flags->use_feature('hardening', 'branch')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 10 | my $cpu = $flags->get_option_value('hardening-branch-cpu'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 10 | my $flag; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 10 | ▶ | if ($cpu eq 'arm64') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | $flag = '-mbranch-protection=standard'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | } elsif ($cpu eq 'amd64') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # TODO: On GNU/Linux, CET is currently only partially supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | # for the "-fcf-protection" option values: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | # - For "return", the current version of glibc in Debian does | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # not enable support for it. See #1114518. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | # - For "branch", the compiler injects the ENDBR instructions in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | # the function prologues, but the Linux kernel does not currently | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # have support to enable IBT support for user-space. And there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | # are proposals that could end up changing its ABI. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # We leave the current option value with the implicit "full", as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | # there is still interest (as of 2025-09) to implement support on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # Linux to enable IBT for user-space, and then it would only need | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # a new Linux kernel and a glibc to enable the support. If this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # does not change in a couple of years, we can revisit whether to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | # switch to "return". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 10 | $flag = '-fcf-protection'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # The following should always be true on Debian, but it might not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # be on derivatives. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 10 | ▶ | if (defined $flag) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 10 | $flags->append($_, $flag) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | # XXX: Handle *_FOR_BUILD flags here until we can properly initialize them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 26 | require Dpkg::Arch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 26 | my $host_arch = Dpkg::Arch::get_host_arch(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 26 | my $build_arch = Dpkg::Arch::get_build_arch(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 26 | ▶ | if ($host_arch eq $build_arch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 23 | foreach my $flag ($flags->list()) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 460 | ▶ | next if $flag =~ m/_FOR_BUILD$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 230 | my $value = $flags->get($flag); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 230 | $flags->append($flag . '_FOR_BUILD', $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 3 | $flags->append($_ . '_FOR_BUILD', $default_flags) foreach @compile_flags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 3 | $flags->append('DFLAGS_FOR_BUILD', $default_d_flags); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | sub _build_tainted_by { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_build_tainted_by: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my %tainted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | require File::Find; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | my %usr_local_types = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | configs => [ qw(etc) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | includes => [ qw(include) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | programs => [ qw(bin sbin) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | libraries => [ qw(lib) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | foreach my $type (keys %usr_local_types) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | my $scan_tainted = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | wanted => sub { $tainted{"usr-local-has-$type"} = 1 if -f }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | no_chdir => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | my @dirs_taintable = grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | -d | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | } map { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | "/usr/local/$_" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | } @{$usr_local_types{$type}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | File::Find::find($scan_tainted, @dirs_taintable); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | my @tainted = sort keys %tainted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | return @tainted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | =head1 CHANGES | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | =head2 Version 0.xx | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | This is a private module. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||