On Thu, Dec 01, 2011 at 09:08:27AM +0100, Arnaud Charlet wrote: > > := assigned variable gets evaluated right away, including the case when > > host doesn't have any Ada compiler installed. In that case we remove ada > > from enabled languages, but still RTS_DIR is sometimes computed. > > Can you elaborate here? When is RTS_DIR computed if Ada is not enabled? > That seems surprising to me, so I'd like to understand more before OKing > this patch.
As written in the PR, even if you on say x86_64-linux ../configure --enable-languages=c --target=i686-pc-linux-gnu you end up with: CONFIG_LANGUAGES = c++ lto LANGUAGES = c gcov$(exeext) gcov-dump$(exeext) $(CONFIG_LANGUAGES) ... LANG_MAKEFRAGS = $(srcdir)/ada/gcc-interface/Make-lang.in $(srcdir)/cp/Make-lang.in $(srcdir)/fortran/Make-lang.in $(srcdir)/go/Make-lang.in $(srcdir)/java/Make-lang.in $(srcdir)/lto/Make-lang.in $(srcdir)/objc/Make-lang.in $(srcdir)/objcp/Make-lang.in ... # per-language makefile fragments ifneq ($(LANG_MAKEFRAGS),) include $(LANG_MAKEFRAGS) endif in gcc/Makefile. When Ada isn't installed on the host, you end up with something like: ... checking whether g++ accepts -g... yes checking for alloca... yes checking for x86_64-unknown-linux-gnu-gnatbind... no checking for x86_64-unknown-linux-gnu-gnatmake... no checking whether compiler driver understands Ada... no checking how to run the C preprocessor... yes gcc -E checking for ANSI C header files... (cached) yes ... config.status: creating ada/gcc-interface/Makefile config.status: creating ada/Makefile config.status: creating auto-host.h config.status: executing default commands /bin/sh: gnatls: command not found make[2]: Entering directory `/usr/src/gcc/obj3/gcc' /bin/sh ../../gcc/../mkinstalldirs po /bin/sh ../../gcc/../mkinstalldirs po /bin/sh ../../gcc/../mkinstalldirs po ... in the output. That is because ada/gcc-interface/Make-lang.in is sourced, even when no goals from it are actually made. But already mere sourcing of that makefile results in ifeq ($(build), $(host)) ifeq ($(host), $(target)) ... else ... RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib ))) ... endif else ... endif $(build) and $(host) is equal here, $(host) and $(target) aren't equal and thus RTS_DIR variable is initialized from the command, irrespective from host GNAT not being detected or present. By changing that variable to deferred: RTS_DIR=$(strip $(subst \,/,$(shell gnatls -v | grep adalib ))) no command is run when the makefile fragment is sourced, instead the command is executed when the vars are actually used: ADA_TOOLS_FLAGS_TO_PASS=\ CC="$(CC)" \ $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) \ ADA_INCLUDES="-I$(RTS_DIR)../adainclude -I$(RTS_DIR)" \ GNATMAKE="gnatmake" \ GNATBIND="gnatbind" \ GNATLINK="gnatlink" \ LIBGNAT="" ... gnattools: $(GCC_PARTS) $(CONFIG_H) prefix.o force $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools1 $(MAKE) -C ada $(ADA_TOOLS_FLAGS_TO_PASS) gnattools2 For gnattools target, this means that gnatls is with the patch invoked 4 times, twice per gnattools1 subcommand and twice per gnattools2 subcommand, but it is evaluated before spawning the submake (i.e. we don't run gnatls per command line). Jakub