You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.4 KiB
40 lines
1.4 KiB
2 years ago
|
From 6d9d949fb4962e32636aee48a948081d8936d318 Mon Sep 17 00:00:00 2001
|
||
|
From: Jitka Plesnikova <jplesnik@redhat.com>
|
||
|
Date: Wed, 11 Jan 2023 09:12:18 +0100
|
||
|
Subject: [PATCH] Add definition of OPTIMIZE to .ph files
|
||
|
|
||
|
The fortify.h header includes a test to ensure that -O is used when
|
||
|
compiling with _FORTIFY_SOURCE, and the header looks for OPTIMIZE, which
|
||
|
is set by the compiler whenever -O is used. Perl translates this test
|
||
|
to the .ph file, but nothing ever sets OPTIMIZE. This causes a warning
|
||
|
for anything that uses features.ph.
|
||
|
|
||
|
_FORTIFY_SOURCE is defined in /usr/lib64/perl5/_h2ph_pre.ph which is
|
||
|
generated by h2ph. It uses value of @Config{'ccsymbols', 'cppsymbols',
|
||
|
'cppccsymbols'} which does not contain definition for OPTIMIZE.
|
||
|
|
||
|
The patch updated h2ph to add OPTIMIZE if -O is used.
|
||
|
---
|
||
|
utils/h2ph.PL | 5 +++++
|
||
|
1 file changed, 5 insertions(+)
|
||
|
|
||
|
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
|
||
|
index afa53c2..3950d11 100644
|
||
|
--- a/utils/h2ph.PL
|
||
|
+++ b/utils/h2ph.PL
|
||
|
@@ -865,6 +865,11 @@ sub _extract_cc_defines
|
||
|
my $allsymbols = join " ",
|
||
|
@Config{'ccsymbols', 'cppsymbols', 'cppccsymbols'};
|
||
|
|
||
|
+ # If optimizing -O2 is used, add the definition
|
||
|
+ if ($Config{'ccflags'} =~ /(?:\s+|^)-O([\d]+)(?:\s+|$)/) {
|
||
|
+ $allsymbols .= " __OPTIMIZE__=$1";
|
||
|
+ }
|
||
|
+
|
||
|
# Split compiler pre-definitions into 'key=value' pairs:
|
||
|
while ($allsymbols =~ /([^\s]+)=((\\\s|[^\s])+)/g) {
|
||
|
$define{$1} = $2;
|
||
|
--
|
||
|
2.39.0
|
||
|
|