Compilation with vcc or clang (msvc) on Windows fails by using `nimRawSetjmp`
Closed this issue · 5 comments
This error only happens with clang msvc compiler. In the clang gnu compiler this does not happen. The default LLVM installer for Windows is msvc.
Example
# test.nim
echo "test"
Current Output
nim c --cc:clang test
Hint: used config file 'D:\Nim\config\nim.cfg' [Conf]
Hint: used config file 'D:\Nim\config\config.nims' [Conf]
.........................................................
CC: D:/Nim/lib/system/ansi_c.nim
CC: D:/Nim/lib/std/private/digitsutils.nim
CC: D:/Nim/lib/system/dollars.nim
CC: D:/Nim/lib/std/syncio.nim
CC: D:/Nim/lib/system.nim
CC: test.nim
C:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem@sansi_c.nim.c:27:25: error: too many arguments to function call,
expected single argument '_Buf', have 2 arguments
result = _setjmp(jmpb, NIM_NIL);
~~~~~~~ ^~~~~~~
D:\Nim\lib\nimbase.h:350:19: note: expanded from macro 'NIM_NIL'
# define NIM_NIL ((void*)0) /* C's NULL is fucked up in some C compilers, so
^~~~~~~~~~
1 error generated.
Error: execution of an external compiler program 'D:\compilers\LLVM64\bin\clang.exe -c -w -ferror-limit=3 -ID:\Nim\lib -IC:\Users\josep\Desktop -o C:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem@sansi_c.nim.c.o C:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem@sansi_c.nim.c' failed with exit code: 1
C:\Users\josep\Desktop>C:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem.nim.c:4448:93: error: too many arguments to function call,
expected single argument '_Buf', have 2 arguments
TM__Q5wkpxktOdTGvlSRo9bzt9aw_26.status = _setjmp(TM__Q5wkpxktOdTGvlSRo9bzt9aw_26.context, 0);
~~~~~~~ ^
1 error generated.
Expected Output
Compile without error.
Additional Information
nim -v
Nim Compiler Version 1.7.1 [Windows: amd64]
Compiled at 2022-07-01
Copyright (c) 2006-2022 by Andreas Rumpf
git hash: ce4078acd40bb27de5d05832f486dbc95918a3c9
active boot switches: -d:release
@rockcavera Hello, could you try not defined(clang) or clang_cl here => https://github.com/nim-lang/Nim/pull/19899/files
@rockcavera Hello, could you try not defined(clang) or clang_cl here => https://github.com/nim-lang/Nim/pull/19899/files
I tried and the error persists.
The problem also happens with the vcc compiler:
nim c --cc:vcc test
Hint: used config file 'D:\Nim\config\nim.cfg' [Conf]
Hint: used config file 'D:\Nim\config\config.nims' [Conf]
.........................................................
CC: D:/Nim/lib/std/private/digitsutils.nim
CC: D:/Nim/lib/system/dollars.nim
CC: D:/Nim/lib/std/syncio.nim
CC: D:/Nim/lib/system.nim
CC: test.nim
@mD@c@sNim@slib@sstd@sprivate@sdigitsutils.nim.c
@mtest.nim.c
@mD@c@sNim@slib@ssystem@sdollars.nim.c
@mD@c@sNim@slib@sstd@ssyncio.nim.c
@mD@c@sNim@slib@ssystem.nim.c
C:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem.nim.c(4559): warning C4020: '_setjmp': muitos parâmetros reais
C:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem.nim.c(4559): error C2167: '_setjmp': muitos parâmetros reais para função intrínseca
Error: execution of an external compiler program 'vccexe.exe /c --platform:amd64 /nologo /ID:\Nim\lib /IC:\Users\josep\Desktop /nologo /FoC:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem.nim.c.obj C:\Users\josep\nimcache\test_d\@mD@c@sNim@slib@ssystem.nim.c' failed with exit code: 2
I fixed the problem with vcc.
The problem with clang can be fixed as well. But the variation between clang msvc or gnu complicates a bit. The clang-cl I'm not sure would be the msvc abi.
The biggest problem with clang on Windows is that the default target is msvc in the installer available for download from the llvm website. So much so that for this, to differentiate the msvc and gnu clang, I did it here. You will only use clang-cl if you want some msvc cl option.