zevv / nim-arduino

Trying to get Nim integrated into arduino IDE
54 stars 2 forks source link

Doesn't work on native Windows #2

Open adokitkat opened 4 years ago

adokitkat commented 4 years ago

OS: Windows 10 Nim: devel 1.3.5 (git hash: 8a004e2fc07c87b8308c3c03e4448372a2094383) Arduino: 1.8.13

I followed the instructions but I cannot get this to work on my machine. The error message is about AVR compiler but I did compile normal Arduino sketches before. The path to the compiler is "wrong" - the problem is a space in the path.

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ado\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path C:\Users\Ado\AppData\Local\Temp\arduino_build_717971 -warnings=default -build-cache C:\Users\Ado\AppData\Local\Temp\arduino_cache_771324 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ado\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino

C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ado\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path C:\Users\Ado\AppData\Local\Temp\arduino_build_717971 -warnings=default -build-cache C:\Users\Ado\AppData\Local\Temp\arduino_cache_771324 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ado\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino

Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

Detecting libraries used...

nim_arduino macros "--nimflags=\"--cpu:avr" --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger "-d:useMalloc\"" "--compiler=\"C:\\Program" Files "(x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++\"" "--cppflags=\"-c" -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard\"" "--input=\"C:\\Users\\Ado\\AppData\\Local\\Temp\\arduino_build_717971\\sketch\\sketch_aug21a.ino.cpp\"" "--output=\"nul\"" -DARDUINO_LIB_DISCOVERY_PHASE

>>> macros --nimflags="--cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc" --compiler="C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" --cppflags="-c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" --input="C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\sketch_aug21a.ino.cpp" --output="nul" -DARDUINO_LIB_DISCOVERY_PHASE

>>> nim cpp -c --nimcache:C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\nimcache --cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\sketch.nim

>>> C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-1.2.6\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\nimcache\@mD@c@sPlayground@sNim@sGit@snim-arduino@ssrc@sarduino.nim.cpp

>>> Error running command

avr-g++: error: Files: No such file or directory

Error while detecting libraries included by C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\sketch_aug21a.ino.cpp

Generating function prototypes...

nim_arduino macros "--nimflags=\"--cpu:avr" --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger "-d:useMalloc\"" "--compiler=\"C:\\Program" Files "(x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++\"" "--cppflags=\"-c" -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard\"" "--input=\"C:\\Users\\Ado\\AppData\\Local\\Temp\\arduino_build_717971\\sketch\\sketch_aug21a.ino.cpp\"" "--output=\"C:\\Users\\Ado\\AppData\\Local\\Temp\\arduino_build_717971\\preproc\\ctags_target_for_gcc_minus_e.cpp\"" -DARDUINO_LIB_DISCOVERY_PHASE

>>> macros --nimflags="--cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc" --compiler="C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" --cppflags="-c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" --input="C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\sketch_aug21a.ino.cpp" --output="C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\preproc\ctags_target_for_gcc_minus_e.cpp" -DARDUINO_LIB_DISCOVERY_PHASE

>>> nim cpp -c --nimcache:C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\nimcache --cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\sketch.nim

>>> C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-1.2.6\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\nimcache\@mD@c@sPlayground@sNim@sGit@snim-arduino@ssrc@sarduino.nim.cpp

>>> Error running command

avr-g++: error: Files: No such file or directory

exit status 1

Error compiling for board Arduino Uno.

So I tried to modify the source so it generates proper paths but now there is a new problem... This time it is OSerror in Nim. osproc.startProcess() procedure doesn't work with this new string.

Look at the Additional info - everything has escape backslashes - also I don't get this "Error: unhandled exception: Access is denied.", maybe I don't have privileges for some reason? Running commands like "cmd" and args "/c", ... works tho.

>>> C:\"Program Files (x86)"\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\cores\arduino -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-#devel\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\nimcache\@m..@s..@s..@s..@s..@s.nimble@spkgs@sarduino-0.1.0@sarduino.nim.cpp
Error while detecting libraries included by C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\sketch_aug21a.ino.cpp
Generating function prototypes...

