Re: AX_PROG_CC_FOR_BUILD should use CFLAGS, etc. in non-crossbuilds

Paolo Bonzini <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.archive-maintainers
Message-ID <[email protected]>
Il 02/01/2014 17:46, Ryan Lortie ha scritto:
> hi,
> 
> Please excuse (and redirect) me if this is not the correct place to file
> this bug.
> 
> The AX_PROG_CC_FOR_BUILD macro in autoconf-archive defines the variables
> CFLAGS_FOR_BUILD, CPPFLAGS_FOR_BUILD and LDFLAGS_FOR_BUILD so that
> people can build executables on the build machine with different
> compiler flags when cross-compiling.
> 
> When not cross-compiling, however, this is a bit of an anti-feature
> because it requires the user to explicitly set these variables in
> addition to the usual CFLAGS, CPPFLAGS, LDFLAGS.
> 
> I consider that there are probably two approaches to fixing it.
> 
> First approach (code added to the top of the macro):
> 
> if test "$cross_compiling" = "no"; then
>        if test -n "$CFLAGS"; then
>                CFLAGS_FOR_BUILD=$CFLAGS
>        fi
>        if test -n "$CPPFLAGS"; then
>                CPPFLAGS_FOR_BUILD=$CPPFLAGS
>        fi
>        if test -n "$LDFLAGS"; then
>                LDFLAGS_FOR_BUILD=$LDFLAGS
>        fi
> fi
> 
> ie: if we see that we are not cross-compiling, initialise the values of
> the _FOR_BUILD variables from their host counterparts (since host ==
> build).
> 
> Second approach:
> 
> if test -z "$CFLAGS_FOR_BUILD" -a -n "$CFLAGS"; then
>       CFLAGS_FOR_BUILD="$CFLAGS"
> fi
> if test -z "$CPPFLAGS_FOR_BUILD" -a -n "$CPPFLAGS"; then
>       CPPFLAGS_FOR_BUILD="$CPPFLAGS"
> fi
> if test -z "$LDFLAGS_FOR_BUILD" -a -n "$LDFLAGS"; then
>       LDFLAGS_FOR_BUILD="$LDFLAGS"
> fi
> 
> ie: always initialise these variables from their host counterparts
> except in the case that they are already explicitly set.

I think the second approach is wrong.  The $cross_compiling test is
necessary.  But you can do: initialise the variables from their host
counterparts in the non-cross-compiling case, but not in the case that
they are already explicitly set.

What do you think?

Paolo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.