playdate-nim icon indicating copy to clipboard operation
playdate-nim copied to clipboard

Does not compile with Nim 2.0.0

Open simjnd opened this issue 10 months ago • 8 comments

When trying to compile the basic example project after following all the instructions, I get the following errors:

nimble simulator
  Verifying dependencies for [email protected]
     Info:  Dependency on playdate@any version already satisfied
  Verifying dependencies for [email protected]
  Executing task simulator in /Users/simjnd/Documents/Lab/pdnim-test/pdnim_test.nimble
  Verifying dependencies for [email protected]
     Info:  Dependency on playdate@any version already satisfied
  Verifying dependencies for [email protected]
   Building pdnim_test/pdnim_test using c backend
/opt/homebrew/Cellar/nim/2.0.0_1/nim/lib/std/typedthreads.nim(51, 10) Error: Threads not implemented for os:any. Please compile with --threads:off.
       Tip: 4 messages have been suppressed, use --verbose to show them.
nimble.nim(229)          buildFromDir

    Error:  Build failed for the package: pdnim_test
stack trace: (most recent call last)
/private/var/folders/41/034yz3fs4f3_lj9tkvwjvw5m0000gn/T/nimblecache-189809156/nimscriptapi_3428472986.nim(210, 16)
/Users/simjnd/.nimble/pkgs/playdate-0.7.2/playdate/build/nimble.nim(78, 5) simulatorTask
/Users/simjnd/.nimble/pkgs/playdate-0.7.2/playdate/build/nimble.nim(10, 5) nimble
/opt/homebrew/Cellar/nim/2.0.0_1/nim/lib/system/nimscript.nim(265, 7) exec
/opt/homebrew/Cellar/nim/2.0.0_1/nim/lib/system/nimscript.nim(265, 7) Error: unhandled exception: FAILED: nimble -d:simulator build [OSError]
       Tip: 3 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim(160) execScript

    Error:  Exception raised during nimble script execution

When trying to disabled threads, the following error message appears:

Verifying dependencies for [email protected]
     Info:  Dependency on playdate@any version already satisfied
  Verifying dependencies for [email protected]
   Building pdnim_test/pdnim_test using c backend
/opt/homebrew/Cellar/nim/2.0.0_1/nim/lib/system/osalloc.nim(218, 10) Error: Port memory manager to your platform
       Tip: 4 messages have been suppressed, use --verbose to show them.
nimble.nim(229)          buildFromDir

    Error:  Build failed for the package: pdnim_test

simjnd avatar Aug 26 '23 17:08 simjnd

Yeah, compiling using Nim 2.0 is not supported/tested yet. I'd like to update the bindings to properly support Nim 2.0 soon, but in the meantime you can try downgrading your Nim version.

samdze avatar Aug 26 '23 19:08 samdze

Yes I saw the README mentioning it was untested so I wanted to report on it being effectively not working as of now. Thanks for the update!

simjnd avatar Aug 27 '23 11:08 simjnd

For documentation, I updated the github workflow to add Nim 2 support -- you can see the failures here:

https://github.com/Nycto/playdate-nim/actions/runs/6286168524/job/17069326685

Nycto avatar Sep 23 '23 21:09 Nycto

I'm seeing similar issues on Nim 1.6.14 and Nimble 0.14.2 (from Nixpkgs):

  Verifying dependencies for [email protected]
     Info:  Dependency on playdate@any version already satisfied
  Verifying dependencies for [email protected]
  Executing task simulator in /Users/kubukoz/projects/playdate-games/chalka_runner_nim/chalka_runner_nim.nimble
     Info:  Nimble data file "/Users/kubukoz/.nimble/nimbledata2.json" has been loaded.
  Verifying dependencies for [email protected]
    Reading official package list
   Checking for playdate@any version
     Info:  Dependency on playdate@any version already satisfied
  Verifying dependencies for [email protected]
   Building chalka_runner_nim/chalka_runner_nim using c backend
nimble.nim:229           buildFromDir

    Error:  Build failed for the package: chalka_runner_nim
     Info:  Nimble data file "/Users/kubukoz/.nimble/nimbledata2.json" has been saved.
stack trace: (most recent call last)
/private/var/folders/f_/cbwjhbrs2jjg59qn23y6nhvm0000gn/T/nimblecache-983774554/nimscriptapi_4204530433.nim(210, 16)
/Users/kubukoz/.nimble/pkgs2/playdate-0.12.0-3ebf44b45466dfec53e569583a9b86f8323c2729/playdate/build/nimble.nim(72, 16) simulatorTask
/Users/kubukoz/.nimble/pkgs2/playdate-0.12.0-3ebf44b45466dfec53e569583a9b86f8323c2729/playdate/build/utils.nim(22, 10) nimble
/nix/store/hcsq4xl64kgdsj33m6a0y2kfznbpsr70-nim-unwrapped-1.6.14/nim/lib/system/nimscript.nim(273, 7) exec
[1m/nix/store/hcsq4xl64kgdsj33m6a0y2kfznbpsr70-nim-unwrapped-1.6.14/nim/lib/system/nimscript.nim:273:7 [0m[31mError: [0munhandled exception: FAILED: nimble -d:simulator -d:debug build --verbose [OSError][36m[0m[0m
       Tip: 3 messages have been suppressed, use --verbose to show them.
nimscriptwrapper.nim:160 execScript

    Error:  Exception raised during nimble script execution

It builds fine for the device. I initially tried Nim 2.0 but then I found this thread and downgraded - I even removed ~/.nimble to clear the previously downloaded playdate dependency.

I'm following the README instructions to run the hello world. What could I be missing?

kubukoz avatar Dec 23 '23 13:12 kubukoz

@Nycto the ci run results have expired. But seems like what's required is to implement the memory manager for Nim 2. Anyone got plans to do that? Would definitely be nice to support Nim 2.

The official nim extension for vscodde requires some manual work to get going under Nim 1.6: https://github.com/nim-lang/langserver/issues/180

ninovanhooff avatar Feb 10 '24 12:02 ninovanhooff

I've made some progress on Nim 2 support -- it seems like the amount of change required is fairly small: https://github.com/Nycto/playdate-nim/commit/nim2

You can see a build running here: https://github.com/Nycto/playdate-nim/actions/runs/7867464179

I haven't yet tested it on an actual project yet, though the example project compiles and runs.

Nycto avatar Feb 12 '24 05:02 Nycto

I've done some testing using my own game, and everything seems to be working just fine. But I realized that I've got the nimble develop lifecycle wrong in the workflow scripts, so I need to figure out what the actual incantation is for that.

Nycto avatar Feb 15 '24 15:02 Nycto

PR to add Nim 2 support: https://github.com/samdze/playdate-nim/pull/58

Nycto avatar Mar 02 '24 22:03 Nycto