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

Currently supports only building object files for nim 1.6.x? #4

Open
danielplohmann opened this issue Aug 23, 2023 · 5 comments
Open

Comments

@danielplohmann
Copy link

danielplohmann commented Aug 23, 2023

Hi!

First off, thanks a lot for the effort in building this toolchain!
I spent some time this morning replicating your results and wanted to share my observations.
In short: It appears that it currently only works with nim 1.6.x, as pyparsing is failing on older versions of nim source code and for 2.0.0, a critical file seems missing.
More details below.


System:

  • Windows 10
  • Python 3.11
  • pyparsing 3.1.1

Observations:

  • only got it to work with nim-1.6.x x64 (1.6.14 in my case), see exception traces for other versions:
  • for 32bit:
    • when using a 32bit Nim version and 32bit MinGW version
    • then adding --cpu:i386 --l:-m32 -t:-m32 to the build call
    • and commenting out the exit(1) to abort in case of non-zero return still produced object files for me, see last error below
nim 1.2.10

(Line: 0419): -----------------------------------------------------
---
(Line: 0602): Fn num      : 43
(Line: 0603): Fn def      : proc <#alignLeft,string,Natural,char>`_.
  ##
  ## See also:
  ## * `alignLeft proc<#alignLeft,string,Natural,char>`_
  ## * `spaces proc<#spaces,Natural>`_
  ## * `indent proc<#indent,string,Natural,string>`_
  ## * `center proc<#center,string,int,char>`_
  runnableExamples:
    assert align("abc", 4) =
Traceback (most recent call last):
  File "C:\Users\User\Downloads\nim_rtl_builder.py", line 682, in <module>
    parse_file(RTLfile + '.nim')
  File "C:\Users\User\Downloads\nim_rtl_builder.py", line 604, in parse_file
    fn_call = gen_function(f)
              ^^^^^^^^^^^^^^^
  File "C:\Users\User\Downloads\nim_rtl_builder.py", line 335, in gen_function
    parsed_fn = fn.parseString(f, parseAll=False)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyparsing\util.py", line 256, in _inner
    return fn(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyparsing\core.py", line 1197, in parse_string
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected W:(0-9A-Z^-z), found '<'  (at char 5), (line:1, col:6)
nim 1.4.8

(Line: 0419): -----------------------------------------------------
---
(Line: 0602): Fn num      : 44
(Line: 0603): Fn def      : proc <#alignLeft,string,Natural,char>`_.
  ##
  ## See also:
  ## * `alignLeft proc<#alignLeft,string,Natural,char>`_
  ## * `spaces proc<#spaces,Natural>`_
  ## * `indent proc<#indent,string,Natural,string>`_
  ## * `center proc<#center,string,int,char>`_
  runnableExamples:
    assert align("abc", 4) =
Traceback (most recent call last):
  File "C:\Users\User\Downloads\nim_rtl_builder.py", line 682, in <module>
    parse_file(RTLfile + '.nim')
  File "C:\Users\User\Downloads\nim_rtl_builder.py", line 604, in parse_file
    fn_call = gen_function(f)
              ^^^^^^^^^^^^^^^
  File "C:\Users\User\Downloads\nim_rtl_builder.py", line 335, in gen_function
    parsed_fn = fn.parseString(f, parseAll=False)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyparsing\util.py", line 256, in _inner
    return fn(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\site-packages\pyparsing\core.py", line 1197, in parse_string
    raise exc.with_traceback(None)
pyparsing.exceptions.ParseException: Expected W:(0-9A-Z^-z), found '<'  (at char 5), (line:1, col:6)
nim 2.0.0

C:\Users\User\.choosenim\toolchains\nim-2.0.0\lib\pure>python C:\Users\User\Downloads\nim_rtl_builder.py

[ERROR] File not found: ..\system\io.nim
[ERROR] Are you running this script in '<Nim_install_dir>\lib\pure' directory ?
nim 1.6.14 x86

collect2.exe: error: ld returned 1 exit status
Error: execution of an external program failed: 'gcc.exe   -o C:\Users\User\.choosenim\toolchains\nim-1.6.14\lib\pure\parseutils_hu.exe  C:\Users\User\.choosenim\toolchains\nim-1.6.14\lib\pure\HU_nim_cache\@m..@sstd@[email protected] C:\Users\User\.choosenim\toolchains\nim-1.6.14\lib\pure\HU_nim_cache\@m..@[email protected] C:\Users\User\.choosenim\toolchains\nim-1.6.14\lib\pure\HU_nim_cache\@m..@[email protected] C:\Users\User\.choosenim\toolchains\nim-1.6.14\lib\pure\HU_nim_cache\@m..@[email protected] C:\Users\User\.choosenim\toolchains\nim-1.6.14\lib\pure\HU_nim_cache\@[email protected] C:\Users\User\.choosenim\toolchains\nim-1.6.14\lib\pure\HU_nim_cache\@mparseutils_hu.nim.c.o   -m32  '
(Line: 0434): Command failed with return code: 1

edit: I used nim 1.6.14, 1.6.18 does not exist.

@hunterbr72
Copy link
Collaborator

thx Daniel, I ll look into this we only focused on 1.6.x , parsing Nim is a nightmare so no surprise other versions crash the parser. I ll have some other work to do the next two weeks so pls expect some delay.

@hunterbr72
Copy link
Collaborator

I haven't looked into it yet, but rg. "[ERROR] File not found: ..\system\io.nim" just exclude it from the list of libraries in the script (the list which lists all the RTL libs), my guess would be that it just doesn't exists in 2.0. or was renamed.

@hunterbr72
Copy link
Collaborator

Hi Daniel, I have created a development branch, you can find a quick'n dirty update there for Nim 1.2.10. There is now a nim_rtl_builder script per Nim version.

@danielplohmann
Copy link
Author

That's awesome, thank you so much!
I was indeed able to build symbols for 1.2.10, both x86+x64.
For 1.4.8 this same adjusted script "almost" works as well, with some error messages being thrown and there's less files generated, which suggests that its incomplete.
For 2.0.0 I tried to remove ../system/io.nim as suggested by you but then there's some other errors of missing declarations despite methods being present in the glued together source code, so no idea what's up with that.

@hunterbr72
Copy link
Collaborator

cool. Yeah, there could be dependencies, when I find time I ll release a 2.0.x version and a simplified version of manually adding excluded functions. I ll ping you once it is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants