Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add makeflag for building TBB under UCRT automatically #2948

Merged
merged 11 commits into from
Sep 29, 2023
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ lib/tbb

# local make include
/make/local
/make/ucrt

# python byte code
*.pyc
Expand Down
15 changes: 15 additions & 0 deletions make/compiler_flags
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ ifeq ($(OS),Windows_NT)
CXXFLAGS_OS ?= -m64
endif

make/ucrt:
pound := \#
UCRT_STRING := $(shell echo '$(pound)include <windows.h>' | $(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
Expand Down
6 changes: 6 additions & 0 deletions make/libraries
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
5 changes: 4 additions & 1 deletion make/tests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting so we remember to do it: it seems like stan and cmdstan do not call the clean target of their submodules, so we will need to manually add something which deletes this higher up.


clean-all: clean clean-doxygen clean-deps clean-libraries

Expand Down