Skip to content

Commit babb1ad

Browse files
authored
Merge pull request #2999 from stan-dev/tbb-rtools-make
Minor patches to TBB Windows build for compatibility with RTools make
2 parents 70f8047 + e5b364b commit babb1ad

6 files changed

Lines changed: 24 additions & 65 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,12 @@ jobs:
3535
- name: Set path for Rtools40
3636
if: runner.os == 'Windows'
3737
run: echo "C:/rtools40/usr/bin;C:/rtools40/mingw64/bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
38-
- name: Install mingw32-make and check toolchain path
39-
if: runner.os == 'Windows'
40-
run: |
41-
pacman -Syu mingw-w64-x86_64-make --noconfirm
42-
g++ --version
43-
Get-Command g++ | Select-Object -ExpandProperty Definition
44-
mingw32-make --version
45-
Get-Command mingw32-make | Select-Object -ExpandProperty Definition
46-
shell: powershell
4738

4839
- name: Build Math libs
4940
shell: powershell
5041
run: |
5142
Add-Content make\local "O=1`n"
52-
mingw32-make -f make/standalone math-libs -j2
43+
make -f make/standalone math-libs -j2
5344
- name: Add TBB to PATH
5445
shell: powershell
5546
run: echo "D:/a/math/math/lib/tbb" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
@@ -85,21 +76,12 @@ jobs:
8576
- name: Set path for Rtools40
8677
if: runner.os == 'Windows'
8778
run: echo "C:/rtools40/usr/bin;C:/rtools40/mingw64/bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
88-
- name: Install mingw32-make and check toolchain path
89-
if: runner.os == 'Windows'
90-
run: |
91-
pacman -Syu mingw-w64-x86_64-make --noconfirm
92-
g++ --version
93-
Get-Command g++ | Select-Object -ExpandProperty Definition
94-
mingw32-make --version
95-
Get-Command mingw32-make | Select-Object -ExpandProperty Definition
96-
shell: powershell
9779

9880
- name: Build Math libs
9981
shell: powershell
10082
run: |
10183
Add-Content make\local "O=1`n"
102-
mingw32-make -f make/standalone math-libs -j2
84+
make -f make/standalone math-libs -j2
10385
- name: Add TBB to PATH
10486
shell: powershell
10587
run: echo "D:/a/math/math/lib/tbb" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
@@ -139,21 +121,12 @@ jobs:
139121
- name: Set path for Rtools40
140122
if: runner.os == 'Windows'
141123
run: echo "C:/rtools40/usr/bin;C:/rtools40/mingw64/bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
142-
- name: Install mingw32-make and check toolchain path
143-
if: runner.os == 'Windows'
144-
run: |
145-
pacman -Syu mingw-w64-x86_64-make --noconfirm
146-
g++ --version
147-
Get-Command g++ | Select-Object -ExpandProperty Definition
148-
mingw32-make --version
149-
Get-Command mingw32-make | Select-Object -ExpandProperty Definition
150-
shell: powershell
151124

152125
- name: Build Math libs
153126
shell: powershell
154127
run: |
155128
Add-Content make\local "O=1`n"
156-
mingw32-make -f make/standalone math-libs -j2
129+
make -f make/standalone math-libs -j2
157130
- name: Add TBB to PATH
158131
shell: powershell
159132
run: echo "D:/a/math/math/lib/tbb" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
@@ -171,7 +144,7 @@ jobs:
171144
with:
172145
name: gtest_outputs_xml
173146
path: '**/*_test.xml'
174-
147+
175148
mix-fun-2:
176149
name: mix/fun tests 2
177150
runs-on: windows-latest
@@ -188,21 +161,12 @@ jobs:
188161
- name: Set path for Rtools40
189162
if: runner.os == 'Windows'
190163
run: echo "C:/rtools40/usr/bin;C:/rtools40/mingw64/bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
191-
- name: Install mingw32-make and check toolchain path
192-
if: runner.os == 'Windows'
193-
run: |
194-
pacman -Syu mingw-w64-x86_64-make --noconfirm
195-
g++ --version
196-
Get-Command g++ | Select-Object -ExpandProperty Definition
197-
mingw32-make --version
198-
Get-Command mingw32-make | Select-Object -ExpandProperty Definition
199-
shell: powershell
200164

201165
- name: Build Math libs
202166
shell: powershell
203167
run: |
204168
Add-Content make\local "O=1`n"
205-
mingw32-make -f make/standalone math-libs -j2
169+
make -f make/standalone math-libs -j2
206170
- name: Add TBB to PATH
207171
shell: powershell
208172
run: echo "D:/a/math/math/lib/tbb" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8

lib/tbb_2020.3/STAN_CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ This file documents changes done for the stan-math project
22

33
- drop -g flag from makefiles for release mode builds to decrease size of binaries
44
- Add `tbb::` to line 252 of `task.h` to fix a build failure with gcc 13. This was done upstream in https://github.com/oneapi-src/oneTBB/pull/833
5+
6+
- build/windows.inc patches for RTools make:
7+
- L15 changed setting to use '?=', allowing override
8+
- L25,L113,L114 added additional '/' to each cmd flag

lib/tbb_2020.3/build/windows.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
export SHELL = cmd
15+
SHELL ?= cmd
1616

