From df1b0bc334515ac13b1364fe58df60c51a3463c6 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 9 May 2024 16:05:18 -0400 Subject: [PATCH 1/2] Fix GCC's ability to find the precompiled header --- make/program | 7 ++++--- makefile | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/make/program b/make/program index 6aa40348e1..180d13cc78 100644 --- a/make/program +++ b/make/program @@ -16,14 +16,15 @@ $(CMDSTAN_MAIN_O) : $(CMDSTAN_MAIN) ## # Precompiled model header ## -$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).d : $(STAN)src/stan/model/model_header.hpp +$(patsub %.d,%.hpp.gch,$(PRECOMPILED_MODEL_HEADER)) : $(STAN)src/stan/model/model_header.hpp $(COMPILE.cpp) $(DEPFLAGS) $< ifneq ($(PRECOMPILED_MODEL_HEADER),) -$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).d : DEPTARGETS = -MT $(patsubst %.d,%.hpp.gch,$@) -MT $@ -$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch : $(STAN)src/stan/model/model_header.hpp +$(patsub %.d,%.hpp.gch,$(PRECOMPILED_MODEL_HEADER)) : DEPTARGETS = -MT $(patsubst %.d,%.hpp.gch,$@) -MT $@ +$(PRECOMPILED_MODEL_HEADER) : $(STAN)src/stan/model/model_header.hpp @echo '' @echo '--- Compiling pre-compiled header. This might take a few seconds. ---' + @mkdir $(dir $@) $(COMPILE.cpp) $< $(OUTPUT_OPTION) ifeq ($(CXX_TYPE),clang) diff --git a/makefile b/makefile index 2fe8e82524..2ccd2eeab9 100644 --- a/makefile +++ b/makefile @@ -132,7 +132,7 @@ PRECOMPILED_HEADERS ?= true endif ifeq ($(PRECOMPILED_HEADERS),true) -PRECOMPILED_MODEL_HEADER=$(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch +PRECOMPILED_MODEL_HEADER=$(STAN)src/stan/model/model_header.hpp.gch/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch ifeq ($(CXX_TYPE),gcc) CXXFLAGS_PROGRAM+= -Wno-ignored-attributes $(CXXFLAGS_OPTIM) $(CXXFLAGS_FLTO) endif @@ -284,6 +284,7 @@ clean: clean-tests $(RM) -r bin/cmdstan @echo ' removing cached compiler objects' $(RM) $(wildcard src/cmdstan/main*.o) $(wildcard $(STAN)src/stan/model/model_header*.hpp.gch) + $(RM) -r $(STAN)src/stan/model/model_header.hpp.gch/ @echo ' removing built example model' $(RM) examples/bernoulli/bernoulli$(EXE) examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.d examples/bernoulli/bernoulli.hpp $(wildcard examples/bernoulli/*.csv) From e923461da9db00f45a21af1464a924c1c9503b67 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 9 May 2024 16:42:24 -0400 Subject: [PATCH 2/2] Fix clang variable I missed --- make/program | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make/program b/make/program index 180d13cc78..16f2818be5 100644 --- a/make/program +++ b/make/program @@ -28,8 +28,8 @@ $(PRECOMPILED_MODEL_HEADER) : $(STAN)src/stan/model/model_header.hpp $(COMPILE.cpp) $< $(OUTPUT_OPTION) ifeq ($(CXX_TYPE),clang) -CXXFLAGS_PROGRAM += -include-pch $(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch -$(STAN_TARGETS) : %$(EXE) : $(STAN)src/stan/model/model_header$(STAN_FLAGS)_$(CXX_MAJOR)_$(CXX_MINOR).hpp.gch +CXXFLAGS_PROGRAM += -include-pch $(PRECOMPILED_MODEL_HEADER) +$(STAN_TARGETS) : %$(EXE) : $(PRECOMPILED_MODEL_HEADER) endif endif