Re: F37 proposal: RPM Macros for Build Flags (System-Wide Change proposal)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/3/22 02:24, Vít Ondruch wrote:
Hi Tom,

Since you are looking into this and I like this proposal, have you considered to look alto into `%extension_*flags`:

https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/rawhide/f/macros#_120-123


I have not considered this.  Do you think there is some way this proposal
could be extended to help solve this problem as well?

-Tom

This is longstanding issue:

https://bugzilla.redhat.com/1284684

Where we have several proposals for fix, but non of them is really appealing to me:

https://src.fedoraproject.org/rpms/ruby/pull-request/110

https://src.fedoraproject.org/rpms/ruby/pull-request/117


BTW isn't the `_flag_` prefix too generic? And also, the initial underscore implies that this is internal macro which should ideally not be used. So should it be rather removed or not?


Vít


Dne 02. 06. 22 v 21:27 Ben Cotton napsal(a):
https://fedoraproject.org/wiki/Changes/RPMMacrosForBuildFlags

This document represents a proposed Change. As part of the Changes
process, proposals are publicly announced in order to receive
community feedback. This proposal will only be implemented if approved
by the Fedora Engineering Steering Committee.

== Summary ==
Create a corresponding macro for each compiler flag in the
redhat-rpm-config macro file and create "extra flag" macros to make it
easier for packages to add and remove compiler flags.

== Owner ==
* Name: [[User:tstellar| Tom Stellard]]
* Email: <tstellar@xxxxxxxxxx>


== Detailed Description ==
The macros file in the redhat-rpm-config package contains a list of
default compiler flags for packages to use when compiling C, C++, and
Fortran packages.  There is currently no standard way to remove or add
to the set of default flags.  Most packages use a combination of echo
and sed to remove unwanted flags or add new ones.  Some examples:
     compiler-rt:
[https://src.fedoraproject.org/rpms/compiler-rt/blob/rawhide/f/compiler-rt.spec#_6
global optflags %(echo %{optflags} -D_DEFAULT_SOURCE)]
     julia:
[https://src.fedoraproject.org/rpms/julia/blob/rawhide/f/julia.spec#_267
%global optflags %(echo %{optflags} | sed 's/-Wp,-D_GLIBCXX_ASSERTIONS
//')]

This change will add new macros which will make it easier for packages
to add and remove their own compiler flags.  This strategy is already
used to some extent with feature macros like %{_lto_cflags},
%{_hardening_cflags}, etc, but these new macros will give packagers
even more fine-grained control over the options.

The proposed macros for adding new flags are:

     %_pkg_extra_cflags
     %_pkg_extra_cxxflags
     %_pkg_extra_fflags
     %_pkg_extra_ldflags

These will be added to %{build_cflags}, %{build_cxxflags},
%{build_fflags}, and %{build_ldflags} respectively to allow packges to
add their own flags to the default list: e.g.

     %build_cflags %{optflags} %{_pkg_extra_cflags}

The proposed new macros to represent existing flags are:

     %_flag_fstack_protector_strong     -fstack-protector-strong
     %_flag_z_now                       -Wl,-z,now
     %_flag_z_defs                      -Wl,-z,defs
     %_flag_flto_auto                   -flto=auto
     %_flag_ffat_lto_objects            -ffat-lto-objects
     %_flag_o                           -O2
     %_flag_f_exceptions                -fexceptions
     %_flag_g                           -g
     %_flag_grecord_gcc_switches        -grecord-gcc-switches
     %_flag_pipe                        -pipe
     %_flag_wall                        -Wall
     %_flag_werror_format_security      -Werror=format-security
     %_flag_fortify_source              -Wp,-D_FORTIFY_SOURCE=2
     %_flag_glibcxx_assertions          -Wp,-D_GLIBCXX_ASSERTIONS
     %_flag_asynchronous_unwind_tables  -fasynchronous-unwind-tables
     %_flag_fstack_clash_protection     -fstack-clash-protection
     %_flag_fcf_protection              -fcf-protection
     %_flag_mbranch_protection_standard -mbranch-protection=standard

With these new macros, the examples from above could be re-written as:

     compiler-rt: %global _pkg_extra_cflags -D_DEFAULT_SOURCE
     julia:       %global _flag_glibcxx_assertions %{nil}

For more details see the
[https://src.fedoraproject.org/fork/tstellar/rpms/redhat-rpm-config/c/0ee9a8c989b55c631f870ad311cdca87329034be?branch=macro-flags
Prototype Implementation].

In addition to adding these new macros, the packaging guidelines will
be updated to require that all new flags added to redhat-rpm-config
have their own RPM macro.


== Benefit to Fedora ==
* It will provide a standard way to disable existing compiler flags or
enable new ones that is more simple and robust than the existing echo
+ sed solution.
* It will make it easier to determine which packages disable or add
compiler flags by doing a simple grep of the spec files.
* It will make it easier for toolchain developers to experiment with
adding new flags to the distribution as this can be done with a simple
macro definition instead of patching redhat-rpm-config.


== Scope ==
* Proposal owners:
** Proposal owners will update the redhat-rpm-config package and add
the new macros.
** Proposal owners will test the changes to ensure that the correct
flags are still being used.

* Other developers:
** Other developers may, but are not required to, update their
packages to use the new macros.

* Release engineering: [https://pagure.io/releng/issues/10819 #10819]

* Policies and guidelines:
** The Fedora packaging policy will be updated to require that new
flags added to redhat-rpm-config come with their own RPM macro.

* Trademark approval: N/A (not needed for this Change)
* Alignment with Objectives:


== Upgrade/compatibility impact ==
None.


== How To Test ==
* This can be tested by inspecting the value of the %{build_cflags},
%{build_cxxflags}, %{build_fflags}, and %{build_ldflags} and ensuring
they are the same before and after the change.
* This can be tested by modifying some of the new macros in a spec
file and ensuring that the changes appear in the appropriate macro
mentioned above.


== User Experience ==
This is a change for developers and will have no impact to the user experience.


== Dependencies ==
None.


== Contingency Plan ==
* Contingency mechanism: (What to do?  Who will do it?) Change owner
will revert the update to redhat-rpm-config.
* Contingency deadline: Mass Rebuild
* Blocks release? N/A (not a System Wide Change), No

== Documentation ==
None.

== Release Notes ==
None.



_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux