From 2b5ddc26d4e9b901cb693d909fe9b058d71153f8 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 8 May 2025 09:42:23 -0400 Subject: [PATCH 1/4] Makefile: Disable Make's implict suffix rules --- make/compiler_flags | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/make/compiler_flags b/make/compiler_flags index 26e15a0e989..e5e4c9caef2 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -70,6 +70,13 @@ CXX_VERSION := $(shell $(CXX) -dumpfullversion -dumpversion 2>&1) CXX_MAJOR := $(word 1,$(subst ., ,$(CXX_VERSION))) CXX_MINOR := $(word 2,$(subst ., ,$(CXX_VERSION))) +# disable Make's implicit suffix rules +# see: https://www.gnu.org/software/make/manual/html_node/Implicit-Rules.html +# this should make Make slightly faster, as well as avoiding some unexpected +# behavior when there are other files lying around with the same name as +# Stan models +.SUFFIXES: + ################################################################################ # Set optional compiler flags for performance # From eb4d188f331bebe1cabee3f1f7dc9c29ff35e291 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 8 May 2025 10:00:14 -0400 Subject: [PATCH 2/4] Add back .cc for googletest --- make/compiler_flags | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make/compiler_flags b/make/compiler_flags index e5e4c9caef2..20b60fa9a2b 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -75,7 +75,8 @@ CXX_MINOR := $(word 2,$(subst ., ,$(CXX_VERSION))) # this should make Make slightly faster, as well as avoiding some unexpected # behavior when there are other files lying around with the same name as # Stan models -.SUFFIXES: +# We do need to leave some rules in place for things like googletest to function +.SUFFIXES: .cc ################################################################################ # Set optional compiler flags for performance From f7cc08a3fe4c704ba719dcd1dabcd093122403ae Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 8 May 2025 10:08:35 -0400 Subject: [PATCH 3/4] Just define a rule for gtest-all.o --- make/compiler_flags | 3 +-- make/libraries | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/make/compiler_flags b/make/compiler_flags index 20b60fa9a2b..e5e4c9caef2 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -75,8 +75,7 @@ CXX_MINOR := $(word 2,$(subst ., ,$(CXX_VERSION))) # this should make Make slightly faster, as well as avoiding some unexpected # behavior when there are other files lying around with the same name as # Stan models -# We do need to leave some rules in place for things like googletest to function -.SUFFIXES: .cc +.SUFFIXES: ################################################################################ # Set optional compiler flags for performance diff --git a/make/libraries b/make/libraries index e2b347d8388..a5be7d49510 100644 --- a/make/libraries +++ b/make/libraries @@ -252,11 +252,8 @@ endif ############################################################ # Google Test: # Build the google test library. -$(GTEST)/src/gtest-all.o: CXXFLAGS += $(CXXFLAGS_GTEST) -$(GTEST)/src/gtest-all.o: CPPFLAGS += $(CPPFLAGS_GTEST) -$(GTEST)/src/gtest-all.o: INC += $(INC_GTEST) - - +$(GTEST)/src/gtest-all.o: $(GTEST)/src/gtest-all.cc + $(COMPILE.cpp) -x c++ $(CXXFLAGS_GTEST) $(CPPFLAGS_GTEST) $(INC_GTEST) -o $@ -c $< ############################################################ # Clean all libraries From b029119eeaac84beb86170131c5b12e11baa54c5 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Thu, 8 May 2025 10:18:18 -0400 Subject: [PATCH 4/4] .cpp for tests --- make/compiler_flags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/compiler_flags b/make/compiler_flags index e5e4c9caef2..336fb3d9d42 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -75,7 +75,7 @@ CXX_MINOR := $(word 2,$(subst ., ,$(CXX_VERSION))) # this should make Make slightly faster, as well as avoiding some unexpected # behavior when there are other files lying around with the same name as # Stan models -.SUFFIXES: +.SUFFIXES: .cpp ################################################################################ # Set optional compiler flags for performance