I'm having some trouble compiling in release and dev mode with --gc:refc --opt:speed. I can only compile it when I disable optimization with nim c -d:release --gc:refc --opt:none myprogram.
I have tested it in combination with -d:danger, --assertions:on/off and --checks:on/off, but it makes no difference. But if I change the gc to --gc:markAndSweep, it'll compile fine. As shown in output below, the compiling takes very looong.
The only nimble installed wrapper gcc includes is nimlibxlsxwriter.
Questions:
System:
Compile output:
# Release
$ nim c -d:release -d:ssl --gc:refc myprogram
Error: execution of an external compiler program 'gcc -c -w -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter" -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter/include" -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter/include/xlsxwriter" -O3 -fno-strict-aliasing -I/home/user/.choosenim/toolchains/nim-0.20.2/lib -I/home/user//nim/myprogram -o /home/user/.cache/nim/myprogram_r/myprogram.nim.c.o /home/user/.cache/nim/myprogram_r/myprogram.nim.c' failed with exit code: 1
gcc: fatal error: Killed signal terminated program cc1
compilation terminated.
# Release danger
$ nim c -d:release -d:danger -d:ssl --gc:refc myprogram
Error: execution of an external compiler program 'gcc -c -w -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter" -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter/include" -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter/include/xlsxwriter" -O3 -fno-strict-aliasing -I/home/user/.choosenim/toolchains/nim-0.20.2/lib -I/home/user//nim/myprogram -o /home/user/.cache/nim/myprogram_r/myprogram.nim.c.o /home/user/.cache/nim/myprogram_r/myprogram.nim.c' failed with exit code: 1
gcc: fatal error: Killed signal terminated program cc1
compilation terminated.
# Release danger with disable optimization
$ nim c -d:release -d:danger -d:ssl --gc:refc --opt:none myprogram
Hint: operation successful (1522671 lines compiled; 414.037 sec total; 784.523MiB peakmem; Dangerous Release Build) [SuccessX]
# Release with disable optimization
$ nim c -d:release -d:ssl --gc:refc --opt:none myprogram
Hint: operation successful (1522671 lines compiled; 354.494 sec total; 975.84MiB peakmem; Release Build) [SuccessX]
# Release markAndSweep danger
$ nim c -d:release -d:danger -d:ssl --gc:markAndSweep myprogram
Hint: operation successful (1577789 lines compiled; 1162.975 sec total; 776.039MiB peakmem; Dangerous Release Build) [SuccessX]
# Release markAndSweep
$ nim c -d:release -d:ssl --gc:markAndSweep myprogram
Hint: operation successful (1577808 lines compiled; 1241.317 sec total; 776.383MiB peakmem; Release Build) [SuccessX]
Compile ouput:
$ nim c -d:release --parallelBuild:1 -d:ssl myprogram.nim
gcc: fatal error: Killed signal terminated program cc1
compilation terminated.
Error: execution of an external program failed: 'gcc -c -w -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter" -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter/include" -I"/home/user/.nimble/pkgs/nimlibxlsxwriter-0.1.1/nimlibxlsxwriter/include/xlsxwriter" -O3 -fno-strict-aliasing -I/home/user/.choosenim/toolchains/nim-0.20.2/lib -I/home/user/nim/myprogramFolder -o /home/user/.cache/nim/myprogram_r/myprogram.nim.c.o /home/user/.cache/nim/myprogram_r/myprogram.nim.c'
Well, it does look like, that it is the out of memory, which kills the compiling - stats below.
Any suggestion to a solution or tips to find the responsible code part?
Time - PID - CPU - MEM
17:23:35 - 3899 - 100,0 - 08,0
17:23:40 - 3899 - 99,80 - 08,0
17:23:45 - 3899 - 99,80 - 08,0
....
17:45:11 - 3899 - 100,0 - 71,0
17:45:16 - 3899 - 99,80 - 71,0
17:45:21 - 3899 - 100,0 - 71,0
17:45:26 - 3899 - 99,80 - 71,0
17:45:31 - 3899 - 100,0 - 71,0
17:45:36 - 3899 - 99,80 - 71,0
17:45:41 - 3899 - 100,0 - 71,0
17:45:46 - 3899 - 99,80 - 71,0
17:45:51 - 3899 - 99,80 - 71,0
17:45:56 - 3899 - 99,40 - 71,0
17:46:01 - 3899 - 99,80 - 71,0
17:46:06 - 3899 - 99,60 - 71,0
17:46:11 - 3899 - 100,0 - 69,4
17:46:16 - 3899 - 53,70 - 86,4
17:46:25 - 3899 - 16,20 - 85,5
17:46:31 - 3899 - 33,30 - 91,0 <-- Increase and crash
17:46:52 - 3899 - 15,20 - 06,2
I have upgraded to Nim 1.0.0 and tested my setup again. Now the compiling works fine, if I specify the compile options in my *.nim.cfg file, but if I specify them as arguments, the compilation fails.
I have inserted check in my code, to verify that it is a release build (echo defined(release)), which verify it.
I can live with updating my *.nim.cfg, but I would like to know why it happens. Any suggestions?
Case 1 - Fail
nim c -d:release myProgram
This will result in the memory crash like my posts above.
Case 2 - Success
nim c myProgram
This compiles and finishes in only ~300 sec.
Note: Putting -d:release in a nim.cfg file does not work! What -d:release means is written in the default nim.cfg and when you set it later in your config the switch has no effect.
As for the real problem: If GCC needs more memory, give it a swap file or something.
Thanks for the clarification @araq. A blunder from my side.
Besides that - this thread is now solved. By increasing my swap to 15G and using most of my 11G ram, I'm able to compile my program in 2700 seconds now. Timewise it's a problem, but then I might need to look at the amount of macros etc. in my code.