From 75afd33e320ebb31f0e974b227d714b049a67808 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 8 Dec 2018 00:28:57 +0100 Subject: Dpkg::Vendor::Ubuntu: Fix buildflags override after default setting move The default buildflags got moved from the Dpkg::BuildFlags module to the Dpkg::Vendor::Debian, but this module was not adapted to match. Instead of running the Debian hooks after the Ubuntu buildflags are set up, run them first, and then modify/prepend the bits we need to change. This fixes compiler optimization on ppc64el, and makes setting it more future proof. Fixes: commit d5374bc618310917557daa9c9ac2f4930515a0b2 Closes: #915881 Co-Author: Iain Lane Co-Author: Adam Conrad --- scripts/Dpkg/Vendor/Ubuntu.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index eb2dffefe..e6335c204 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,14 @@ 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'); + my $value = $flags->get($flag); + $value =~ s/-O[0-9]/-O3/; + $flags->set($flag, $value); } } } # 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->prepend('LDFLAGS', '-Wl,-Bsymbolic-functions'); } else { return $self->SUPER::run_hook($hook, @params); } -- cgit v1.2.3