New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adopt compiler flags related enhancements from Fedora #692
Adopt compiler flags related enhancements from Fedora #692
Conversation
%{optflags} has been the catchall for all compiler options but this is quite limiting as there's no way to add for example C++ specific options distro-wide. This adds separate %build_cflags, %build_cxxflags, %build_fflags for the gcc-supported languages, and additionally %build_ldflags for distro-wide LDFLAGS setting. Based on Florian Weimer's work in Fedoras redhat-rpm-config macros.
Not all the world is autotools based, mercifully. Let the other build systems benefit from the central rpm macros as well by splitting the XXFLAGS setting out of %configure. Based on Florian Weimer's work in Fedoras redhat-rpm-config macros.
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have | ||
# not been set already. | ||
%set_build_flags \ | ||
CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are moving this to RPM, I think it is better to go directly with export CFLAGS=…
. It is very very old version of bash which did not support this. I think even RHEL6 has good bash enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, but rpm only ever uses /bin/sh. We can't assume bash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pubs.opengroup.org/onlinepubs/009695399/utilities/export.html
POSIX says:
IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/6 is applied, adding the following text to the end of the first paragraph of the DESCRIPTION: ``If the name of a variable is followed by = word, then the value of that variable shall be set to word.''. The reason for this change is that the SYNOPSIS for export includes:
export name[=word]...
but the meaning of the optional ``= word'' is never explained in the text.
So I think only non-POSIX conformant shells use foo=bar; export foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whatever. There's just no real benefit to making it potentially more incompatible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one issue...
%build_fflags %{optflags} %{?_fmoddir:-I%{_fmoddir}} | ||
|
||
# Link editor flags. This is usually called LDFLAGS in makefiles. | ||
#%build_ldflags -Wl,-z,relro %{?_lto_cflags} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we commenting this out? The LTO settings won't take effect as is...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I don't want to set defaults. That's up to distros to do, it's just an example of what might be there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Any estimation when this will be merged? |
This is bascially a more elaborate version of #660 :