1717
ifdef tbb_build_dir
1818
test_dir:=$(tbb_build_dir)
@@ -22,7 +22,7 @@ endif
2222

2323
# A convenience wrapper for calls to detect.js.
2424
# $(1) is the full command line for the script, e.g. /minversion icl 12
25-
detect_js = $(shell cmd /C "cscript /nologo /E:jscript $(tbb_root)/build/detect.js $(1)")
25+
detect_js = $(shell cmd //C "cscript //nologo //E:jscript $(tbb_root)/build/detect.js $(1)")
2626

2727
# TODO give an error if archs doesn't match
2828
ifndef arch
@@ -110,8 +110,8 @@ ifneq ($(filter vc8 vc9,$(runtime)),)
110110
RML.MANIFEST = tbbmanifest.exe.manifest
111111
endif
112112

113-
MAKE_VERSIONS = cmd /C cscript /nologo /E:jscript $(subst \,/,$(tbb_root))/build/version_info_windows.js $(compiler) $(arch) $(subst \,/,"$(VERSION_FLAGS)") > version_string.ver
114-
MAKE_TBBVARS = cmd /C "$(subst /,\,$(tbb_root))\build\generate_tbbvars.bat"
113+
MAKE_VERSIONS = cmd //C cscript //nologo //E:jscript $(subst \,/,$(tbb_root))/build/version_info_windows.js $(compiler) $(arch) $(subst \,/,"$(VERSION_FLAGS)") > version_string.ver
114+
MAKE_TBBVARS = cmd //C "$(subst /,\,$(tbb_root))\build\generate_tbbvars.bat"
115115

116116
TEST_LAUNCHER = $(subst /,\,$(tbb_root))\build\test_launcher.bat $(largs)
117117

make/libraries

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ clean-sundials:
102102
# Note that the tbb targets must not be build in parallel (so no concurrent
103103
# build of tbb and tbbmalloc, for example). This is ensured here with proper
104104
# dependencies.
105-
#
106-
# On windows the mingw32-make (part of RTools, for example) is required to build
107-
# the TBB as this make has proper POSIX extensions needed by the used downstream
108-
# TBB makefiles.
109105

110106
ifndef TBB_LIB
111107

@@ -143,6 +139,13 @@ ifeq (Windows_NT, $(OS))
143139
ifeq ($(IS_UCRT),true)
144140
TBB_CXXFLAGS += -D_UCRT
145141
endif
142+
SH_CHECK := $(shell command -v sh 2>/dev/null)
143+
ifdef SH_CHECK
144+
WINDOWS_HAS_SH ?= true
145+
endif
146+
ifeq ($(WINDOWS_HAS_SH), true) # Stop TBB makefile changing SHELL on RTools
147+
SHELL = sh.exe
148+
endif
146149
endif
147150

148151
# If brackets or spaces are found in MAKE on Windows
@@ -157,12 +160,6 @@ $(TBB_BIN)/tbb-make-check:
157160
ifeq ($(OS),Windows_NT)
158161
ifneq ($(MAKE),$(MAKE_ESCAPED))
159162
$(error '$nError:$n$nThe RTools toolchain is installed in a path with spaces or brackets.$nPlease reinstall the toolchain.$n$n')
160-
else
161-
if ! [[ $(MAKE) =~ mingw32 ]]; then \
162-
echo "ERROR: Please use mingw32-make on Windows to build the Intel TBB library."; \
163-
echo "This is packaged with RTools, for example."; \
164-
exit 1; \
165-
fi
166163
endif
167164
endif
168165
@mkdir -p $(TBB_BIN)

runTests.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ def doCommand(command, exit_on_failure=True):
177177

178178
def generateTests(j):
179179
"""Generate all tests and pass along the j parameter to make."""
180-
if isWin():
181-
doCommand("mingw32-make -j%d generate-tests -s" % (j or 1))
182-
else:
183-
doCommand("make -j%d generate-tests -s" % (j or 1))
180+
doCommand("make -j%d generate-tests -s" % (j or 1))
184181

185182

186183
def divide_chunks(l, n):
@@ -238,10 +235,7 @@ def cleanupJumboTests(paths):
238235

239236
def makeTest(name, j):
240237
"""Run the make command for a given single test."""
241-
if isWin():
242-
doCommand("mingw32-make -j%d %s" % (j or 1, name))
243-
else:
244-
doCommand("make -j%d %s" % (j or 1, name))
238+
doCommand("make -j%d %s" % (j or 1, name))
245239

246240

247241
def commandExists(command):
@@ -375,7 +369,7 @@ def handleExpressionTests(tests, only_functions, n_test_files):
375369
def checkToolchainPathWindows():
376370
if isWin():
377371
p1 = subprocess.Popen(
378-
"where.exe mingw32-make",
372+
"where.exe make",
379373
stdout=subprocess.PIPE,
380374
stderr=subprocess.PIPE,
381375
universal_newlines=True,

test/sig_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import sys
77

88
if os.name == "nt": # Windows
9-
make = "mingw32-make"
9+
make = "make"
1010
exe_extension = ".exe"
1111
else:
1212
make = "make"

0 commit comments

Comments
 (0)