Skip to content

Commit d0dc13e

Browse files
authored
v.builder: bump the default stack size for executables, when compiling with msvc on windows, to 32MB (#25824)
1 parent 8147388 commit d0dc13e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

make.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ if exist "%InstallDir%/Common7/Tools/vsdevcmd.bat" (
214214
set ObjFile=.v.c.obj
215215

216216
echo ^> Attempting to build "%V_BOOTSTRAP%" (from v_win.c) with MSVC
217-
cl.exe /volatile:ms /Fo%ObjFile% /W0 /MD /D_VBOOTSTRAP /F 16777216 "vc/v_win.c" user32.lib kernel32.lib advapi32.lib shell32.lib ws2_32.lib /link /nologo /out:"%V_BOOTSTRAP%" /incremental:no
217+
cl.exe /volatile:ms /Fo%ObjFile% /W0 /MD /D_VBOOTSTRAP /F33554432 "vc/v_win.c" user32.lib kernel32.lib advapi32.lib shell32.lib ws2_32.lib /link /nologo /out:"%V_BOOTSTRAP%" /incremental:no
218218
if %ERRORLEVEL% NEQ 0 (
219219
echo In some cases, compile errors happen because of the MSVC compiler version
220220
cl.exe

vlib/v/builder/msvc_windows.v

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,10 @@ pub fn (mut v Builder) cc_msvc() {
277277
// `-w` no warnings
278278
// `/we4013` 2 unicode defines, see https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4013?redirectedfrom=MSDN&view=msvc-170
279279
// `/volatile:ms` enables atomic volatile (gcc _Atomic)
280-
// `/F 16777216` changes the stack size to 16MB, see https://docs.microsoft.com/en-us/cpp/build/reference/f-set-stack-size?view=msvc-170
281-
a << ['-w', '/we4013', '/volatile:ms', '/F 16777216']
280+
// `/F33554432` changes the stack size to 32MB, see https://docs.microsoft.com/en-us/cpp/build/reference/f-set-stack-size?view=msvc-170
281+
// Note: passing `/FNUMBER` is preferable to `/F NUMBER` for unix shells like bash or in cygwin, that otherwise may treat the `/F` as a folder,
282+
// if there is an F: drive in the system (they map c: as /c/, d: as /d/ etc)
283+
a << ['-w', '/we4013', '/volatile:ms', '/F33554432']
282284
if v.pref.is_prod && !v.pref.no_prod_options {
283285
a << '/O2'
284286
}
@@ -387,7 +389,7 @@ pub fn (mut v Builder) cc_msvc() {
387389
a << v.pref.ldflags.trim_space()
388390
}
389391
v.dump_c_options(a)
390-
args := '\xEF\xBB\xBF' + a.join(' ')
392+
args := '\xEF\xBB\xBF' + a.join(' ') // write a BOM to indicate the utf8 encoding of the file
391393
// write args to a file so that we dont smash createprocess
392394
os.write_file(out_name_cmd_line, args) or {
393395
verror('Unable to write response file to "${out_name_cmd_line}"')

0 commit comments

Comments
 (0)