Skip to content

Conversation

ringabout
Copy link
Member

revert #19891
ref #19957

It causes regression on 1.6.8 for mingw 32-bit + clang (msvc) on Windows

I'm looking into it.

cc @Menduist

In parallel, we've been running nimbus with this flag enabled since it was merged without issues

It seems to cause problems for stew; ref status-im/nim-stew#133

@ringabout ringabout marked this pull request as draft November 5, 2022 02:27
@ringabout ringabout changed the title revert https://github.com/nim-lang/Nim/pull/19891 revert #19891; nimRawSetjmp causes problems for mingw 32 bits too Nov 5, 2022
@rockcavera
Copy link
Contributor

What's the problem?

@ringabout
Copy link
Member Author

Here you are https://discord.com/channels/371759389889003530/371759389889003532/1038271070995763202

just trying to compile a simple hello world app fails on 1.6.8 / 32-bit on windows
while it works fine with 1.6.6
the error

image

@Menduist
Copy link
Contributor

Menduist commented Nov 8, 2022

This seemed to at least fix some of the weird bugs we had with mingw-w64, but it was indeed enabled too broadly
(is _setjmp with two parameters only available on mingw-w64?)

Maybe we could try to enable it only when it's available, or just revert it.

@rockcavera
Copy link
Contributor

@ringabout, I was unable to reproduce the error. I downloaded Nim 1.6.8 x86 and mingw32 from Nim's website, but I still can't reproduce the error with mingw32.

Any possibility that he downloaded a mingw32 compiler different from the one available on the site?

@ringabout
Copy link
Member Author

Any possibility that he downloaded a mingw32 compiler different from the one available on the site?

I don't know the details. Probably.

@rockcavera
Copy link
Contributor

One way to force such an error using mingw32 available on Nim's website is to pass -DUSE_NO_MINGW_SETJMP_TWO_ARGS

nim r -f --passC:-DUSE_NO_MINGW_SETJMP_TWO_ARGS test
Hint: used config file 'E:\oNim\nim-1.6.8\config\nim.cfg' [Conf]
Hint: used config file 'E:\oNim\nim-1.6.8\config\config.nims' [Conf]
.........................................................
CC: E:/oNim/nim-1.6.8/lib/system/ansi_c.nim
CC: E:/oNim/nim-1.6.8/lib/std/private/digitsutils.nim
CC: E:/oNim/nim-1.6.8/lib/system/dollars.nim
CC: E:/oNim/nim-1.6.8/lib/system/io.nim
CC: E:/oNim/nim-1.6.8/lib/system.nim
CC: test.nim
E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem@sansi_c.nim.c: In function 'c_setjmp__systemZansi95c_42':
E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem@sansi_c.nim.c:27:18: error: too many arguments to function '_setjmp'
   27 |         result = _setjmp(jmpb, NIM_NIL);
      |                  ^~~~~~~
In file included from E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem@sansi_c.nim.c:8:
e:\compilers\mingw32\i686-w64-mingw32\include\setjmp.h:267:63: note: declared here
  267 |   int __cdecl __attribute__ ((__nothrow__,__returns_twice__)) setjmp(jmp_buf _Buf);
      |                                                               ^~~~~~
Error: execution of an external compiler program 'E:\compilers\mingw32\bin\gcc.exe -c  -w -fmax-errors=3 -mno-ms-bitfields -DUSE_NO_MINGW_SETJMP_TWO_ARGS   -IE:\oNim\nim-1.6.8\lib -IC:\Users\josep\desktop -o E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem@sansi_c.nim.c.o E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem@sansi_c.nim.c' failed with exit code: 1



C:\Users\josep\desktop>E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem.nim.c: In function 'showErrorMessage__system_2538':
E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem.nim.c:4415:58: error: too many arguments to function '_setjmp'
 4415 |                 TM__Q5wkpxktOdTGvlSRo9bzt9aw_26.status = _setjmp(TM__Q5wkpxktOdTGvlSRo9bzt9aw_26.context, 0);
      |                                                          ^~~~~~~
In file included from E:\nimcache\test_d\@mE@c@soNim@snim-1.6.8@slib@ssystem.nim.c:9:
e:\compilers\mingw32\i686-w64-mingw32\include\setjmp.h:267:63: note: declared here
  267 |   int __cdecl __attribute__ ((__nothrow__,__returns_twice__)) setjmp(jmp_buf _Buf);
      |                                                               ^~~~~~
nim -v
Nim Compiler Version 1.6.8 [Windows: i386]
Compiled at 2022-09-27
Copyright (c) 2006-2021 by Andreas Rumpf

active boot switches: -d:release

Still the lines from setjmp.h don't match my error with the screenshot error.

@rockcavera
Copy link
Contributor

rockcavera commented Nov 11, 2022

I discovered the problem. User is using mingw from "original" project https://mingw.osdn.io/

Even the setjmp.h file of this project matches the line that the gcc compiler claimed in the user image.

It is now up to the Nim team to recommend only mingw32 from the Mingw-w64 project or revert

@ringabout ringabout marked this pull request as ready for review November 11, 2022 07:40
@ringabout ringabout changed the title revert #19891; nimRawSetjmp causes problems for mingw 32 bits too revert #19891; nimRawSetjmp causes problems for mingw 32 bits too [backport] Nov 11, 2022
@Araq Araq merged commit d17b1d4 into devel Nov 11, 2022
@Araq Araq deleted the ringabout-patch-2 branch November 11, 2022 07:42
@ringabout
Copy link
Member Author

@narimiran backport please, thanks!

@github-actions
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from d17b1d4

Hint: mm: orc; opt: speed; options: -d:release
165054 lines; 7.948s; 614.18MiB peakmem

narimiran pushed a commit that referenced this pull request Nov 11, 2022
capocasa pushed a commit to capocasa/Nim that referenced this pull request Mar 31, 2023
bung87 pushed a commit to bung87/Nim that referenced this pull request Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants