AOSC-Archive / autobuild3

AOSC OS package maintenance toolkit (version 3)
https://aosc.io
GNU General Public License v2.0
24 stars 17 forks source link

Future Build Flag Changes on AOSC OS #104

Open jyhi opened 6 years ago

jyhi commented 6 years ago

This is a tracking issue for a list of operations related to compiler flags in the (near or distant) future.

For flag addition, there are some new GCC flags that only apply to newer version of GCC, and hence need to wait for the upgrade of compiler.

If you have more idea, update the list.

jyhi commented 5 years ago

Interesting flags we may want to consider:

Some flags are for better debugging:

jyhi commented 5 years ago

Also we now enable -fpermissive by default. I personally think this is not a very good idea... and I propose a removal of this flag (given that Red Hat has several style-related compiler flags enabled).

jyhi commented 5 years ago

Previously we have many packages failed to be built because of PIE. I looked a little bit into our GCC specs, and found out that our hardened-ld specs are unaware of the status of input files: if the given object files are not compiled with -fPIC then the linker just deny to link with -pie. Our current resolution is disabling PIC across the package, which disables ASLR. NG.

And it turns out that GCC specs can be merged into one single file. My trial on this is successful.

jyhi commented 5 years ago

In c901619 we use -flto=jobserver instead of -flto=$ABTHREADS. Packagers may have seen this from time to time:

warning: jobserver unavailable: using -j1. Add `+' to parent make rule.

This means the (originally) parallel LTO process is downgraded to single-threaded, making the LTO process very slow. In addition, -flto=jobserver requires:

If we do not alter packages, we may want to revert c901619 and force LTO to use as many cores as possible.

jyhi commented 5 years ago

For Rust packages, RUSTFLAGS environment variable can be set for cargo (The Rust package manager and build system) to apply to rustc, for not only the project itself but also all dependencies of it. For example:

export RUSTFLAGS="-C target-feature=+sse3 -C no-integrated-as"

LTO can be enabled too (theoretically), but there are limitations:

Rust binaries are by default PIEs on many platforms, so we can leave it as-is.

jyhi commented 5 years ago

Experimentally we want to enable the following two options in GCC configuration:

This also avoids GCC specs problems (hopefully).

https://gcc.gnu.org/install/configure.html

jyhi commented 5 years ago

As @LionNatsu proposed, since some packages by default turn -march=native on, which breaks compatibility on machines less capable than the build machine, GCC specs may be used to strip such flags to avoid such problem. To achieve this without confusing users using GCC, a separate toolchain with such specs integrated and --enable-default-pie --enalbe-default-ssp may be packaged for distribution compilation use (because we want the -march=native stripping be the default).

Nonetheless, we haven't figured out how to do this yet.