commit: 9a089ae37edf29aa5956932209751379a1bceb21
Author: Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 1 20:07:21 2024 +0000
Commit: Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Tue Oct 1 23:04:04 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9a089ae3
toolchain.eclass: restrict *FLAGS for stage1 compiler when bootstrapping
e.g. if gnat1 from a bootstrap compiler is older than the host compiler
itself, we are going to end up passing flags that the host compiler does
understand, but gnat1 does not. This is trivially broken with
-march=native (passes loads of flags) and also more plebeian things such
as -march=x86-64-v3 which is sadly too new for gnat-10
Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>
Reviewed-by: Sam James <sam <AT> gentoo.org>
eclass/toolchain.eclass | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index d5570a746a2e..6a816a66275d 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -2077,6 +2077,13 @@ gcc_do_make() {
if ! tc-is-gcc || ver_test $(gcc-fullversion) -lt 10 ; then
STAGE1_CFLAGS="-O0"
STAGE1_CXXFLAGS="-O0"
+ # We have a very good host compiler but it may be a bit too
good, and
+ # know about flags that the version we are compiling does not
know
+ # about. In principle we could check e.g. which gnat1 we are
using as
+ # a bootstrap. It's simpler to do it unconditionally for now.
+ elif _tc_use_if_iuse ada || _tc_use_if_iuse d; then
+ STAGE1_CFLAGS="-O2"
+ STAGE1_CXXFLAGS="-O2"
fi
# We only want to use the system's CFLAGS if not building a