...

>>> C:\"Program Files (x86)"\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\cores\arduino -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-#devel\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\nimcache\@m..@s..@s..@s..@s..@s.nimble@spkgs@sarduino-0.1.0@sarduino.nim.cpp
oserr.nim(94)            raiseOSError
Error: unhandled exception: Access is denied.
Additional info: "C:\\\"Program Files (x86)\"\\Arduino\\hardware\\tools\\avr\\bin\\avr-g++" [OSError]
exit status 1
Error compiling for board Arduino Uno.

However, if I run this code below in Powershell, it works and generates C code into STDOUT.

C:\"Program Files (x86)"\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\cores\arduino -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-#devel\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_717971\sketch\nimcache\@m..@s..@s..@s..@s..@s.nimble@spkgs@sarduino-0.1.0@sarduino.nim.cpp
zevv commented 4 years ago

Yeah, I recently found out this is a problem. I'm not yet sure if and how this can be fixed, as I'm pretty much limited by the way I can get arduino studio to pass options into the "fake" c compiler which is actually the Nim compiler. I will look into this some more.

adokitkat commented 4 years ago

I also tried to run the commands via cmd /c "compiler path" other_arguments but somehow I didn't pass arguments correctly I assume (again the space was the source of this problem) so it doesn't work for now either. However if the arguments were somehow passed correctly, then it could work this way.

Temporary fix also could be having avr-g++ in path and invoking it directly.

EDIT1: Ok, so I maybe got it to work - partly - by adding the folder with compiler to path, restarting PC, and changing the source a little. How long does it takes to compile a Nim program in Arduino IDE? Because it may now just stuck... avr-g++.exe and also arduino-builder.exe is running in Task Manager, but compilation seems to be stuck.

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ado\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path C:\Users\Ado\AppData\Local\Temp\arduino_build_505416 -warnings=default -build-cache C:\Users\Ado\AppData\Local\Temp\arduino_cache_607875 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ado\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ado\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path C:\Users\Ado\AppData\Local\Temp\arduino_build_505416 -warnings=default -build-cache C:\Users\Ado\AppData\Local\Temp\arduino_cache_607875 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ado\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino
Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
nim_arduino macros "--nimflags=\"--cpu:avr" --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger "-d:useMalloc\"" "--compiler=\"C:\\Program" Files "(x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++\"" "--cppflags=\"-c" -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard\"" "--input=\"C:\\Users\\Ado\\AppData\\Local\\Temp\\arduino_build_505416\\sketch\\sketch_aug21a.ino.cpp\"" "--output=\"nul\"" -DARDUINO_LIB_DISCOVERY_PHASE
>>> macros --nimflags="--cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc" --compiler="C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" --cppflags="-c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" --input="C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\sketch_aug21a.ino.cpp" --output="nul" -DARDUINO_LIB_DISCOVERY_PHASE
>>> nim cpp -c --nimcache:C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\nimcache --cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\sketch.nim
>>> avr-g++.exe -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\cores\arduino -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-#devel\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\nimcache\@mD@c@sPlayground@sNim@sGit@snim-arduino@ssrc@sarduino.nim.cpp

This is my changed proc run() from _nimarduino.nim:

proc run(cmd: string, args: seq[string]): string =

  var command = cmd
  var tmp_join = ""
  var tmp_args : seq[string]
  var new_args : seq[string]

  command = command.replace("Program Files (x86)", "\"Program Files (x86)\"").replace("/", "\\")

  for arg in args:
    if "Program" in arg:
      tmp_join = arg & " "
      continue

    if "Files" in arg:
      tmp_join &= arg & " "
      continue

    if "(x86)" in arg:
      tmp_join &= arg 
      tmp_args.add tmp_join
    else:
      tmp_args.add arg

  for arg in tmp_args:
    var new_arg = arg.replace("Program", "\"Program").replace("(x86)", "(x86)\"")
    new_args.add new_arg

  if "avr-g++" in command:
    command = "avr-g++.exe"

  dbg command & " " & new_args.join(" ")

  let p = startProcess(command, args=new_args, options={poUsePath,poStdErrToStdOut})
  let o = p.outputStream.readAll()
  let rv = p.waitForExit()
  p.close()
  if rv != 0:
    err "Error running command\n" & o
  result = o

