From d8027fc843e8343bbd750e718259f970d3d08dbb Mon Sep 17 00:00:00 2001 From: Paul Cadman Date: Mon, 27 Nov 2023 09:14:20 +0000 Subject: [PATCH] runtime Makefile: Do not resolve variables when writing a dependency file (#2538) This is an attempt to fix a confusing situation where a user: 1. Builds the runtime with clang that does not support wasm32-wasi 2. Attempts to rebuild the runtime by passing the CC parameter pointing to another installation of clang that does support wasm32-wasi. In step 1. the runtime Makefile generates dependencies files which contain the resolved value of `$(CC)`. When the user passes the correct `CC` variable to the Makefile in step 2., the dependencies files are not regenerated, the old value of `CC` is used in the build and the build continues to fail. In this PR we change the dependency file generation so that the variables like `$(CC)` are written into the dependency file verbatim. They are resolved when they are run in step 2. using the new value of the CC parameter. * Closes https://github.com/anoma/juvix/issues/2537 --- runtime/Makefile.generic | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/runtime/Makefile.generic b/runtime/Makefile.generic index a8f5cf0218..9a085b7af3 100644 --- a/runtime/Makefile.generic +++ b/runtime/Makefile.generic @@ -240,23 +240,23 @@ $(CLEXSOURCES) : $(BUILDDIR)%.c : %.lex $(CDEPENDS) : $(BUILDDIR)%.d : %.c $(CC) $(CDEPFLAGS) -MM -MT $(patsubst %.c,$(BUILDDIR)%.o,$<) $< > $@ - printf "\t$(CC) -c $(CFLAGS) -o $(patsubst %.c,$(BUILDDIR)%.o,$<) $<\n" >> $@ + printf "\t\$$(CC) -c \$$(CFLAGS) -o $(patsubst %.c,$(BUILDDIR)%.o,$<) $<\n" >> $@ $(CYLDEPENDS) : $(BUILDDIR)%.d : $(BUILDDIR)%.c $(CC) $(CDEPFLAGS) -MM -MT $(patsubst %.c,%.o,$<) $< > $@ - printf "\t$(CC) -c $(CFLAGS) -o $(patsubst %.c,%.o,$<) $<\n" >> $@ + printf "\t\$$(CC) -c \$$(CFLAGS) -o $(patsubst %.c,%.o,$<) $<\n" >> $@ $(CPPDEPENDS) : $(BUILDDIR)%.d : %.cpp $(CXX) $(CXXDEPFLAGS) -MM -MT $(patsubst %.cpp,$(BUILDDIR)%.o,$<) $< > $@ - printf "\t$(CXX) -c $(CXXFLAGS) -o $(patsubst %.cpp,$(BUILDDIR)%.o,$<) $<\n" >> $@ + printf "\t\$$(CXX) -c \$$(CXXFLAGS) -o $(patsubst %.cpp,$(BUILDDIR)%.o,$<) $<\n" >> $@ $(CXXDEPENDS) : $(BUILDDIR)%.d : %.cxx $(CXX) $(CXXDEPFLAGS) -MM -MT $(patsubst %.cxx,$(BUILDDIR)%.o,$<) $< > $@ - printf "\t$(CXX) -c $(CXXFLAGS) -o $(patsubst %.cxx,$(BUILDDIR)%.o,$<) $<\n" >> $@ + printf "\t\$$(CXX) -c \$$(CXXFLAGS) -o $(patsubst %.cxx,$(BUILDDIR)%.o,$<) $<\n" >> $@ $(CCDEPENDS) : $(BUILDDIR)%.d : %.cc $(CXX) $(CXXDEPFLAGS) -MM -MT $(patsubst %.cc,$(BUILDDIR)%.o,$<) $< > $@ - printf "\t$(CXX) -c $(CXXFLAGS) -o $(patsubst %.cc,$(BUILDDIR)%.o,$<) $<\n" >> $@ + printf "\t\$$(CXX) -c \$$(CXXFLAGS) -o $(patsubst %.cc,$(BUILDDIR)%.o,$<) $<\n" >> $@ $(CPROGRAMS) : % : $(ALLOBJECTS) $(CCLD) -o $@ $@.o $(OBJECTS) $(CCLDFLAGS)