Merge ~zhsj/ubuntu/+source/dpkg:duplicated-lto-flags into ubuntu/+source/dpkg:ubuntu/devel

Proposed by Shengjing Zhu
Status: Merged
Merge reported by: Shengjing Zhu
Merged at revision: 4a62312909717df6ca47324410907f4b1aa529fb
Proposed branch: ~zhsj/ubuntu/+source/dpkg:duplicated-lto-flags
Merge into: ubuntu/+source/dpkg:ubuntu/devel
Diff against target: 187 lines (+53/-69)
3 files modified
debian/changelog (+7/-0)
scripts/Dpkg/Vendor/Debian.pm (+3/-69)
scripts/Dpkg/Vendor/Ubuntu.pm (+43/-0)
Reviewer Review Type Date Requested Status
Canonical Foundations Team Pending
Review via email: mp+435346@code.launchpad.net

Description of the change

* Remove duplicated lto flags (LP: #2002201)
* Move lto-disabled hook to Dpkg::Vendor::Ubuntu

To post a comment you must log in.
Revision history for this message
Shengjing Zhu (zhsj) wrote :
Revision history for this message
Shengjing Zhu (zhsj) wrote :

Uploaded by costamagnagianfranco

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 1cd4a3f..805c0e4 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,10 @@
6+dpkg (1.21.17ubuntu2) lunar; urgency=medium
7+
8+ * Remove duplicated lto flags (LP: #2002201)
9+ * Move lto-disabled hook to Dpkg::Vendor::Ubuntu
10+
11+ -- Shengjing Zhu <shengjing.zhu@canonical.com> Mon, 09 Jan 2023 08:02:37 +0000
12+
13 dpkg (1.21.17ubuntu1) lunar; urgency=medium
14
15 * Merge from Debian unstable. Remaining changes:
16diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm
17index 4c064a1..39ffbf0 100644
18--- a/scripts/Dpkg/Vendor/Debian.pm
19+++ b/scripts/Dpkg/Vendor/Debian.pm
20@@ -26,7 +26,6 @@ use warnings;
21 our $VERSION = '0.01';
22
23 use Dpkg;
24-use Dpkg::Arch;
25 use Dpkg::Gettext;
26 use Dpkg::ErrorHandling;
27 use Dpkg::Control::Types;
28@@ -95,45 +94,6 @@ sub run_hook {
29 }
30 }
31
32-sub _lto_disabled {
33- my $fn = "/usr/share/lto-disabled-list/lto-disabled-list";
34- open(LIST, "<", $fn) or return;
35-
36- # get source name
37- -r "debian/control" or return;
38- require Dpkg::Control::Info;
39- my $ctrl = Dpkg::Control::Info->new();
40- my $src_fields = $ctrl->get_source();
41- return unless defined $src_fields;
42-
43- my $src = "";
44- foreach (keys %{$src_fields}) {
45- my $v = $src_fields->{$_};
46- if (m/^Source$/i) {
47- $src = $v;
48- last;
49- }
50- }
51- return unless $src ne "";
52-
53- my $arch = Dpkg::Arch::get_host_arch();
54-
55- # read disabled-list
56- while (<LIST>) {
57- if (m/^$src\s/) {
58- if (m/^$src\s.*(any|$arch)\s/) {
59- close(LIST);
60- return 1;
61- } else {
62- close(LIST);
63- return;
64- }
65- }
66- }
67- close(LIST);
68- return;
69-}
70-
71 sub set_build_features {
72 my ($self, $flags) = @_;
73
74@@ -173,21 +133,6 @@ sub set_build_features {
75 },
76 );
77
78- # no hook to set in Ubuntu.pm
79- require Dpkg::Arch;
80- my $arch = Dpkg::Arch::get_host_arch();
81-
82- if (Dpkg::Arch::debarch_eq($arch, 'amd64')
83- or Dpkg::Arch::debarch_eq($arch, 'arm64')
84- or Dpkg::Arch::debarch_eq($arch, 'ppc64el')
85- or Dpkg::Arch::debarch_eq($arch, 's390x'))
86- {
87- $use_feature{optimize}{lto} = 1;
88- if (_lto_disabled()) {
89- $use_feature{optimize}{lto} = 0;
90- }
91- }
92-
93 my %builtin_feature = (
94 hardening => {
95 pie => 1,
96@@ -207,6 +152,9 @@ sub set_build_features {
97 $opts_maint->parse_features($area, $use_feature{$area});
98 }
99
100+ require Dpkg::Arch;
101+
102+ my $arch = Dpkg::Arch::get_host_arch();
103 my ($abi, $libc, $os, $cpu) = Dpkg::Arch::debarch_to_debtuple($arch);
104
105 unless (defined $abi and defined $libc and defined $os and defined $cpu) {
106@@ -253,20 +201,6 @@ sub set_build_features {
107 $flags->set_option_value('optimize-level', 2);
108 }
109
110- ## Area: optimize
111-
112- if ($use_feature{optimize}{lto}) {
113- my $ltoflag = '-flto=auto -ffat-lto-objects';
114- $flags->append('CFLAGS', $ltoflag);
115- $flags->append('CXXFLAGS', $ltoflag);
116- $flags->append('OBJCFLAGS', $ltoflag);
117- $flags->append('OBJCXXFLAGS', $ltoflag);
118- $flags->append('FFLAGS', $ltoflag);
119- $flags->append('FCFLAGS', $ltoflag);
120-
121- $flags->append('LDFLAGS', '-flto=auto');
122- }
123-
124 ## Area: sanitize
125
126 # Handle logical feature interactions.
127diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm
128index 6a8be91..e8cacc9 100644
129--- a/scripts/Dpkg/Vendor/Ubuntu.pm
130+++ b/scripts/Dpkg/Vendor/Ubuntu.pm
131@@ -123,6 +123,46 @@ sub run_hook {
132 }
133 }
134
135+sub _lto_disabled {
136+ my $fn = "/usr/share/lto-disabled-list/lto-disabled-list";
137+ open(LIST, "<", $fn) or return;
138+
139+ # get source name
140+ -r "debian/control" or return;
141+ require Dpkg::Control::Info;
142+ my $ctrl = Dpkg::Control::Info->new();
143+ my $src_fields = $ctrl->get_source();
144+ return unless defined $src_fields;
145+
146+ my $src = "";
147+ foreach (keys %{$src_fields}) {
148+ my $v = $src_fields->{$_};
149+ if (m/^Source$/i) {
150+ $src = $v;
151+ last;
152+ }
153+ }
154+ return unless $src ne "";
155+
156+ require Dpkg::Arch;
157+ my $arch = Dpkg::Arch::get_host_arch();
158+
159+ # read disabled-list
160+ while (<LIST>) {
161+ if (m/^$src\s/) {
162+ if (m/^$src\s.*(any|$arch)\s/) {
163+ close(LIST);
164+ return 1;
165+ } else {
166+ close(LIST);
167+ return;
168+ }
169+ }
170+ }
171+ close(LIST);
172+ return;
173+}
174+
175 # Override Debian default features.
176 sub set_build_features {
177 my ($self, $flags) = @_;
178@@ -134,6 +174,9 @@ sub set_build_features {
179
180 if (any { $_ eq $arch } qw(amd64 arm64 ppc64el s390x)) {
181 $flags->set_feature('optimize', 'lto', 1);
182+ if (_lto_disabled()) {
183+ $flags->set_feature('optimize', 'lto', 0);
184+ }
185 }
186
187 if ($arch eq 'ppc64el' && $flags->get_option_value('optimize-level') != 0) {

Subscribers

People subscribed via source and target branches