-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
{.codegenDecl: "__thread $# $#".} does not seem to work across files #2101
Comments
For __thread you don't need codegenDecl, use the .threadVar pragma. |
Using .threadVar does not seem to influence the generated C. var variable {.threadvar.} : ptr int produces NI* variable_89004; Should it not insert __thread? |
@ckkashyap Under certain cases, Nim uses emulated TLS, to work around compiler bugs and such. Are you sure that nothing has changed in the generated C code? Try using '--tlsEmulation:off' in your command line arguments. |
Passing --threads:on (as Araq mentioned in IRC) made {.threadvar.} work correctly. Araq had asked to leave the bug open since the original issue about {.codegenDecl: "__thread |
Original example works for me with devel on MacOS |
Still not working on Linux: seems like a difference between gcc and clang |
Linker complains when a file that uses a var declared with codegenDecl in another file.
kashyap@kashyap-tp:~/junk$ nim c hello.nim
config/nim.cfg(45, 2) Hint: added path: '/home/kashyap/.babel/pkgs/' [Path]
config/nim.cfg(46, 2) Hint: added path: '/home/kashyap/.nimble/pkgs/sdl2-1.0' [Path]
config/nim.cfg(46, 2) Hint: added path: '/home/kashyap/.nimble/pkgs/nimble-0.6.0' [Path]
config/nim.cfg(46, 2) Hint: added path: '/home/kashyap/.nimble/pkgs/opengl-1.0' [Path]
config/nim.cfg(46, 2) Hint: added path: '/home/kashyap/.nimble/pkgs/x11-1.0' [Path]
config/nim.cfg(46, 2) Hint: added path: '/home/kashyap/.nimble/pkgs/opencv-0.1.0' [Path]
config/nim.cfg(46, 2) Hint: added path: '/home/kashyap/.nimble/pkgs/' [Path]
Hint: used config file '/home/kashyap/Nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: hello [Processing]
Hint: world [Processing]
CC: world
[Linking]
/usr/bin/ld: worldptr_89012: TLS definition in /home/kashyap/junk/nimcache/world.o section .tbss mismatches non-TLS reference in /home/kashyap/junk/nimcache/hello.o
/home/kashyap/junk/nimcache/hello.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
Error: execution of an external program failed
world.nim
hello.nim
The text was updated successfully, but these errors were encountered: