[PATCH] D64304: [X86] -fno-plt: use GOT __tls_get_addr only if GOTPCRELX is enabled
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 00:31:55 PDT 2019
nikic added a comment.
In D64304#1579785 <https://reviews.llvm.org/D64304#1579785>, @MaskRay wrote:
> Can you share a reproduce of the Rust code?
Sorry, I missed that! The rust code is essentially the same as your C code, plus a lot of boilerplate to avoid linking libstd, otherwise the internal TLS use in libstd will already cause the linker error.
// test2.rs
#![crate_type="rlib"]
#![no_std]
#![feature(thread_local)]
#[thread_local]
static TEST: isize = 0;
pub fn get_test() -> isize {
TEST
}
// test.rs
#![no_std]
#![no_main]
extern crate test2;
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {}
}
#[no_mangle]
pub extern "C" fn _start() -> isize {
test2::get_test()
}
Additionally `-C link-arg=-nostartfiles` needs to be specified to avoid linking libc.
This requires a rustc build linked against LLVM 9 though, and the only public build with LLVM 9 (`rustup-toolchain-install-master 82310f68ee567093e06ad767cc0d3cb6127457ba`) already includes your patch here, otherwise rustc would be practically unusable.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D64304/new/
https://reviews.llvm.org/D64304
More information about the llvm-commits
mailing list