Skip to content

Commit fe7a843

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 5f24e31 commit fe7a843

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed
Lines changed: 7 additions & 0 deletions
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
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
"gnu-cc": [
23+
"-m64"
24+
],
25+
"gnu-lld-cc": [
26+
"-m64"
27+
]
28+
},
29+
"relro-level": "full",
30+
"stack-probes": {
31+
"kind": "inline-or-call",
32+
"min-llvm-version-for-inline": [
33+
16,
34+
0,
35+
0
36+
]
37+
},
38+
"static-position-independent-executables": true,
39+
"supported-sanitizers": [
40+
"address",
41+
"cfi",
42+
"leak",
43+
"memory",
44+
"thread",
45+
"safestack"
46+
],
47+
"supported-split-debuginfo": [
48+
"packed",
49+
"unpacked",
50+
"off"
51+
],
52+
"supports-xray": true,
53+
"target-family": [
54+
"unix"
55+
],
56+
"target-pointer-width": "64"
57+
}
Lines changed: 9 additions & 0 deletions
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)