[m-rev.] for review: Fix mmake issue when compiling without a bootstrap compiler.

Peter Wang novalazy at gmail.com
Wed Oct 18 17:54:19 AEDT 2023


Fix an issue exposed by commit 7d001786a0d2b26a1cc6195fd63bd05b9843be03.

VPATH indirectly refers to GRADESTRING_NO_TARGET.
When the VPATH is being calculated after the makefile is read,
the reference to GRADESTRING_NO_TARGET causes make to try to run the
Mercury compiler to output a grade string, but we may not yet have a
working Mercury compiler.

scripts/Mmake.vars.in:
    Set EXTRA_INIT_DIRS_NO_TARGET to a non-empty string
    (that references GRADESTRING_NO_TARGET in a pattern substitution)
    only if EXTRA_LIB_DIRS is actually non-empty.
---
 scripts/Mmake.vars.in | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/scripts/Mmake.vars.in b/scripts/Mmake.vars.in
index 0eca0f257..01eab66d6 100644
--- a/scripts/Mmake.vars.in
+++ b/scripts/Mmake.vars.in
@@ -27,6 +27,13 @@ ALL_EXTRA_LIBRARIES = $(TARGET_EXTRA_LIBRARIES) $(EXTRA_LIBRARIES)
 EXTRA_LIB_DIRS =
 EXTRA_LIBRARIES =
 
+EXTRA_INT_DIRS =
+EXTRA_C_LIB_DIRS =
+EXTRA_C_INCL_DIRS =
+EXTRA_INIT_DIRS =
+EXTRA_INIT_DIRS_NO_TARGET =
+
+# `mmc --make' handles these paths itself.
 ifneq ($(MMAKE_USE_MMC_MAKE),yes)
 EXTRA_INT_DIRS		= $(patsubst %,%/ints,$(EXTRA_LIB_DIRS))
 EXTRA_C_LIB_DIRS	= \
@@ -37,15 +44,16 @@ EXTRA_C_INCL_DIRS	= \
 	$(patsubst %,%/inc,$(EXTRA_LIB_DIRS))
 EXTRA_INIT_DIRS		= \
 	$(patsubst %,%/modules/$(GRADESTRING),$(EXTRA_LIB_DIRS))
+# EXTRA_INIT_DIRS_NO_TARGET is referenced by VPATH so it will always be
+# expanded after the makefile is read. The occurrence of GRADESTRING_NO_TARGET
+# in the pattern substitution causes make to run $(MC) in a shell command, but
+# we may not have a working Mercury compiler yet. Therefore, leave
+# EXTRA_INIT_DIRS_NO_TARGET empty unless EXTRA_LIB_DIRS is actually used;
+# it is not used while building the Mercury system itself.
+ifneq ($(EXTRA_LIB_DIRS),)
 EXTRA_INIT_DIRS_NO_TARGET = \
 	$(patsubst %,%/modules/$(GRADESTRING_NO_TARGET),$(EXTRA_LIB_DIRS))
-else
-# mmc handles these itself when invoked with `--make'.
-EXTRA_INT_DIRS =
-EXTRA_C_LIB_DIRS =
-EXTRA_C_INCL_DIRS =
-EXTRA_INIT_DIRS =
-EXTRA_INIT_DIRS_NO_TARGET =
+endif
 endif
 
 # Set the directory search path.
-- 
2.42.0



More information about the reviews mailing list