Skip to content

Commit 1f6bd4c

Browse files
committed
add end-to-end test of custom target using rust-lld
starting from the x86_64-unknown-linux-gnu specs, we add the lld linker flavor and self-contained linker component
1 parent 5efbb44 commit 1f6bd4c

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include ../tools.mk
2+
3+
# needs-rust-lld
4+
# only-x86_64-unknown-linux-gnu
5+
all:
6+
RUSTC_LOG=rustc_codegen_ssa::back::link=info $(RUSTC) --crate-type cdylib --target custom-target.json -Clink-args=-Wl,-v lib.rs 2> $(TMPDIR)/output.txt
7+
$(CGREP) -e "^LLD [0-9]+\.[0-9]+\.[0-9]+" < $(TMPDIR)/output.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"arch": "x86_64",
3+
"cpu": "x86-64",
4+
"crt-static-respected": true,
5+
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
6+
"dynamic-linking": true,
7+
"env": "gnu",
8+
"has-rpath": true,
9+
"has-thread-local": true,
10+
"link-self-contained": {
11+
"components": [
12+
"linker"
13+
]
14+
},
15+
"linker-flavor": "gnu-lld-cc",
16+
"llvm-target": "x86_64-unknown-linux-gnu",
17+
"max-atomic-width": 64,
18+
"os": "linux",
19+
"plt-by-default": false,
20+
"position-independent-executables": true,
21+
"pre-link-args": {
22+
"gcc": [
23+
"-m64"
24+
]
25+
},
26+
"relro-level": "full",
27+
"stack-probes": {
28+
"kind": "inline-or-call",
29+
"min-llvm-version-for-inline": [
30+
16,
31+
0,
32+
0
33+
]
34+
},
35+
"static-position-independent-executables": true,
36+
"supported-sanitizers": [
37+
"address",
38+
"cfi",
39+
"leak",
40+
"memory",
41+
"thread",
42+
"safestack"
43+
],
44+
"supported-split-debuginfo": [
45+
"packed",
46+
"unpacked",
47+
"off"
48+
],
49+
"supports-xray": true,
50+
"target-family": [
51+
"unix"
52+
],
53+
"target-pointer-width": "64"
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Test linking using `cc` with `rust-lld`, using a custom target with features described in MCP 510
2+
// see https://github.com/rust-lang/compiler-team/issues/510 for more info:
3+
//
4+
// Starting from the `x86_64-unknown-linux-gnu` target spec, we add the following options:
5+
// - a linker-flavor using lld via a C compiler
6+
// - the self-contained linker component is enabled
7+
8+
#![feature(no_core)]
9+
#![no_core]

0 commit comments

Comments
 (0)