Skip to content
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

Merged
merged 2 commits into from May 14, 2019

Conversation

pmatilai
Copy link
Member

@pmatilai pmatilai commented May 6, 2019

This is bascially a more elaborate version of #660 :

  • Add language specific %build_fooflags macros to allow separate distro-wide defaults for c, c++ and fortran
  • Add %build_ldflags for specifying distro-wide ldflags (how on earth we didn't have this?)
  • Split FOOFLAGS= setting out of %configure to %set_build_flags macro to make them available outside autotools

%{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 ; \
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member

@Conan-Kudo Conan-Kudo left a 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}
Copy link
Member

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...

Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

@pmatilai pmatilai added the RFE label May 6, 2019
@marxin
Copy link
Contributor

marxin commented May 13, 2019

Any estimation when this will be merged?

@pmatilai pmatilai merged commit 3940c6f into rpm-software-management:master May 14, 2019
@pmatilai pmatilai deleted the buildflags-pr branch May 14, 2019 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants