Hi there,
Some time ago I found zig lang. It also can be used as C compiler, so I thought that it would be great to try it with Nim.
Anyone tried to use zig as c compiler for nim? Could you provide compilation steps?
I used nim c hi.nim and tried to use generated c code with zig, but c code generated by nim has some parts that zig c compiler complains about. I removed the comments and some lines he pointed me to, but I don't want to destroy the file.
Thank you
I hope to try and come back at some point in future, but don't suspect this to be soon. As to compiler's complaints, try your luck at asking on Zig's IRC and/or reporting on their github, Andrew Kelley seems to listen and be very open to discussion and helping, though he also has a lot to do, so I'd say your chances are maybe kinda 50/50?
Hi there, Recently I've found that in Nim devel branch there have been added support for zig compiler.
So i decided to give it another try. On Nim IRC I found that one of the users was able to compile to arm with
./nim_1_1_1/bin/nim --cpu:arm -d:danger --cc:zig --passC:"-target arm-linux-musleabi" --passL:"-target arm-linux-musleabi" c ./hi.nim
It also works for me, but then i tried to use different target:
./nim_1_1_1/bin/nim --cpu:amd64 -d:danger --cc:zig --passC:"-target x86_64-linux-musl" --passL:"-target x86_64-linux-musl" c ./hi.nim
It gives me huge log which I cut for clarity:
..[seba@sebapc Pobrane]$ ./nim_1_1_1/bin/nim --cpu:amd64 -d:danger --cc:zig --passC:"-target x86_64-linux-musl" --passL:"-target x86_64-linux-musl" c ./hi.nim Hint: used config file '/home/seba/Pobrane/nim_1_1_1/config/nim.cfg' [Conf] Hint: system [Processing] Hint: widestrs [Processing] Hint: io [Processing] Hint: hi [Processing] CC: stdlib_io.nim CC: stdlib_system.nim Compile C Objects [1/1] Compile C Objects [1/1] /home/seba/.cache/nim/hi_r/stdlib_system.nim.c:431:27: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] static N_INLINE(NIM_BOOL, nimMulInt)(NI a, NI b, NI* res); 4 warnings and 11 errors generated.
The following command failed:
Error: execution of an external compiler program 'zig cc -c -target x86_64-linux-musl -O3 -fno-ident -I/home/seba/Pobrane/nim_1_3_1/lib -I/home/seba/Pobrane -o /home/seba/.cache/nim/hi_r/stdlib_system.nim.c.o /home/seba/.cache/nim/hi_r/stdlib_system.nim.c' failed with exit code: 1..
What am I doing wrong? How should I fix it? Thank you