Subject: Re: Report: iproute2 build broken?

From: Stephen Hemminger <[email-masked]>
Date: Mon, 4 Jul 2022 10:07:29 -0700

On Mon, 4 Jul 2022 11:51:39 -0400
Jamal Hadi Salim <[email-masked]> wrote:

> I have to admit i am being lazy here digging into the
> root cause but normally iproute2 should just build
> standalone regardless especially when it is a stable
> version:
> 
> $ cat include/version.h
> static const char version[] = "5.18.0";
> 
> $make
> ..
> ....
> .....
>   CC       iplink_bond.o
> iplink_bond.c:935:10: error: initializer element is not constant
>   .desc = ipstats_stat_desc_bond_tmpl_lacp,
>           ^
> iplink_bond.c:935:10: note: (near initialization for
> ‘ipstats_stat_desc_xstats_bond_lacp.desc’)
> iplink_bond.c:957:10: error: initializer element is not constant
>   .desc = ipstats_stat_desc_bond_tmpl_lacp,
>           ^
> iplink_bond.c:957:10: note: (near initialization for
> ‘ipstats_stat_desc_xstats_slave_bond_lacp.desc’)
> ../config.mk:40: recipe for target 'iplink_bond.o' failed
> make[1]: *** [iplink_bond.o] Error 1
> Makefile:77: recipe for target 'all' failed
> make: *** [all] Error 2
> 
> There's more if you fix that one given a whole lot
> of dependencies
> 
> cheers,
> jamal

Fixed in main by:

commit 11e41a635cfab54e8e02fbff2a03715467e77ae9
Author: Petr Machata <[email-masked]>
Date:   Tue May 31 13:35:48 2022 +0200

    ip: Convert non-constant initializers to macros
    
    As per the C standard, "expressions in an initializer for an object that
    has static or thread storage duration shall be constant expressions".
    Aggregate objects are not constant expressions. Newer GCC doesn't mind, but
    older GCC and LLVM do.
    
    Therefore convert to a macro. And since all these macros will look very
    similar, extract a generic helper, IPSTATS_STAT_DESC_XSTATS_LEAF, which
    takes the leaf name as an argument and initializes the rest as appropriate
    for an xstats descriptor.
    
    Reported-by: Stephen Hemminger <[email-masked]>
    Signed-off-by: Petr Machata <[email-masked]>
    Reviewed-by: Ido Schimmel <[email-masked]>
    Signed-off-by: Stephen Hemminger <[email-masked]>