Bug 103398 - configure: Enable --enable-default-pie by default for Linux
Summary: configure: Enable --enable-default-pie by default for Linux
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: driver (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-23 21:46 UTC by Fangrui Song
Modified: 2023-10-18 21:14 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-11-23 21:46:49 UTC
Many Linux distros configure GCC with --enable-default-pie (at least Arch/Debian/Fedora/Gentoo/Ubuntu). I think it makes sense to default to --enable-default-pie for Linux.
Comment 1 Andrew Pinski 2021-11-23 22:27:40 UTC
No. The whole reason why there is an option is because it is optional.
Comment 2 Fangrui Song 2021-11-24 01:02:39 UTC
I want to switch the default because:

* It seems to me that every Linux distro uses --enable-default-pie GCC. I use "many", but it is likely "most" at this point (2021).
* When a user builds GCC on Linux, the generated GCC does not default PIE. This almost certainly does not match the behavior of their host GCC. 

On the libc-alpha mailing list, I have seen that contributors waste time because they don't notice that scripts/build-many-glibcs.py built GCC uses the implicit --disable-default-pie, which has a behavior different from the host GCC or cross compiler provided by system packages.
Comment 3 Sam James 2021-11-24 01:03:38 UTC
(In reply to Andrew Pinski from comment #1)
> No. The whole reason why there is an option is because it is optional.

A fair amount of future-new-defaults start off as optional and eventually become it. This isn't a particularly strong reason to reject it.

The alternative would be that there was.. never a configure option? And one day it just flipped without any chance of changing it? I think this would probably benefit from more discussion.

As meowray noted, this has been set by every major Linux distro for quite some time. It would make sense to re-evaluate GCC's defaults in that context and whether the reasons for them still make sense.
Comment 4 Mark Esler 2023-10-18 21:14:21 UTC
(In reply to Andrew Pinski from comment #1)
> No. The whole reason why there is an option is because it is optional.

Could this issue be re-considered?

Or should -fhardened and related endeavors all re-suggest the specific flags that --enable-default-pie provides?