diff --git a/.gitignore b/.gitignore index 64d811d4bed..ab2dd6a91bb 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,7 @@ lib/tbb # local make include /make/local +/make/ucrt # python byte code *.pyc diff --git a/make/compiler_flags b/make/compiler_flags index 1552381f232..a4c6224e6da 100644 --- a/make/compiler_flags +++ b/make/compiler_flags @@ -161,6 +161,21 @@ ifeq ($(OS),Windows_NT) CXXFLAGS_OS ?= -m64 endif + make/ucrt: + pound := \# + UCRT_STRING := $(shell echo '$(pound)include ' | $(CXX) -E -dM - | findstr _UCRT) + ifneq (,$(UCRT_STRING)) + IS_UCRT ?= true + else + IS_UCRT ?= false + endif + $(shell echo "IS_UCRT ?= $(IS_UCRT)" > $(MATH)make/ucrt) + + include make/ucrt + ifeq ($(IS_UCRT),true) + CXXFLAGS_OS += -D_UCRT + endif + ifneq (gcc,$(CXX_TYPE)) LDLIBS_OS ?= -static-libgcc else diff --git a/make/libraries b/make/libraries index 441f5b8c3e0..7dd5dcbfd45 100644 --- a/make/libraries +++ b/make/libraries @@ -139,6 +139,12 @@ ifeq (Linux, $(OS)) SHELL = /usr/bin/env bash endif +ifeq (Windows_NT, $(OS)) + ifeq ($(IS_UCRT),true) + TBB_CXXFLAGS += -D_UCRT + endif +endif + # If brackets or spaces are found in MAKE on Windows # we error, as those characters cause issues when building. ifeq (Windows_NT, $(OS)) diff --git a/make/tests b/make/tests index 14a2550f08d..fcf379d6520 100644 --- a/make/tests +++ b/make/tests @@ -101,12 +101,15 @@ HEADER_TESTS := $(addsuffix -test,$(call findfiles,stan,*.hpp)) ifeq ($(OS),Windows_NT) DEV_NULL = nul + ifeq ($(IS_UCRT),true) + UCRT_NULL_FLAG = -S + endif else DEV_NULL = /dev/null endif %.hpp-test : %.hpp test/dummy.cpp - $(COMPILE.cpp) $(CXXFLAGS) -O0 -include $^ -o $(DEV_NULL) -Wunused-local-typedefs + $(COMPILE.cpp) $(CXXFLAGS) -O0 -include $^ $(UCRT_NULL_FLAG) -o $(DEV_NULL) -Wunused-local-typedefs test/dummy.cpp: @mkdir -p test diff --git a/makefile b/makefile index f34da7b164b..f14ab40df4e 100644 --- a/makefile +++ b/makefile @@ -125,6 +125,7 @@ clean-deps: @$(RM) $(call findfiles,test,*.d.*) @$(RM) $(call findfiles,lib,*.d.*) @$(RM) $(call findfiles,stan,*.dSYM) + @$(RM) $(call findfiles,make,ucrt) clean-all: clean clean-doxygen clean-deps clean-libraries