-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Can't link to an external thread local symbol #30795
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
Comments
I think this is because we don't recognize #![feature(thread_local)]
extern {
#[thread_local]
#[link_name = "errno"]
pub static errno: i32;
}
pub fn foo() -> i32 {
unsafe { errno }
} ; ModuleID = 'foo.0.rs'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-darwin"
@errno = external global i32
; Function Attrs: uwtable
define i32 @_ZN3foo20h5ca9ce4ccbe13eabhaaE() unnamed_addr #0 {
entry-block:
%0 = load i32, i32* @errno, align 4
ret i32 %0
}
attributes #0 = { uwtable "no-frame-pointer-elim"="true" } (note the lack of |
@alexcrichton: DragonFly would need it in order to support |
This may actually be easy enough to add to trans, I think you'll basically need to copy this code over into the foreign module as well. It's possible that we could add back the C shim wrapper, although I'd prefer not to do so! |
@alexcrichton : Thanks for pointing out the solution! I have a pull request (#30856) that fixes that. Much better than requiring a C wrapper! With that fix and some other libc related things, I can now build rust on DragonFly again. |
This will correctly add the thread_local attribute to the external static variable ```errno```: ```rust extern { #[thread_local] static errno: c_int; } ``` Before this commit, the thread_local attribute is ignored. Fixes #30795. Thanks @alexcrichton for pointing out the solution.
I am trying to link to
I try it with:
But it seem that it omits the
thread_local
part. Any ideas how to get it to work? The linker tells me that I have both thread-local and non-thread local references toerrno
defined, so above links to the non-thread local.The text was updated successfully, but these errors were encountered: