nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.44k stars 1.47k forks source link

GCC build error in windows msys2 GCC when enabling threads #20895

Closed 123swk123 closed 1 year ago

123swk123 commented 1 year ago

What happened?

GCC build error repr_v2.nim.c with following error details

CC: C:/Users/xxxx/.choosenim/toolchains/nim-#devel/lib/system/repr_v2.nim
C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c: In function 'reprObject__leddat82eader_1162':
C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c:1135:50: error: 'RTL_CONDITION_VARIABLE' has no member named 'ptr'; did you mean 'Ptr'?
 1135 |         colontmpD_ = repr__systemZrepr95v50_16(x.ptr);
      |                                                  ^~~
      |                                                  Ptr
Error: execution of an external compiler program 'gcc.exe -c  -w -fmax-errors=3 -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN   -IC:\Users\xxxx\.choosenim\toolchains\nim-#devel\lib -Ip:\learnings\nim\qt-nimtest-2 -o C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c.o C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c' failed with exit code: 1

Nim Version

Nim Compiler Version 1.7.3 [Windows: amd64] Compiled at 2022-11-18 Copyright (c) 2006-2022 by Andreas Rumpf

Current Standard Output Logs

nim compile --threads:on --run "p:\learnings\nim\qt-nimtest-2\leddatReader.nim"
Hint: used config file 'C:\Users\xxxx\.choosenim\toolchains\nim-#devel\config\nim.cfg' [Conf]
Hint: used config file 'C:\Users\xxxx\.choosenim\toolchains\nim-#devel\config\config.nims' [Conf]
...............................................................................................................................
p:\learnings\nim\qt-nimtest-2\configParser.nim(33, 30) Hint: 'err' is declared but not used [XDeclaredButNotUsed]
......
p:\learnings\nim\qt-nimtest-2\leddatReader.nim(141, 6) Hint: 'doTest' is declared but not used [XDeclaredButNotUsed]
p:\learnings\nim\qt-nimtest-2\leddatReader.nim(157, 6) Hint: 'doTest2' is declared but not used [XDeclaredButNotUsed]
CC: C:/Users/xxxx/.choosenim/toolchains/nim-#devel/lib/system/repr_v2.nim
C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c: In function 'reprObject__leddat82eader_1162':
C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c:1135:50: error: 'RTL_CONDITION_VARIABLE' has no member named 'ptr'; did you mean 'Ptr'?
 1135 |         colontmpD_ = repr__systemZrepr95v50_16(x.ptr);
      |                                                  ^~~
      |                                                  Ptr
Error: execution of an external compiler program 'gcc.exe -c  -w -fmax-errors=3 -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN   -IC:\Users\xxxx\.choosenim\toolchains\nim-#devel\lib -Ip:\learnings\nim\qt-nimtest-2 -o C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c.o C:\Users\xxxx\nimcache\leddatReader_d\@mC@c@sUsers@sxxxx@s.choosenim@stoolchains@snim-@hdevel@slib@ssystem@srepr_v2.nim.c' failed with exit code: 1

Expected Standard Output Logs

No response

Possible Solution

No response

Additional Information

C source code that generates this GCC compile error @ line colontmpD_ = repr__systemZrepr95v50_16(x.ptr);

N_LIB_PRIVATE N_NIMCALL(void, reprObject__leddat82eader_1162)(NimStringV2* res, RTL_CONDITION_VARIABLE x) {
    NimStringV2 colontmpD_;
    NIM_BOOL firstElement;
NIM_BOOL* nimErr_;
    nimfr_("reprObject", "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
{nimErr_ = nimErrorFlag();
    colontmpD_.len = 0; colontmpD_.p = NIM_NIL;
    nimln_(104, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    nimAddCharV1((&(*res)), 40);
    nimln_(105, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    firstElement = NIM_TRUE;
    nimln_(110, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    {
        if (!!(firstElement)) goto LA3_;
        prepareAdd((&(*res)), 2);
appendString((&(*res)), TM__bQ89bat3hUkmJB4hVh79bf4w_101);
    }
    LA3_: ;
    nimln_(112, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    prepareAdd((&(*res)), 6);
appendString((&(*res)), TM__bQ89bat3hUkmJB4hVh79bf4w_103);
    nimln_(113, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    prepareAdd((&(*res)), 2);
appendString((&(*res)), TM__bQ89bat3hUkmJB4hVh79bf4w_104);
    nimln_(116, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    colontmpD_ = repr__systemZrepr95v50_16(x.ptr);
    if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
    prepareAdd((&(*res)), colontmpD_.len + 0);
appendString((&(*res)), colontmpD_);
    nimln_(117, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    firstElement = NIM_FALSE;
    nimln_(121, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\system\\repr_v2.nim");
    nimAddCharV1((&(*res)), 41);
    nimln_(21, "C:\\Users\\xxxx\\.choosenim\\toolchains\\nim-#devel\\lib\\std\\assertions.nim");
    eqdestroy___stdZassertions_13((&colontmpD_));
    }BeforeRet_: ;
    popFrame();
}

in windows winnt.h RTL_CONDITION_VARIABLE has Ptr and not ptr

typedef struct _RTL_CONDITION_VARIABLE { PVOID Ptr; } RTL_CONDITION_VARIABLE,*PRTL_CONDITION_VARIABLE;

123swk123 commented 1 year ago

this issue does not happen with version 1.6.8

ringabout commented 1 year ago

The devel branch defaults to ORC, you should compare it with ORC on 1.6.8

123swk123 commented 1 year ago

yes you are right with ORC on 1.6.8 I get the same build error

123swk123 commented 1 year ago

as a work around I can comment out my debugs that uses repr and work on both nim versions devel &1.6.8 on 1.6.8 I'm getting runtime exception SIGSEV, but not on devel

123swk123 commented 1 year ago

works now! Thanks for the update.