EDIT2: So after terminating the avr-g++.exe process I got an output like this. It seems like something was happening but CPU usage by this process was 0. Also I don't think it would be so slow...

>>> avr-g++.exe -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\cores\arduino -IC:\"Program Files (x86)"\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-#devel\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\nimcache\@mD@c@sPlayground@sNim@sGit@snim-arduino@ssrc@sarduino.nim.cpp
>>> Error running command
# 1 "C:\\Users\\Ado\\AppData\\Local\\Temp\\arduino_build_505416\\sketch\\nimcache\\@mD@c@sPlayground@sNim@sGit@snim-arduino@ssrc@sarduino.nim.cpp"
# 1 "C:\\Program Files (x86)\\Arduino//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "C:\\Users\\Ado\\AppData\\Local\\Temp\\arduino_build_505416\\sketch\\nimcache\\@mD@c@sPlayground@sNim@sGit@snim-arduino@ssrc@sarduino.nim.cpp"
/* Generated by Nim Compiler v1.3.5 */
/*   (c) 2020 Andreas Rumpf */
/* The generated code is subject to the original license. */

/* section: NIM_merge_HEADERS */

# 1 "C:\\Users\\Ado\\.choosenim\\toolchains\\nim-#devel\\lib/nimbase.h" 1
/*

            Nim's Runtime Library

        (c) Copyright 2015 Andreas Rumpf

    See the file "copying.txt", included in this

    distribution, for details about the copyright.

*/
# 10 "C:\\Users\\Ado\\.choosenim\\toolchains\\nim-#devel\\lib/nimbase.h"
/* compiler symbols:

__BORLANDC__

_MSC_VER

__WATCOMC__

__LCC__

__GNUC__

__DMC__

__POCC__

__TINYC__

__clang__

__AVR__

*/
# 27 "C:\\Users\\Ado\\.choosenim\\toolchains\\nim-#devel\\lib/nimbase.h"
/*------------ declaring a custom attribute to support using LLVM's Address Sanitizer ------------ */

/*

   This definition exists to provide support for using the LLVM ASAN (Address SANitizer) tooling with Nim. This

   should only be used to mark implementations of the GC system that raise false flags with the ASAN tooling, or

   for functions that are hot and need to be disabled for performance reasons. Based on the official ASAN

   documentation, both the clang and gcc compilers are supported. In addition to that, a check is performed to

   verify that the necessary attribute is supported by the compiler.

   To flag a proc as ignored, append the following code pragma to the proc declaration:

      {.codegenDecl: "CLANG_NO_SANITIZE_ADDRESS $# $#$#".}

   For further information, please refer to the official documentation:

     https://github.com/google/sanitizers/wiki/AddressSanitizer

 */
# 51 "C:\\Users\\Ado\\.choosenim\\toolchains\\nim-#devel\\lib/nimbase.h"
/* ------------ ignore typical warnings in Nim-generated files ------------- */

#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wwritable-strings"
#pragma GCC diagnostic ignored "-Winvalid-noreturn"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wlogical-not-parentheses"
#pragma GCC diagnostic ignored "-Wlogical-op-parentheses"
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
#pragma GCC diagnostic ignored "-Wtautological-compare"
#pragma GCC diagnostic ignored "-Wswitch-bool"
#pragma GCC diagnostic ignored "-Wmacro-redefined"
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
#pragma GCC diagnostic ignored "-Wpointer-bool-conversion"
#pragma GCC diagnostic ignored "-Wconstant-conversion"

