GDB: How does configure with with config.cache??

Simon Marchi simark@simark.ca
Thu Sep 12 12:23:11 GMT 2024


On 9/11/24 6:10 PM, Paul Smith via Gdb wrote:
> Can someone explain to me how the GDB top-level configure script works?
> It's driving me bananas.
> 
> I'm trying to build a version of GDB based on non-default compiler and
> libraries, and what keeps happening is that I invoke the top-level
> configure script with all the settings etc. that I want, and after it's
> finished running I see that there is a config.cache file in each of the
> subdirectories, and its contents are WRONG.
> 
> This causes everything to go haywire when I run make and it tries to
> run configure in each of the subdirectories.
> 
> For example, I invoke configure with this argument (among many):
> 
>     ../gdb-15.1/configure ... CFLAGS='-O2 -static-libgcc' ...
> 
> after the configure script runs, when I look at the gdb/config.cache
> for example, its contents are wrong:
> 
>    ac_cv_env_CFLAGS_set=set
>    ac_cv_env_CFLAGS_value='-ggdb3    '
> 
> this isn't what I said, and it's wrong because then when I run make and
> it invokes configure in the subdirectories passing this CFLAGS
> assignment on the command line as above, and it fails:
> 
>   configure: loading cache ./config.cache
>   configure: error: `CFLAGS' has changed since the previous run:
>   configure:   former value:  `-ggdb3    '
>   configure:   current value: `-O2 -static-libgcc  '

It sounds like you are trying to configure with a set of flags in a
build directory that is already configured with another set of flags.
Otherwise, I don't know where that `-ggdb3` for CFLAGS would come from.

You would need to delete all config.cache files before re-configuring,
or more simply wipe the build directory and start from scratch.

> 
> I just can't figure out how this is supposed to work.  Why are the
> initial values in subdirs config.cache files all wrong?  Where are
> these config.cache files even created (I couldn't find where it's
> created in the configure or configure.ac files but it must be there,
> hiding).

They are in every directory that is configured, in the build dir:

    $ find . -name config.cache | sort
    ./bfd/config.cache
    ./etc/config.cache
    ./gdb/config.cache
    ./gdbserver/config.cache
    ./gdbsupport/config.cache
    ./gnulib/config.cache
    ./libbacktrace/config.cache
    ./libctf/config.cache
    ./libdecnumber/config.cache
    ./libiberty/config.cache
    ./libsframe/config.cache
    ./opcodes/config.cache
    ./sim/config.cache

> PS. It's annoying that the GDB top-level makefile doesn't support any
> way to show the commands being invoked in the makefile recipes; most
> modern GNU makefiles use the $V.SILENT: trick to do this but this
> doesn't appear to be used in the Makefile.tpl file.
> 
> If people are interested I could send a patch.

I suppose it would be fine.

Simon


More information about the Gdb mailing list