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

Link error when a module defines a global variable and has no stacktrace #10943

Closed
yglukhov opened this issue Apr 2, 2019 · 3 comments

Comments

Projects
None yet
3 participants
@yglukhov
Copy link
Member

commented Apr 2, 2019

# a.nim
{.push stackTrace: off.}
proc foo*(): int =
  var a {.global.} = 0
  result = a
{.pop.}
# b.nim
import a
echo foo()
nim c b.nim
/usr/bin/ld: /home/yglukhov/.cache/nim/b_d/a.c.o: in function `unknown_aInit000':
a.c:(.text+0x3d): undefined reference to `nimln_'
collect2: error: ld returned 1 exit status
Error: execution of an external program failed: 'gcc   -o /home/yglukhov/b  /home/yglukhov/.cache/nim/b_d/stdlib_io.c.o /home/yglukhov/.cache/nim/b_d/stdlib_system.c.o /home/yglukhov/.cache/nim/b_d/a.c.o /home/yglukhov/.cache/nim/b_d/b.c.o    -ldl'

@yglukhov yglukhov added the Regression label Apr 2, 2019

@cooldome

This comment has been minimized.

Copy link
Member

commented Apr 2, 2019

What is the correct behavior here? nimln_ should not be emitted because stack trace is off or because variable is global and stack trace is not disabled globally stack trace should be emitted irrespective of pragmas?

@Araq

This comment has been minimized.

Copy link
Member

commented Apr 2, 2019

Any solution that makes this code compile will do IMO.

@cooldome

This comment has been minimized.

Copy link
Member

commented Apr 2, 2019

I will provide fix

cooldome added a commit to cooldome/Nim that referenced this issue Apr 2, 2019

@Araq Araq closed this in e749fc0 Apr 5, 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.