Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow target specs to use an LLD flavor, and self-contained linking components #116035

Merged
merged 6 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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
  • Loading branch information
lqd committed Oct 18, 2023
commit fe7a843278343ed7406c420548da0c26aebdd170
7 changes: 7 additions & 0 deletions tests/run-make/rust-lld-custom-target/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 1,7 @@
include ../tools.mk

# needs-rust-lld
# only-x86_64-unknown-linux-gnu
all:
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
$(CGREP) -e "^LLD [0-9] \.[0-9] \.[0-9] " < $(TMPDIR)/output.txt
57 changes: 57 additions & 0 deletions tests/run-make/rust-lld-custom-target/custom-target.json
Original file line number Diff line number Diff line change
@@ -0,0 1,57 @@
{
"arch": "x86_64",
"cpu": "x86-64",
"crt-static-respected": true,
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
"dynamic-linking": true,
"env": "gnu",
"has-rpath": true,
"has-thread-local": true,
"link-self-contained": {
petrochenkov marked this conversation as resolved.
Show resolved Hide resolved
"components": [
"linker"
]
},
"linker-flavor": "gnu-lld-cc",
"llvm-target": "x86_64-unknown-linux-gnu",
"max-atomic-width": 64,
"os": "linux",
"plt-by-default": false,
"position-independent-executables": true,
"pre-link-args": {
"gnu-cc": [
"-m64"
],
"gnu-lld-cc": [
"-m64"
]
},
"relro-level": "full",
"stack-probes": {
"kind": "inline-or-call",
"min-llvm-version-for-inline": [
16,
0,
0
]
},
"static-position-independent-executables": true,
"supported-sanitizers": [
"address",
"cfi",
"leak",
"memory",
"thread",
"safestack"
],
"supported-split-debuginfo": [
"packed",
"unpacked",
"off"
],
"supports-xray": true,
"target-family": [
"unix"
],
"target-pointer-width": "64"
}
9 changes: 9 additions & 0 deletions tests/run-make/rust-lld-custom-target/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 1,9 @@
// Test linking using `cc` with `rust-lld`, using a custom target with features described in MCP 510
// see https://github.com/rust-lang/compiler-team/issues/510 for more info:
//
// Starting from the `x86_64-unknown-linux-gnu` target spec, we add the following options:
// - a linker-flavor using lld via a C compiler
// - the self-contained linker component is enabled

#![feature(no_core)]
#![no_core]