During stage2 bootstrap of bootstrap-prefix.sh (LATEST_TREE_YES is NOT set), compilation of dev-libs/gmp fails with the following error: > /srv/moritz/gentoo/tmp/var/tmp/portage/dev-libs/gmp-6.3.0/work/gmp-6.3.0/gen-sieve.c: In function ‘setmask’: > /srv/moritz/gentoo/tmp/var/tmp/portage/dev-libs/gmp-6.3.0/work/gmp-6.3.0/gen-sieve.c:99:3: error: ‘for’ loop initial declarations are only allowed in C99 mode > for (unsigned i = 0; i < 2 * a * b; ++i) > ^ > /srv/moritz/gentoo/tmp/var/tmp/portage/dev-libs/gmp-6.3.0/work/gmp-6.3.0/gen-sieve.c:99:3: note: use option -std=c99 or -std=gnu99 to compile your code The host system is "CentOS 7.9.2009", the host compiler is "gcc version 4.8.5 20150623 (Red Hat 4.8.5-44)" I assume this problem stems from the fact that newer versions of GCC use a more modern default value for -std by default. Reproducible: Always Steps to Reproduce: 1. Run bootstrap-prefix.sh, select testing during questionaire 2. Wait until stage2 Actual Results: dev-libs/gmp fails to compile. Expected Results: The bootstrap process should continue without error.
Created attachment 879458 [details] stage2 bootstrap log
I hit this too, also with GCC 4.8.5. Of note: ``` configure.wrapped: summary of build options: Version: GNU MP 6.3.0 Host type: x86_64-pc-linux-gnu ABI: 64 Install prefix: /flash/tmp/gentoo/tmp/usr Compiler: gcc -std=gnu99 Static libraries: no Shared libraries: yes . . . gcc `test -f 'gen-psqr.c' || echo '/flash/tmp/gentoo/tmp/var/tmp/portage/dev-libs/gmp-6.3.0-r1/work/gmp-6.3.0/'`gen-psqr.c -o gen-psqr -lm /flash/tmp/gentoo/tmp/var/tmp/portage/dev-libs/gmp-6.3.0-r1/work/gmp-6.3.0/gen-sieve.c: In function ‘setmask’: /flash/tmp/gentoo/tmp/var/tmp/portage/dev-libs/gmp-6.3.0-r1/work/gmp-6.3.0/gen-sieve.c:99:3: error: ‘for’ loop initial declarations are only allowed in C99 mode for (unsigned i = 0; i < 2 * a * b; ++i) ^ /flash/tmp/gentoo/tmp/var/tmp/portage/dev-libs/gmp-6.3.0-r1/work/gmp-6.3.0/gen-sieve.c:99:3: note: use option -std=c99 or -std=gnu99 to compile your code ./gen-jacobitab >mpn/jacobitab.h || (rm -f mpn/jacobitab.h; exit 1) ```
This appears to be because we're setting `CC_FOR_BUILD` to 'gcc' and therefore dropping the -std=gnu99 that is passed to configure. https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-libs/gmp/gmp-6.3.0-r1.ebuild#n118
seems we could "avoid" the problem for most scenarios if any of: - we set the CC_FOR_BUILD only on cross setups - we unconditionally add -std=c99 to CC_FOR_BUILD - we up the dependencies for a compiler that defaults to c99 I think the second option should actually be ok, and meet all scenarios, and only break on ancient compilers that won't be able to compile most of the code anyway.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=08dc9bec045a5683f5628787aecdcd5657b8be1e commit 08dc9bec045a5683f5628787aecdcd5657b8be1e Author: Sam James <sam@gentoo.org> AuthorDate: 2024-12-06 13:05:52 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-12-06 13:05:52 +0000 dev-libs/gmp: pass -std=gnu17 conditionally Old compilers during Prefix bootstrap may not support it but they also won't be defaulting to C23 so that's fine. (This doesn't fix bug #919935 but it means we don't make it worse. I'll fix that as well in a minute.) Bug: https://bugs.gentoo.org/919935 Signed-off-by: Sam James <sam@gentoo.org> dev-libs/gmp/gmp-6.3.0-r1.ebuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aa0955f0726ebd11a1309eca383c114bb25193bb commit aa0955f0726ebd11a1309eca383c114bb25193bb Author: Sam James <sam@gentoo.org> AuthorDate: 2024-12-06 13:08:35 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-12-06 13:08:35 +0000 dev-libs/gmp: add -std=gnu99 to CC_FOR_BUILD By setting CC_FOR_BUILD, we're clobbering -std=gnu99, so let's restore it. This seems like the best and easiest of the optins in grobian's summary at https://bugs.gentoo.org/919935#c4. Closes: https://bugs.gentoo.org/919935 Signed-off-by: Sam James <sam@gentoo.org> dev-libs/gmp/gmp-6.3.0-r1.ebuild | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)