Bug 1880641 - Provide a system-defaults.pc pkgconfig file
Summary: Provide a system-defaults.pc pkgconfig file
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: redhat-rpm-config
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Florian Festi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-09-18 20:52 UTC by Mark Wielaard
Modified: 2023-07-07 03:02 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Mark Wielaard 2020-09-18 20:52:35 UTC
As an upstream developer I often struggle with replicating issues seen with a fedora package build because of missing warning, hardening flags or annobin injection.

It would be really convenient if redhat-rpm-config would provide a pkgconfig file with the default build flags to use on the system as if building an rpm package.

If the flags would also be available in an system-defaults.pc then it becomes easier for upstream projects or a CI system to do builds as Fedora would do them.

Then you could simply configure CFLAGS=$(pkgconf --cflags system-default)

I am suggesting the name system-defaults.pc so it is actually distro independent (hopefully other distros would provide a similarly named pkgconfig file).

Comment 1 Panu Matilainen 2020-09-21 05:35:03 UTC
You can query these from rpm, some examples:

[pmatilai🎩︎lumikko ~]$ rpm --eval "%{build_cflags}"
-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
[pmatilai🎩︎lumikko ~]$ rpm --target i686 --eval "%{build_cflags}"
-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
[pmatilai🎩︎lumikko ~]$ rpm --target i686 --undefine "_hardened_build" --eval "%{build_cflags}"
-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches  -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
[pmatilai🎩︎lumikko ~]$ rpm --target ppc64le --eval "%{build_ldflags}"
-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld

In principle it's a nice idea, developers are likely to be more acquainted with pkgconf than rpm (witness this bug:)
There'd probably need to be multiple such files to account for major configurables (such as hardening). A bigger obstacle might be per-architecture flags, which need to be handled somehow - we could put them into separate files too, but then the number with combinations starts getting unwieldy.

Comment 2 Frank Ch. Eigler 2020-09-21 13:57:10 UTC
(In reply to Panu Matilainen from comment #1)
> You can query these from rpm, some examples:
> 
> [pmatilai🎩︎lumikko ~]$ rpm --eval "%{build_cflags}" [...]

Yeah.

> There'd probably need to be multiple such files to account for major
> configurables (such as hardening). 

I think the attraction of a single .pc would be to match the "default"
case used in the distro.  If an ISV/package wants to micromanage e.g.
hardening, they could do so with or without the .pc originated cflags.

> A bigger obstacle might be per-architecture flags, which need to be
> handled somehow - we could put them into separate files too, but then
> the number with combinations starts getting unwieldy.

Could the .pc files be created during %post, to mechanize it fully?

We could start with just a native one, and if there is interest, maybe
generate a suite of arch-specific ones?

Comment 3 Ben Cotton 2021-02-09 15:18:52 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 34 development cycle.
Changing version to 34.

Comment 4 Ben Cotton 2022-05-12 15:13:12 UTC
This message is a reminder that Fedora Linux 34 is nearing its end of life.
Fedora will stop maintaining and issuing updates for Fedora Linux 34 on 2022-06-07.
It is Fedora's policy to close all bug reports from releases that are no longer
maintained. At that time this bug will be closed as EOL if it remains open with a
'version' of '34'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, change the 'version' 
to a later Fedora Linux version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora Linux 34 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora Linux, you are encouraged to change the 'version' to a later version
prior to this bug being closed.

Comment 5 Mark Wielaard 2022-05-15 19:00:49 UTC
This would still be a useful feature.


Note You need to log in before you can comment on or make changes to this bug.