Skip to content

config_pass_vars_to_children_1

Tsukasa OI edited this page Oct 4, 2022 · 4 revisions

configure: Pass CPPFLAGS_FOR_BUILD to subdirectories

Issue Solved

While investigating previous -Wstack-usage=262144 removal (on Clang) patch, I found something intresting.

Here's some excerpt from $(builddir)/bfd/config.log:

gcc: warning: @CPPFLAGS_FOR_BUILD@: linker input file unused because linking not done
gcc: error: @CPPFLAGS_FOR_BUILD@: linker input file not found: No such file or directory
gcc: warning: @CPPFLAGS_FOR_BUILD@: linker input file unused because linking not done
gcc: error: @CPPFLAGS_FOR_BUILD@: linker input file not found: No such file or directory
gcc: warning: @CPPFLAGS_FOR_BUILD@: linker input file unused because linking not done
gcc: error: @CPPFLAGS_FOR_BUILD@: linker input file not found: No such file or directory

This is because command like this is called:

gcc -E @CPPFLAGS_FOR_BUILD@ conftest.c

I found that this is because $(build)/Makefile passes CPPFLAGS_FOR_BUILD environment variable without substituting with AC_SUBST (should be placed in $(srcdir)/configure.ac).

Here's excerpt from $(builddir)/Makefile:

CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@

THIS IS NOT $(srcdir)/Makefile.in (it's normal in Makefile.in but should be substituted while generating $(builddir)/Makefile).

I searched similar examples and found that following environment variables are unsubstituted in $(builddir)/Makefile and possibly used in subdirectories:

  • CPPFLAGS_FOR_BUILD
  • DSYMUTIL
  • DSYMUTIL_FOR_BUILD
  • DSYMUTIL_FOR_TARGET
  • OTOOL
  • OTOOL_FOR_TARGET

Note: There are other unsubstituted variables but I think they are not used by any subdirectories.

At least, CPPFLAGS_FOR_BUILD can be tested on my own. For that, I think this simple patch would work.

Clone this wiki locally