I was looking to try nmqtt with an old RPi, but I didn't managed to build it:
$ nimble install nmqtt
[...]
Installing nmqtt@#head
Building nmqtt/nmqtt/nmqtt_password using c backend
Executing /usr/bin/nim c --colors:on --noNimblePath -d:release -d:NimblePkgVersion=1.0.4 --path:/home/alarm/.nimble/pkgs/cligen-1.2.2 --path:/home/alarm/.nimble/pkgs/bcrypt-0.2.1 -o:'/tmp/nimble_958/githubcom_zevvnmqtt_#head/bin/nmqtt/nmqtt_password' '/tmp/nimble_958/githubcom_zevvnmqtt_#head/nmqtt/nmqtt_password.nim'
Hint: used config file '/etc/nim/nim.cfg' [Conf]
Hint: used config file '/etc/nim/config.nims' [Conf]
Hint: used config file '/tmp/nimble_958/githubcom_zevvnmqtt_#head/nmqtt/config.nims' [Conf]
...........................................
Hint: gcc -c -w -fmax-errors=3 -march=armv6 -mfloat-abi=hard -mfpu=vfp -O2 -pipe -fno-plt -D_FORTIFY_SOURCE=2 -O3 -fno-strict-aliasing -fno-ident -I/usr/lib/nim -I'/tmp/nimble_958/githubcom_zevvnmqtt_#head/nmqtt' -o /home/alarm/.cache/nim/nmqtt_password_r/arc4random.c.o /home/alarm/.nimble/pkgs/bcrypt-0.2.1/bcrypt/arc4random.c [Exec]
Error: Build failed for package: nmqtt
... Execution failed with exit code 137
... Command: /usr/bin/nim c --colors:on --noNimblePath -d:release -d:NimblePkgVersion=1.0.4 --path:/home/alarm/.nimble/pkgs/cligen-1.2.2 --path:/home/alarm/.nimble/pkgs/bcrypt-0.2.1 -o:'/tmp/nimble_958/githubcom_zevvnmqtt_#head/bin/nmqtt/nmqtt_password' '/tmp/nimble_958/githubcom_zevvnmqtt_#head/nmqtt/nmqtt_password.nim'
It looks like I am running out of memory. Is there anything that I can do to avoid this error? (other than buying a new one! ;oP)
Just for the record, I am trying:
nim --cpu:arm --cc:clang --clang.exe="zig cc" --zig.options.linker: "-target arm-linux-musleabihf" --zig.options.always: "-target arm-linux-musleabihf" c alarma.nim
but it looks I am hitting the same problem:
CC: stdlib_assertions.nim
CC: stdlib_dollars.nim
CC: stdlib_formatfloat.nim
/bin/sh: zig cc: orden no encontrada
CC: stdlib_io.nim
/bin/sh: zig cc: orden no encontrada
CC: stdlib_system.nim
/bin/sh: zig cc: orden no encontrada
CC: stdlib_math.nim
/bin/sh: zig cc: orden no encontrada
/bin/sh: zig cc: orden no encontrada
CC: stdlib_strutils.nim
CC: stdlib_posix.nim
/bin/sh: zig cc: orden no encontrada
Error: execution of an external compiler program ''zig cc' -c -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -o /home/jose/.cache/nim/alarma_d/stdlib_assertions.nim.c.o /home/jose/.cache/nim/alarma_d/stdlib_assertions.nim.c' failed with exit code: 127
but I saw Araq saying it wasn't Nim fault.
Any work around?
Thank both. For the sake of learning, I am trying the cross compilation route. Now I am having the following error:
$ env PATH=.:$PATH nim --cpu:arm --cc:clang --clang.exe="zigcc" --zig.options.linker: "-target arm-linux-musleabihf" --zig.options.always: "-target arm-linux-musleabihf" c alarma.nim
Hint: used config file '/home/jose/.choosenim/toolchains/nim-1.2.6/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: alarma [Processing]
Hint: nmqtt [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: macros [Processing]
Hint: algorithm [Processing]
Hint: unicode [Processing]
Hint: asyncnet [Processing]
Hint: asyncdispatch [Processing]
Hint: os [Processing]
Hint: pathnorm [Processing]
Hint: osseps [Processing]
Hint: posix [Processing]
Hint: times [Processing]
Hint: options [Processing]
Hint: typetraits [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: heapqueue [Processing]
Hint: asyncstreams [Processing]
Hint: asyncfutures [Processing]
Hint: deques [Processing]
Hint: cstrutils [Processing]
Hint: monotimes [Processing]
Hint: nativesockets [Processing]
Hint: net [Processing]
Hint: sets [Processing]
Hint: ssl_certs [Processing]
Hint: ospaths [Processing]
Hint: selectors [Processing]
Hint: epoll [Processing]
/home/jose/.nimble/pkgs/nmqtt-1.0.4/nmqtt.nim(1029, 11) Warning: observable stores to ':envP.pkt7' [ObservableStores]
CC: stdlib_assertions.nim
CC: stdlib_dollars.nim
CC: stdlib_formatfloat.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: stdlib_math.nim
CC: stdlib_strutils.nim
CC: stdlib_posix.nim
In file included from /home/jose/.cache/nim/alarma_d/stdlib_assertions.nim.c:10:
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a In file included from /home/jose/.cache/nim/alarma_d/stdlib_dollars.nim.c:negative size
10:
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
In file included from /home/jose/.cache/nim/alarma_d/stdlib_formatfloat.nim.c:10:
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/CgGvqzEnU14s-stdlib_assertions.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/CgGvqzEnU14s-stdlib_assertions.nim.o /home/jose/.cache/nim/alarma_d/stdlib_assertions.nim.c
Error: execution of an external compiler program 'zigcc -c -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -o /home/jose/.cache/nim/alarma_d/stdlib_assertions.nim.c.o /home/jose/.cache/nim/alarma_d/stdlib_assertions.nim.c' failed with exit code: 1
In file included from /home/jose/.cache/nim/alarma_d/stdlib_system.nim.c:10:
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/RZkv6Lfzr5T4-stdlib_dollars.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/RZkv6Lfzr5T4-stdlib_dollars.nim.o /home/jose/.cache/nim/alarma_d/stdlib_dollars.nim.c
[jose@mountain mqtt]$ 1 error generated.
In file included from /home/jose/.cache/nim/alarma_d/stdlib_math.nim.c:10:
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/jose/.cache/nim/alarma_d/stdlib_strutils.nim.c:10:
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/hG9uiOeIJ9y7-stdlib_formatfloat.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/hG9uiOeIJ9y7-stdlib_formatfloat.nim.o /home/jose/.cache/nim/alarma_d/stdlib_formatfloat.nim.c
In file included from /home/jose/.cache/nim/alarma_d/stdlib_io.nim.c:10:
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/h__18jO4p2Gq-stdlib_math.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/h__18jO4p2Gq-stdlib_math.nim.o /home/jose/.cache/nim/alarma_d/stdlib_math.nim.c
In file included from /home/jose/.cache/nim/alarma_d/stdlib_posix.nim.c:10:
/home/jose/.choosenim/toolchains/nim-1.2.6/lib/nimbase.h:522:64: error: 'Nim_and_C_compiler_disagree_on_target_architecture' declared as an array with a negative size
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/pt9uu3gAhiaK-stdlib_posix.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/pt9uu3gAhiaK-stdlib_posix.nim.o /home/jose/.cache/nim/alarma_d/stdlib_posix.nim.c
1 error generated.
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/zAEW6qt9SUQ8-stdlib_io.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/zAEW6qt9SUQ8-stdlib_io.nim.o /home/jose/.cache/nim/alarma_d/stdlib_io.nim.c
1 error generated.
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/pM99c74AGEAn-stdlib_strutils.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/pM99c74AGEAn-stdlib_strutils.nim.o /home/jose/.cache/nim/alarma_d/stdlib_strutils.nim.c
1 error generated.
The following command failed:
/usr/bin/zig clang -c -nostdinc -fno-spell-checking -target x86_64-unknown-linux-gnu -isystem /usr/lib/zig/include -isystem /usr/lib/zig/libc/include/x86_64-linux-gnu -isystem /usr/lib/zig/libc/include/generic-glibc -isystem /usr/lib/zig/libc/include/x86_64-linux-any -isystem /usr/lib/zig/libc/include/any-linux-any -Xclang -target-cpu -Xclang haswell -Xclang -target-feature -Xclang -3dnow,-3dnowa,+64bit,-adx,+aes,+avx,+avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,+bmi,+bmi2,-branchfusion,-cldemote,-clflushopt,-clwb,-clzero,+cmov,+cx16,+cx8,-enqcmd,+ermsb,+f16c,+false-deps-lzcnt-tzcnt,+false-deps-popcnt,-fast-11bytenop,-fast-15bytenop,-fast-bextr,-fast-gather,-fast-hops,-fast-lzcnt,+fast-scalar-fsqrt,-fast-scalar-shift-masks,+fast-shld-rotate,+fast-variable-shuffle,-fast-vector-fsqrt,-fast-vector-shift-masks,+fma,-fma4,+fsgsbase,+fxsr,-gfni,-idivl-to-divb,+idivq-to-divl,+invpcid,-lea-sp,-lea-uses-ag,-lwp,+lzcnt,+macrofusion,+merge-to-threeway-branch,+mmx,+movbe,-movdir64b,-movdiri,-mpx,-mwaitx,+nopl,-pad-short-functions,+pclmul,-pconfig,-pku,+popcnt,-prefer-128-bit,-prefer-256-bit,-prefer-mask-registers,-prefetchwt1,-prfchw,-ptwrite,-rdpid,+rdrnd,-rdseed,-retpoline,-retpoline-external-thunk,-retpoline-indirect-branches,-retpoline-indirect-calls,-rtm,+sahf,-sgx,-sha,-shstk,+slow-3ops-lea,-slow-incdec,-slow-lea,-slow-pmaddwd,-slow-pmulld,-slow-shld,-slow-two-mem-ops,-slow-unaligned-mem-16,-slow-unaligned-mem-32,-soft-float,+sse,-sse-unaligned-mem,+sse2,+sse3,+sse4.1,+sse4.2,-sse4a,+ssse3,-tbm,-use-aa,-use-glm-div-sqrt-costs,-vaes,-vpclmulqdq,+vzeroupper,-waitpkg,-wbnoinvd,+x87,-xop,+xsave,-xsavec,+xsaveopt,-xsaves -MD -MV -MF zig-cache/tmp/vynAQbyobhby-stdlib_system.nim.o.d -fno-omit-frame-pointer -fsanitize=undefined -fsanitize-trap=undefined -D_DEBUG -Og -fstack-protector-strong --param ssp-buffer-size=4 -fPIC -w -I/home/jose/.choosenim/toolchains/nim-1.2.6/lib -I/home/jose/src/mqtt -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -o zig-cache/tmp/vynAQbyobhby-stdlib_system.nim.o /home/jose/.cache/nim/alarma_d/stdlib_system.nim.c
Sorry for unburying this from the death. But I was trying again to crosscompile in Linux x64 with the target armv6 and I got the same issue (no surprise I guess).
From the wording of the error it looks like Nim and Zig disagrees on how the target architecture is defined.
If my understanding is correct, the following in nimbase.h:
typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
results in an array of negative size.
Why is that? Is it a problem in Nim or Zig?
I'm not very familiar with arm names etc. But if I recall correctly (one of) this builds did run on my pi 2:
It fails during the compilation phase. I would expect that to fail during the execution phase.
Nonetheless, I tried adding
$ nim c --cc:clang --os:linux --clang.exe="zigcc" --clang.linkerexe="zigcc" --passC:"-target arm-linux-gnueabihf -mfloat-abi=soft" --passL:"-target arm-linux-gnueabihf" alarma.nim
...
In file included from In file included from /home/jose/.cache/nim/alarma_d/@m..@s..@[email protected]@[email protected]@slib@[email protected]:7:
/home/jose/.choosenim/toolchains/nim-1.6.10/lib/nimbase.h:550:1: error: static assertion failed due to requirement 'sizeof(long long) == sizeof(void *) && 64 == sizeof(long long) * 8':
NIM_STATIC_ASSERT(sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8, "");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
Given it is the following what is failing: https://github.com/nim-lang/Nim/blob/v1.6.10/lib/nimbase.h#L549_L550
my question is: is this assertion valid in cross-compilation situation? If not, do I have any mean to deactive them?
Finally it compiled!!
nim c --cpu:arm --os:linux --cc:clang --os:linux --clang.exe="zigcc" --clang.linkerexe="zigcc" --passC:"-target arm-linux-musleabihf -mfloat-abi=soft" --passL:"-target arm-linux-musleabihf" alarma.nim
Later I will check if it actually works in the RPi1.
Sadly not working.
It looks like the target shall be arm-linux-muslabi instead of arm-linux-muslabihf`(that `hf at the end seems to refer to hardware float).
It looks also that zig might not be managing properlly some flags:
So it might be that zig might not be receiving the flags it needs to precisely compile for armv6.
is this assertion valid in cross-compilation situation?
I think so, yes.
I managed to make it work with the following line:
nim c --cpu:arm --os:linux --cc:clang --os:linux --clang.exe="zigcc" --clang.linkerexe="zigcc" --passC:"-target arm-linux-musleabi -mcpu=arm1176jzf_s -fno-sanitize=undefined" --passL:"-target arm-linux-musleabi -mcpu=arm1176jzf_s" alarma.nim
If somebody else reach this thread, don't forget to do first:
nimble install zigcc