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

os:standalone Error: redefinition of 'nimToCStringConv' #11445

Closed
mikra01 opened this issue Jun 9, 2019 · 5 comments

Comments

@mikra01
Copy link

commented Jun 9, 2019

I would like to compile the following example with the gcc-cross toolchain:
"nim c --d:release --os:standalone --gcc.exe:i686-elf-gcc test.nim"

test.nim

 asm """
       hlt;     
     """  

gives me the error

Hint: system [Processing]
C:\Users\tst\Nim\lib\system\sysstr.nim(85, 1) Error: redefinition of 'nimToCStringConv'; previous declaration here: C:\Users\tst\Nim\lib\system.nim(3357, 8)

Additional Information

my compiler version

Nim Compiler Version 0.20.99 [Windows: amd64]
Compiled at 2019-06-07
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: bce908f6ee9f24346641310d8f7f8971e92ffe01
active boot switches: -d:release
@mratsim

This comment has been minimized.

Copy link
Collaborator

commented Jun 9, 2019

It seems like a redeclaration introduced by the standalone flag

proc nimToCStringConv(s: NimString): cstring {.compilerProc, nonReloadable, inline.} =
if s == nil or s.len == 0: result = cstring""
else: result = cstring(addr s.data)

Nim/lib/system.nim

Lines 3356 to 3359 in 3c62d41

when hostOS == "standalone":
proc nimToCStringConv(s: NimString): cstring {.compilerProc, inline.} =
if s == nil or s.len == 0: result = cstring""
else: result = cstring(addr s.data)

@mikra01

This comment has been minimized.

Copy link
Author

commented Jun 9, 2019

it is consumed within the compiler here:

result = ropecg(p.module, "#nimToCStringConv($1)", [a.rdLoc])

and here
ropecg(p.module, "#nimToCStringConv($1)", [rdLoc(a)]),

it seems (to me) that it´s more appropriate within sysstr.nim. I just removed the lines 3356-3359 within system.nim locally but unfortunately I run into another issue:

nim c --os:standalone --gcc.exe:i686-elf-gcc test.nim Hint: used config file 'C:\Users\tst\Nim\config\nim.cfg' [Conf] Hint: used config file 'C:\Users\tst\Nim\config\config.nims' [Conf] Hint: system [Processing] C:\Users\tst\Nim\lib\system\gc.nim(445, 20) Error: type mismatch: got <int, int literal(16)> but expected one of: proc addInt(a, b: int16): int16 first type mismatch at position: 1 required type: int16 but expression 'mulInt(len, typ.base.size)' is of type: int expression: addInt(mulInt(len, typ.base.size), 16)

nim c --os:standalone --gc:stack --gcc.exe:i686-elf-gcc test.nim Hint: used config file 'C:\Users\tst\Nim\config\nim.cfg' [Conf] Hint: used config file 'C:\Users\tst\Nim\config\config.nims' [Conf] Hint: system [Processing] C:\Users\tst\Nim\lib\system\gc_regions.nim(338, 28) Error: type mismatch: got <int, int literal(16)> but expected one of: proc addInt(a, b: int16): int16 first type mismatch at position: 1 required type: int16 but expression 'mulInt(len, typ.base.size)' is of type: int expression: addInt(mulInt(len, typ.base.size), 16)

the switch --gc:none seems to prevent that crash...

@Araq Araq added the Regression label Jun 10, 2019

@mikra01

This comment has been minimized.

Copy link
Author

commented Jun 15, 2019

Hi, how could this be resolved? just removing these few lines (as mentioned) within system.nim? how could the 2nd "mulInt" issue resolved? Should I file another issue for that? At the moment my workaround is: use 0.19.6..

@Araq Araq closed this in fb87833 Jun 27, 2019

@Araq

This comment has been minimized.

Copy link
Member

commented Jun 27, 2019

I couldn't reproduce the mulInt issue, if still a problem open a new bug for that one. Thanks!

@mikra01

This comment has been minimized.

Copy link
Author

commented Jun 30, 2019

Hi Araq, thank you very much - I'll investigate further...

narimiran added a commit that referenced this issue Jul 2, 2019

fixes #11445
(cherry picked from commit fb87833)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.