/* ------------------------------------------------------------------------- */
# 90 "C:\\Users\\Ado\\.choosenim\\toolchains\\nim-#devel\\lib/nimbase.h"
/* calling convention mess ----------------------------------------------- */

  /* these should support C99's inline */
  /* the test for __POCC__ has to come before the test for _MSC_VER,

     because PellesC defines _MSC_VER too. This is brain-dead. */
# 123 "C:\\Users\\Ado\\.choosenim\\toolchains\\nim-#devel\\lib/nimbase.h"
/*

  NIM_THREADVAR declaration based on

  http://stackoverflow.com/questions/18298280/how-to-declare-a-variable-as-thread-local-portably

*/
# 146 "C:\\Users\\Ado\\.choosenim\\toolchains\\nim-#devel\\lib/nimbase.h"
/* --------------- how int64 constants should be declared: ----------- */

...
zevv commented 4 years ago

I tried to add a workaround, but I haven't tested on windows. Could you give the latest version a try?

adokitkat commented 4 years ago

This is the output, no errors:

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ado\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path C:\Users\Ado\AppData\Local\Temp\arduino_build_505416 -warnings=default -build-cache C:\Users\Ado\AppData\Local\Temp\arduino_cache_607875 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ado\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ado\Documents\Arduino\libraries -fqbn=arduino:avr:uno -ide-version=10813 -build-path C:\Users\Ado\AppData\Local\Temp\arduino_build_505416 -warnings=default -build-cache C:\Users\Ado\AppData\Local\Temp\arduino_cache_607875 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino7.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ado\Documents\Arduino\sketch_aug21a\sketch_aug21a.ino
Using board 'uno' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
nim_arduino macros "--nimflags=\"--cpu:avr" --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger "-d:useMalloc\"" "--compiler=\"C:\\Program" Files "(x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++\"" "--cppflags=\"-c" -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\cores\\arduino" "-IC:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\variants\\standard\"" "--input=\"C:\\Users\\Ado\\AppData\\Local\\Temp\\arduino_build_505416\\sketch\\sketch_aug21a.ino.cpp\"" "--output=\"nul\"" -DARDUINO_LIB_DISCOVERY_PHASE
>>> macros --nimflags="--cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc" --compiler="C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" --cppflags="-c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" --input="C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\sketch_aug21a.ino.cpp" --output="nul" -DARDUINO_LIB_DISCOVERY_PHASE
>>>   output = nul
>>>   nimflags = --cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc
>>>   compiler = C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++
>>>   input = C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\sketch_aug21a.ino.cpp
>>>   cppflags = -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard
>>> nim cpp -c --nimcache:C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\nimcache --cpu:avr --os:any --gc:arc --exceptions:goto --noMain -d:noSignalHandler -d:danger -d:useMalloc C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\sketch.nim
>>> C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -xc++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10813 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard -IC:\Users\Ado\.choosenim\toolchains\nim-#devel\lib C:\Users\Ado\AppData\Local\Temp\arduino_build_505416\sketch\nimcache\@mD@c@sPlayground@sNim@sGit@snim-arduino@ssrc@sarduino.nim.cpp

But still I am not sure if it is actually doing something. How long is the build time for a example sketch? By the time of writing this it has been running for 5 minutes and nothing changed, it is still "compiling".

zevv commented 4 years ago

Ok, thats not good, but it's also not bad: the problem with the white space has been fixed, it seems that now something else is wrong with executing the subcommands. I don't have access to a windows machine, but I will see if I can reproduce this on Wine (the linux Windows Emulator).

adokitkat commented 4 years ago

I have successfully compiled Nim code in Arduino IDE via WSL2 at least, but I cannot upload it directly because idk how to forward a COM port connection into WSL2... yet.

EDIT1: Apparently is is only possible in WSL1 for now. I will try it.

EDIT2: I have tried to downgrade my WSL instance do version 1 and connect a COM port via ttys and cu commands as is written in WSL documentation but Arduino IDE doesn't recognize it anyway.