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

Newruntime: compileTime variables can cause compilation to fail due to destructor injections #11204

Closed
cooldome opened this issue May 8, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@cooldome
Copy link
Member

commented May 8, 2019

Unnecessary destructor injections happen for compile time varibles:
Test case:

var a {.compileTime.} = @["a", "b"]

const b = a.len
echo b

nim c --newruntime rt1.nim fails with:

Error: execution of an external compiler program 'gcc.exe -c  -w -mno-ms-bitfields  -IC:\Nim\lib -IC:\Nim -o "rt1.c.o" "rt1.c"' failed with exit code: 1

rt1.c: In function 'NimMainModule':
rt1.c:265:36: error: 'a_OrC3DdeGlFa6OcSiUvQdrg' undeclared (first use in this function)
   eqsink__r6aagoRVuov7HvfEjIi3Uw((&a_OrC3DdeGlFa6OcSiUvQdrg), TM_Fhdix3fUl1Tt0AaVFanfxQ_3);
                                    ^~~~~~~~~~~~~~~~~~~~~~~~

@cooldome cooldome added the Destructors label May 8, 2019

@Clyybber

This comment has been minimized.

Copy link
Contributor

commented May 8, 2019

Note that this also fails without --newruntime, ableit with a different error:

Error: execution of an external compiler program 'gcc -c  -w  -I/home/clyybber/builds/nim/lib -I/home/clyybber/projects/tests -o /home/clyybber/.cache/nim/ctdes_d/ctdes.c.o /home/clyybber/.cache/nim/ctdes_d/ctdes.c' failed with exit code: 1

/home/clyybber/.cache/nim/ctdes_d/ctdes.c: In function ‘NimMainModule’:
/home/clyybber/.cache/nim/ctdes_d/ctdes.c:171:21: error: ‘a_PKmDrwDhlid2eJ9cMvf6f5Q’ undeclared (first use in this function)
  genericSeqAssign((&a_PKmDrwDhlid2eJ9cMvf6f5Q), TM_KN8z8YggeLlhnYXTspvISA_2, (&NTI_sM4lkSb7zS6F7OVMvW9cffQ_));
                     ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/clyybber/.cache/nim/ctdes_d/ctdes.c:171:21: note: each undeclared identifier is reported only once for each function it appears in

you probably meant to remove the a = @["c"], as that change makes it compile without --newruntime, but fail with --newruntime

@cooldome

This comment has been minimized.

Copy link
Member Author

commented May 8, 2019

thanks Clyybber, you are right. Test updated.

@cooldome

This comment has been minimized.

Copy link
Member Author

commented May 8, 2019

I will provide a fix

cooldome added a commit to cooldome/Nim that referenced this issue May 8, 2019

@mratsim mratsim added the VM label May 8, 2019

@Araq Araq closed this in f4c9eb1 May 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.