Package: libdpkg-perl Version: 1.19.1 Severity: normal Tags: patch Heya,
In Ubuntu we recently got a version of dpkg including d5374bc618310917557daa9c9ac2f4930515a0b2 for the first time, and I noticed that our ppc64el -O3 build flag wasn't being used - -O2 was being passed instead. See the attached commit for my proposed fix - please let me know what you think. There are other valid approaches such as having Debian.pm check the value doesn't contain `-g -O\d' before appending it. Cheers, -- Iain Lane [ i...@orangesquash.org.uk ] Debian Developer [ la...@debian.org ] Ubuntu Developer [ la...@ubuntu.com ]
>From c23ab654f69b25019edd4e3b2b533dfc7659f618 Mon Sep 17 00:00:00 2001 From: Iain Lane <la...@debian.org> Date: Fri, 7 Dec 2018 14:14:27 +0000 Subject: [PATCH] Dpkg::Vendor::Ubuntu: Chain up to update-buildflags first, not last Since d5374bc618310917557daa9c9ac2f4930515a0b2, Dpkg::Vendor::Debian (Dpkg::Vendor::Ubuntu's parent class) appends `-g -O2' or `-g -O2' to the build flags. For ppc64el, Ubuntu sets the flag to `-g -O3'. Ubuntu calls up to Debian's implementation at the end, meaning that Debian's default build flags are appended after Ubuntu's, which means that they take precedence: $ DEB_HOST_ARCH=ppc64el dpkg-buildflags --get CFLAGS -g -O3 -g -O2 -fdebug-prefix-map=/home/laney=. -fstack-protector-strong -Wformat -Werror=format-security Fix this by having Ubuntu chain up at the start, and then append when it sets flags, meaning that its changes will win out over Debian's: $ DEB_HOST_ARCH=ppc64el dpkg-buildflags --get CFLAGS -g -O2 -fdebug-prefix-map=/home/laney=. -fstack-protector-strong -Wformat -Werror=format-security -g -O3 --- scripts/Dpkg/Vendor/Ubuntu.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index eb2dffefe..8662c2351 100644 --- a/scripts/Dpkg/Vendor/Ubuntu.pm +++ b/scripts/Dpkg/Vendor/Ubuntu.pm @@ -98,6 +98,9 @@ sub run_hook { } elsif ($hook eq 'update-buildflags') { my $flags = shift @params; + # Run the Debian hook to add hardening flags + $self->SUPER::run_hook($hook, $flags); + require Dpkg::BuildOptions; my $build_opts = Dpkg::BuildOptions->new(); @@ -109,15 +112,12 @@ sub run_hook { if (Dpkg::Arch::debarch_eq($arch, 'ppc64el')) { for my $flag (qw(CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS GCJFLAGS FFLAGS FCFLAGS)) { - $flags->set($flag, '-g -O3', 'vendor'); + $flags->append($flag, '-g -O3', 'vendor'); } } } # Per https://wiki.ubuntu.com/DistCompilerFlags - $flags->set('LDFLAGS', '-Wl,-Bsymbolic-functions', 'vendor'); - - # Run the Debian hook to add hardening flags - $self->SUPER::run_hook($hook, $flags); + $flags->append('LDFLAGS', '-Wl,-Bsymbolic-functions', 'vendor'); } else { return $self->SUPER::run_hook($hook, @params); } -- 2.17.1