[PATCH] autoconf: add missing main() for __builtin_alloca check
Marc Glisse
marc.glisse at inria.fr
Sun Sep 14 14:49:13 CEST 2025
Hello,
thank you for the patch. However, it would be more useful if it came with
a description of what the problem is and why this is the right way to fix
it. Let me try and describe what I understand of the test.
* First, it checks if the compiler provides __builtin_alloca, with a
trivial test. This test currently always fails due to the missing main.
* If the first trivial test is successful, it runs a test on a more
advanced piece of code. AFAIK, your patch never runs this second test,
because the API of GMP_PROG_CC_WORKS_PART differs from
GMP_PROG_CC_WORKS_PART_TEST by more than adding a main function.
* If the first trivial test fails, nothing happens, it does not disqualify
the compiler, which explains why we never paid attention in the past.
The idea is probably that if __builtin_alloca is provided, we want it to
work properly, but it is ok if it is not provided since we have fallbacks.
That makes sense, but does not quite match what we actually do afterwards.
Whether we use __builtin_alloca depends on __GNUC__ or whether stdlib.h or
other was included before gmp-impl.h and defines a macro alloca and etc,
ideally we would test whether __builtin_alloca is buggy with the same
conditions. And there is a separate test GMP_FUNC_ALLOCA (without counting
the relevant GMP_HEADER_ALLOCA, GMP_OPTION_ALLOCA) that checks whether
gmp-impl.h manages to provide alloca.
My conclusions
1) the test is not super relevant nowadays (written for HP's itanium
compiler) and never worked properly (?), so we could remove it.
2) we can keep it as a sanity check (we have a few of those), but then I
think the proper fix is adding int main(void){return 0;} to the test
explicitly.
Does anyone have a different understanding?
--
Marc Glisse
On Wed, 10 Sep 2025, mochaaP wrote:
> From: Zephyr Lykos <self at mochaa.ws>
>
> # HG changeset patch
> # User Zephyr Lykos <self at mochaa.ws>
> # Date 1750155278 -28800
> # Tue Jun 17 18:14:38 2025 +0800
> # Node ID 1e575f491a8046e67c5759e8369284860d58b969
> # Parent d66d66d82dbbe4f561920d28c1e1cbe6818452c7
> autoconf: add missing main() for __builtin_alloca check.
>
> diff --git a/acinclude.m4 b/acinclude.m4
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -566,7 +566,7 @@ param_init ()
>
> # __builtin_alloca is not available everywhere, check it exists before
> # seeing that it works
> -GMP_PROG_CC_WORKS_PART_TEST([$1],[__builtin_alloca availability],
> +GMP_PROG_CC_WORKS_PART([$1],[__builtin_alloca availability],
> [int k; int foo () { __builtin_alloca (k); }],
> [GMP_PROG_CC_WORKS_PART([$1], [alloca array],
> [/* The following provokes an internal compiler error from Itanium HP-UX cc
> _______________________________________________
> gmp-devel mailing list
> gmp-devel at gmplib.org
> https://gmplib.org/mailman/listinfo/gmp-devel
>
More information about the gmp-devel
mailing list