Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Failed to compile with Nim 2.0.0 #31

Closed
fukusuket opened this issue Aug 19, 2023 · 6 comments · Fixed by #32
Closed

[bug] Failed to compile with Nim 2.0.0 #31

fukusuket opened this issue Aug 19, 2023 · 6 comments · Fixed by #32
Assignees
Labels
bug Something isn't working
Milestone

Comments

@fukusuket
Copy link
Collaborator

fukusuket commented Aug 19, 2023

Describe the bug
Version 2.0.0 of Nim was released on August 1st.
There seems to be some incompatible changes with major version updates :(

Step to Reproduce

  1. curl https://nim-lang.org/choosenim/init.sh -sSf | sh
  2. choosenim update stable
  3. git clone https://github.com/Yamato-Security/takajo.git
  4. nimble update
  5. nimble build -d:release -d:ssl
  6. See error

Expected behavior
Compilation succeeds.

Actual behavior
Compilation fails with below error.

% choosenim update stable
   Updating stable
Downloading Nim 2.0.0 from nim-lang.org
[##################################################] 100.0% 0kb/s
 Extracting nim-2.0.0.tar.xz
 Extracting nim-2.0.0.tar
   Building Nim 2.0.0
   Building koch
   Building Nim
   Building tools (nimble, nimgrep, nimpretty, nimsuggest, testament)
    Updated to 2.0.0
   Switched to Nim 2.0.0
fukusuke@fukusukenoMacBook-Air takajo % clear
fukusuke@fukusukenoMacBook-Air takajo % nimble update
Downloading Official package list
    Success Package list downloaded.
fukusuke@fukusukenoMacBook-Air takajo % nimble build -d:release -d:ssl
  Verifying dependencies for takajo@2.0.0
 Installing cligen@>= 1.5
Downloading https://github.com/c-blake/cligen.git using git
  Verifying dependencies for cligen@1.6.13
 Installing cligen@1.6.13
  Success:  cligen installed successfully.
 Installing suru@any version
Downloading https://github.com/de-odex/suru using git
  Verifying dependencies for suru@0.3.1
 Installing suru@0.3.1
  Success:  suru installed successfully.
   Building takajo/takajo using c backend
/Users/fukusuke/.nimble/pkgs2/suru-0.3.1-cd5a2094da4c78f632b31b56739e0d0a55baa998/suru.nim(241, 14) Error: type mismatch
Expression: setup(sbc[].bar, iterableLengths)
  [1] sbc[].bar: SuruBar
  [2] iterableLengths: varargs[int]

Expected one of (first mismatch at [position]):
[1] proc setup(sbc: ptr SuruBarController; iterableLengths: varargs[int])
[2] proc setup(sb: var SuruBar)

       Tip: 60 messages have been suppressed, use --verbose to show them.
nimble.nim(229)          buildFromDir

    Error:  Build failed for the package: takajo

Environment (please complete the following information):

  • OS: macOS Ventura 13.4.1
  • nimble version: nimble v0.14.2 compiled at 2023-08-19 16:19:52
  • Takajo version: 2.0.0

Additional context
@YamatoSecurity had already created an issue :)
It seems that other libraries also have compilation errors like this.

@fukusuket fukusuket added the bug Something isn't working label Aug 19, 2023
@YamatoSecurity
Copy link
Collaborator

@fukusuket Thanks for raising the issue! Yes, I'd like to get takajo to work with nim 2.0.0 but I don't think there is a good progress bar replacement for suru so will wait a while until that gets fixed and keep using the 1.x version for now.

@fukusuket
Copy link
Collaborator Author

The following changes in version 2.0.0 seem to cause compilation errors. I'll try to see if I can fix it💪

https://nim-lang.org/blog/2023/08/01/nim-v20-released.html

Improved error message for type mismatch

proc foo(s: string) = discard
proc foo(x, y: int) = discard
proc foo(c: char) = discard

foo 4
produces:

temp3.nim(11, 1) Error: type mismatch
Expression: foo 4
  [1] 4: int literal(4)

Expected one of (first mismatch at [position]):
[1] proc foo(c: char)
[1] proc foo(s: string)
[2] proc foo(x, y: int)

@hitenkoku
Copy link
Collaborator

@fukusuket @YamatoSecurity
I tried in Windows 11(nim --version 2.0.0.)
but successed compile...

>choosenim show
  Selected: 2.0.0
   Channel: stable
      Path: xxx\.choosenim\toolchains\nim-2.0.0

  Versions:
          * 2.0.0
            1.6.12
PS >git pull
Already up to date.
PS >nimble update   
Downloading Official package list
    Success Package list downloaded.
PS >nimble build -d:release -d:ssl
PS >

@fukusuket
Copy link
Collaborator Author

fukusuket commented Aug 20, 2023

@hitenkoku
Thank you for comment :)
I see, it's strange ... I got the same compilation error on my Windows 11 as follows.
There seems to be one more condition for reproduction ... 🤔

