DevHeads.net

Fedora c++ default build flags

Hi,
during a discussion with upstream (MongoDB) they asked me about default
Fedora C/C++ build flags. And I don't remember all Fedora System Wide
changes where it was introduced,... so is there some place where it's
described?

Main upstream question was:
"""
I don't know what is in those various hardening scripts, so hard to say
what they do. I am somewhat interested in whether you think we should
be applying these flags for our hardened builds. Do you have some
guidance on the runtime costs?

-fstack-clash-protection
-D_GLIBCXX_ASSERTIONS
-fcf-protection

I'm also curious about why you are applying -fexceptions and
-fasynchronous-unwind-tables. The first seems unnecessary for a C++
project, and the second seems potentially interesting, if you have some
context on why it is applied.
"""

So some link or explanation in this thread (which I can link to
upstream) would be really helpful.

Thanks,
Marek

(link to upstream issue - <a href="https://jira.mongodb.org/browse/SERVER-35935" title="https://jira.mongodb.org/browse/SERVER-35935">https://jira.mongodb.org/browse/SERVER-35935</a>)

Comments

Re: Fedora c++ default build flags

By Dan =?ISO-8859-... at 07/11/2018 - 08:12

On Wed, 11 Jul 2018 14:00:40 +0200

<a href="https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/buildflags.md" title="https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/buildflags.md">https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/build...</a>

Dan

Re: Fedora c++ default build flags

By Marek =?ISO-885... at 07/12/2018 - 14:49

Dan Horák píše v St 11. 07. 2018 v 14:12 +0200:
Thanks. Also does someone have any information how our flags affects
performance?
(which is also important for the upstream project)

Thanks,
Marek

Re: Fedora c++ default build flags

By Jonathan Wakely at 07/16/2018 - 11:25

On 12/07/18 20:49 +0200, <a href="mailto: ... at redhat dot com"> ... at redhat dot com</a> wrote:
Currently -D_GLIBCXX_ASSERTIONS has fairly negative effects on
performance of some code using the C++ standard library. GCC is not
able to optimise away as many of the checks as we initially thought.

Re: Fedora c++ default build flags

By Florian Weimer at 07/16/2018 - 12:24

On 07/16/2018 05:25 PM, Jonathan Wakely wrote:
Do you know if anything else besides <https://gcc.gnu.org/PR85929>?
That one at least a simple source-level fix (probably fixing a real bug
in some cases): Use size_type/size_t for the index variable.

Thanks,
Florian

Re: Fedora c++ default build flags

By Jonathan Wakely at 07/16/2018 - 12:37

On 16/07/18 18:24 +0200, Florian Weimer wrote:
That's the only specific example I'm aware of, but there might be
plenty of correct code using unsigned for the loop variable, which
gets pessimised by the assertions. It's unusual to have more than
UINT_MAX elements in a vector, so we can't just say such code needs
fixing.

Re: Fedora c++ default build flags

By Florian Weimer at 07/23/2018 - 07:11

On 07/16/2018 06:37 PM, Jonathan Wakely wrote:
It's not just about -D_GLIBCXX_ASSERTIONS. The type mismatch inhibits
loop optimizations in general (looks like strength reduction in particular).

Thanks,
Florian