diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index cc4031cc18076..6d8f1cba7091f 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -373,7 +373,7 @@ mod imp { arg: *mut u8, dso_handle: *mut u8) -> libc::c_int; mem::transmute::<*const (), F>(__cxa_thread_atexit_impl) - (dtor, t, __dso_handle); + (dtor, t, &__dso_handle as *const _ as *mut _); return } diff --git a/src/test/run-make/issue-24445/Makefile b/src/test/run-make/issue-24445/Makefile new file mode 100644 index 0000000000000..7a0cbfcf517b7 --- /dev/null +++ b/src/test/run-make/issue-24445/Makefile @@ -0,0 +1,12 @@ +-include ../tools.mk + +ifeq ($(UNAME),Linux) +all: + $(RUSTC) foo.rs + $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -o $(TMPDIR)/foo + $(call RUN,foo) + $(CC) foo.c -lfoo -L $(TMPDIR) -Wl,--gc-sections -lpthread -pie -fPIC -o $(TMPDIR)/foo + $(call RUN,foo) +else +all: +endif diff --git a/src/test/run-make/issue-24445/foo.c b/src/test/run-make/issue-24445/foo.c new file mode 100644 index 0000000000000..775e151f2362d --- /dev/null +++ b/src/test/run-make/issue-24445/foo.c @@ -0,0 +1,16 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +void foo(); + +int main() { + foo(); + return 0; +} diff --git a/src/test/run-make/issue-24445/foo.rs b/src/test/run-make/issue-24445/foo.rs new file mode 100644 index 0000000000000..65e505df5ef17 --- /dev/null +++ b/src/test/run-make/issue-24445/foo.rs @@ -0,0 +1,25 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "staticlib"] + +struct Destroy; +impl Drop for Destroy { + fn drop(&mut self) { println!("drop"); } +} + +thread_local! { + static X: Destroy = Destroy +} + +#[no_mangle] +pub extern "C" fn foo() { + X.with(|_| ()); +}