Skip to content

Commit 598dba7

Browse files
authored
Merge pull request #2948 from stan-dev/tbb-ucrt-makeflags
Add makeflag for building TBB under UCRT automatically
2 parents be485f4 + dfe460d commit 598dba7

5 files changed

Lines changed: 27 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ lib/tbb
7171

7272
# local make include
7373
/make/local
74+
/make/ucrt
7475

7576
# python byte code
7677
*.pyc

make/compiler_flags

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,21 @@ ifeq ($(OS),Windows_NT)
161161
CXXFLAGS_OS ?= -m64
162162
endif
163163

164+
make/ucrt:
165+
pound := \#
166+
UCRT_STRING := $(shell echo '$(pound)include <windows.h>' | $(CXX) -E -dM - | findstr _UCRT)
167+
ifneq (,$(UCRT_STRING))
168+
IS_UCRT ?= true
169+
else
170+
IS_UCRT ?= false
171+
endif
172+
$(shell echo "IS_UCRT ?= $(IS_UCRT)" > $(MATH)make/ucrt)
173+
174+
include make/ucrt
175+
ifeq ($(IS_UCRT),true)
176+
CXXFLAGS_OS += -D_UCRT
177+
endif
178+
164179
ifneq (gcc,$(CXX_TYPE))
165180
LDLIBS_OS ?= -static-libgcc
166181
else

make/libraries

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ ifeq (Linux, $(OS))
139139
SHELL = /usr/bin/env bash
140140
endif
141141

142+
ifeq (Windows_NT, $(OS))
143+
ifeq ($(IS_UCRT),true)
144+
TBB_CXXFLAGS += -D_UCRT
145+
endif
146+
endif
147+
142148
# If brackets or spaces are found in MAKE on Windows
143149
# we error, as those characters cause issues when building.
144150
ifeq (Windows_NT, $(OS))

make/tests

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ HEADER_TESTS := $(addsuffix -test,$(call findfiles,stan,*.hpp))
101101

102102
ifeq ($(OS),Windows_NT)
103103
DEV_NULL = nul
104+
ifeq ($(IS_UCRT),true)
105+
UCRT_NULL_FLAG = -S
106+
endif
104107
else
105108
DEV_NULL = /dev/null
106109
endif
107110

108111
%.hpp-test : %.hpp test/dummy.cpp
109-
$(COMPILE.cpp) $(CXXFLAGS) -O0 -include $^ -o $(DEV_NULL) -Wunused-local-typedefs
112+
$(COMPILE.cpp) $(CXXFLAGS) -O0 -include $^ $(UCRT_NULL_FLAG) -o $(DEV_NULL) -Wunused-local-typedefs
110113

111114
test/dummy.cpp:
112115
@mkdir -p test

makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ clean-deps:
125125
@$(RM) $(call findfiles,test,*.d.*)
126126
@$(RM) $(call findfiles,lib,*.d.*)
127127
@$(RM) $(call findfiles,stan,*.dSYM)
128+
@$(RM) $(call findfiles,make,ucrt)
128129

129130
clean-all: clean clean-doxygen clean-deps clean-libraries
130131

0 commit comments

Comments
 (0)