PS C:\Users\fukusuke> git clone https://github.com/Yamato-Security/takajo.git
Cloning into 'takajo'...
remote: Enumerating objects: 958, done.
remote: Counting objects: 100% (477/477), done.
remote: Compressing objects: 100% (242/242), done.
remote: Total 958 (delta 270), reused 407 (delta 235), pack-reused 481
Receiving objects: 100% (958/958), 295.33 KiB | 7.20 MiB/s, done.
Resolving deltas: 100% (532/532), done.
PS C:\Users\fukusuke> cd .\takajo
PS C:\Users\fukusuke\takajo> nimble update
Downloading Official package list
    Success Package list downloaded.
PS C:\Users\fukusuke\takajo> nimble build -d:release -d:ssl
  Verifying dependencies for takajo@2.0.0
 Installing cligen@>= 1.5
Downloading https://github.com/c-blake/cligen.git using git
  Verifying dependencies for cligen@1.6.13
 Installing cligen@1.6.13
  Success:  cligen installed successfully.
 Installing suru@any version
Downloading https://github.com/de-odex/suru using git
  Verifying dependencies for suru@0.3.1
 Installing suru@0.3.1                                                                                                                  Success:  suru installed successfully.                                                                                                 Building takajo/takajo.exe using c backend                                                                                         C:\Users\fukusuke\.nimble\pkgs2\suru-0.3.1-cd5a2094da4c78f632b31b56739e0d0a55baa998\suru.nim(241, 14) Error: type mismatch            Expression: setup(sbc[].bar, iterableLengths)
  [1] sbc[].bar: SuruBar
  [2] iterableLengths: varargs[int]

Expected one of (first mismatch at [position]):
[1] proc setup(sbc: ptr SuruBarController; iterableLengths: varargs[int])
[2] proc setup(sb: var SuruBar)

       Tip: 58 messages have been suppressed, use --verbose to show them.
nimble.nim(229)          buildFromDir

    Error:  Build failed for the package: takajo
PS C:\Users\fukusuke\takajo> nim -v
Nim Compiler Version 2.0.0 [Windows: amd64]
Compiled at 2023-08-01
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release
PS C:\Users\fukusuke\takajo> nimble -v
nimble v0.14.2 compiled at 2023-08-01 01:51:39

@fukusuket
Copy link
Collaborator Author

The code below was causing the compilation error.
https://github.com/de-odex/suru/blob/v0.3.1/src/suru.nim#L241

The code above tries to call the following function, but it gives an error because the argument signatures do not match.
https://github.com/de-odex/suru/blob/v0.3.1/src/suru.nim#L153

This issue seems to be fixed in the pull request below.
de-odex/suru#4

@fukusuket
Copy link
Collaborator Author

Also, this issue was avoided by adding the following options when compiling.
nimble build -d:release -d:ssl --threads:off
(However, enabling this compile option may result in the loss of some features of suru ... )

@hitenkoku hitenkoku added this to the 2.1.0 milestone Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants