diff mbox series

[v2,1/1] package/gmp: fix target build with host gcc 4.9

Message ID 20240315234316.17513-1-brandon.maier@collins.com
State Accepted
Headers show
Series [v2,1/1] package/gmp: fix target build with host gcc 4.9 | expand

Commit Message

Brandon Maier March 15, 2024, 11:43 p.m. UTC
GMP does not build if the host gcc is v4.9 due to the following error

  gen-sieve.c: In function 'setmask':
  gen-sieve.c:99:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
     for (unsigned i = 0; i < 2 * a * b; ++i)
     ^
  gen-sieve.c:99:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

The gen-sieve utility was added in GMP v6.3.0. It is built using
CC_FOR_BUILD (host compiler) during cross compilation as it generates
build files. Autoconf does not have a macro for add -std=c99 to
CC_FOR_BUILD, so it must be set manually.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
---
v1: https://patchwork.ozlabs.org/project/buildroot/patch/20240312190954.71227-1-brandon.maier@collins.com/

v2:
- remove unnecessary comment and ifdef check
---
 package/gmp/gmp.mk | 2 ++
 1 file changed, 2 insertions(+)

Comments

Arnout Vandecappelle March 24, 2024, 3:44 p.m. UTC | #1
Hi Brandon,

On 16/03/2024 00:43, Brandon Maier wrote:
> GMP does not build if the host gcc is v4.9 due to the following error
> 
>    gen-sieve.c: In function 'setmask':
>    gen-sieve.c:99:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
>       for (unsigned i = 0; i < 2 * a * b; ++i)
>       ^
>    gen-sieve.c:99:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
> 
> The gen-sieve utility was added in GMP v6.3.0. It is built using
> CC_FOR_BUILD (host compiler) during cross compilation as it generates
> build files. Autoconf does not have a macro for add -std=c99 to
> CC_FOR_BUILD, so it must be set manually.

  I've added the explanation you gave why this is not needed for the target.

  Applied to master, thanks.

  Regards,
  Arnout

> 
> Signed-off-by: Brandon Maier <brandon.maier@collins.com>
> ---
> v1: https://patchwork.ozlabs.org/project/buildroot/patch/20240312190954.71227-1-brandon.maier@collins.com/
> 
> v2:
> - remove unnecessary comment and ifdef check
> ---
>   package/gmp/gmp.mk | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/package/gmp/gmp.mk b/package/gmp/gmp.mk
> index bd401c6a80..7e8da9025c 100644
> --- a/package/gmp/gmp.mk
> +++ b/package/gmp/gmp.mk
> @@ -14,6 +14,8 @@ GMP_CPE_ID_VENDOR = gmplib
>   GMP_DEPENDENCIES = host-m4
>   HOST_GMP_DEPENDENCIES = host-m4
>   
> +GMP_CONF_ENV += CC_FOR_BUILD="$(HOSTCC) -std=c99"
> +
>   # GMP doesn't support assembly for coldfire or mips r6 ISA yet
>   # Disable for ARM v7m since it has different asm constraints
>   ifeq ($(BR2_m68k_cf)$(BR2_MIPS_CPU_MIPS32R6)$(BR2_MIPS_CPU_MIPS64R6)$(BR2_ARM_CPU_ARMV7M),y)
Peter Korsgaard March 25, 2024, 9:04 a.m. UTC | #2
>>>>> "Brandon" == Brandon Maier via buildroot <buildroot@buildroot.org> writes:

 > GMP does not build if the host gcc is v4.9 due to the following error
 >   gen-sieve.c: In function 'setmask':
 >   gen-sieve.c:99:3: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
 >      for (unsigned i = 0; i < 2 * a * b; ++i)
 >      ^
 >   gen-sieve.c:99:3: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

 > The gen-sieve utility was added in GMP v6.3.0. It is built using
 > CC_FOR_BUILD (host compiler) during cross compilation as it generates
 > build files. Autoconf does not have a macro for add -std=c99 to
 > CC_FOR_BUILD, so it must be set manually.

 > Signed-off-by: Brandon Maier <brandon.maier@collins.com>
 > ---
 > v1: https://patchwork.ozlabs.org/project/buildroot/patch/20240312190954.71227-1-brandon.maier@collins.com/

 > v2:
 > - remove unnecessary comment and ifdef check

Committed to 2024.02.x and 2023.11.x, thanks.
diff mbox series

Patch

diff --git a/package/gmp/gmp.mk b/package/gmp/gmp.mk
index bd401c6a80..7e8da9025c 100644
--- a/package/gmp/gmp.mk
+++ b/package/gmp/gmp.mk
@@ -14,6 +14,8 @@  GMP_CPE_ID_VENDOR = gmplib
 GMP_DEPENDENCIES = host-m4
 HOST_GMP_DEPENDENCIES = host-m4
 
+GMP_CONF_ENV += CC_FOR_BUILD="$(HOSTCC) -std=c99"
+
 # GMP doesn't support assembly for coldfire or mips r6 ISA yet
 # Disable for ARM v7m since it has different asm constraints
 ifeq ($(BR2_m68k_cf)$(BR2_MIPS_CPU_MIPS32R6)$(BR2_MIPS_CPU_MIPS64R6)$(BR2_ARM_CPU_ARMV7M),y)