about summary refs log tree commit diff
path: root/tests/run-make/non-pie-thread-local/rmake.rs
blob: 1758f1a0855baef2fca46603e45049afef22de57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// It was once required to use a position-independent executable (PIE)
// in order to use the thread_local! macro, or some symbols would contain
// a NULL address. This was fixed, and this test checks a non-PIE, then a PIE
// build to see if this bug makes a resurgence.
// See https://github.com/rust-lang/rust/pull/24448

//@ ignore-cross-compile
//@ only-linux

use run_make_support::{cc, cwd, run, rustc};

fn main() {
    rustc().input("foo.rs").run();
    cc().input("foo.c")
        .arg("-lfoo")
        .library_search_path(cwd())
        .arg("-Wl,--gc-sections")
        .arg("-lpthread")
        .arg("-ldl")
        .out_exe("foo")
        .run();
    run("foo");
    cc().input("foo.c")
        .arg("-lfoo")
        .library_search_path(cwd())
        .arg("-Wl,--gc-sections")
        .arg("-lpthread")
        .arg("-ldl")
        .arg("-pie")
        .arg("-fPIC")
        .out_exe("foo")
        .run();
    run("foo");
}