-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Document unstable linker flags in the unstable book #119024
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
968d400
remove unstable linker flavors from stable documentation
lqd 8560c67
describe unstable linker flavors in the unstable book
lqd d39324b
describe unstable self-contained linking components in the unstable book
lqd 3006e62
fix typo in stable doc codegen-options chapter
lqd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/doc/unstable-book/src/compiler-flags/codegen-options.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Unstable codegen options | ||
|
||
All of these options are passed to `rustc` via the `-C` flag, short for "codegen". The flags are | ||
stable but some of their values are individually unstable, and also require using `-Z | ||
unstable-options` to be accepted. | ||
|
||
## linker-flavor | ||
|
||
In addition to the stable set of linker flavors, the following unstable values also exist: | ||
- `ptx`: use [`rust-ptx-linker`](https://github.com/denzp/rust-ptx-linker) | ||
for Nvidia NVPTX GPGPU support. | ||
- `bpf`: use [`bpf-linker`](https://github.com/alessandrod/bpf-linker) for eBPF support. | ||
|
||
Additionally, a set of more precise linker flavors also exists, for example allowing targets to | ||
declare that they use the LLD linker by default. The following values are currently unstable, and | ||
the goal is for them to become stable, and preferred in practice over the existing stable values: | ||
- `gnu`: unix-like linker with GNU extensions | ||
- `gnu-lld`: `gnu` using LLD | ||
- `gnu-cc`: `gnu` using a C/C++ compiler as the linker driver | ||
- `gnu-lld-cc`: `gnu` using LLD and a C/C++ compiler as the linker driver | ||
- `darwin`: unix-like linker for Apple targets | ||
- `darwin-lld`: `darwin` using LLD | ||
- `darwin-cc`: `darwin` using a C/C++ compiler as the linker driver | ||
- `darwin-lld-cc`: `darwin` using LLD and a C/C++ compiler as the linker driver | ||
- `wasm-lld`: unix-like linker for Wasm targets, with LLD | ||
- `wasm-lld-cc`: unix-like linker for Wasm targets, with LLD and a C/C++ compiler as the linker | ||
driver | ||
- `unix`: basic unix-like linker for "any other Unix" targets (Solaris/illumos, L4Re, MSP430, etc), | ||
not supported with LLD. | ||
- `unix-cc`: `unix` using a C/C++ compiler as the linker driver | ||
- `msvc-lld`: MSVC-style linker for Windows and UEFI, with LLD | ||
- `em-cc`: emscripten compiler frontend, similar to `wasm-lld-cc` with a different interface | ||
|
||
## link-self-contained | ||
|
||
This flag generally controls whether the linker will use libraries and objects shipped with Rust | ||
instead of those in the system. The stable boolean values for this flag are coarse-grained | ||
(everything or nothing), but there exists a set of unstable values with finer-grained control, | ||
`-Clink-self-contained` can accept a comma-separated list of components, individually enabled | ||
(`+component`) or disabled (`-component`): | ||
- `crto`: CRT objects (e.g. on `windows-gnu`, `musl`, `wasi` targets) | ||
- `libc`: libc static library (e.g. on `musl`, `wasi` targets) | ||
- `unwind`: libgcc/libunwind (e.g. on `windows-gnu`, `fuchsia`, `fortanix`, `gnullvm` targets) | ||
- `linker`: linker, dlltool, and their necessary libraries (e.g. on `windows-gnu` and for | ||
`rust-lld`) | ||
- `sanitizers`: sanitizer runtime libraries | ||
- `mingw`: other MinGW libs and Windows import libs | ||
|
||
Out of the above self-contained linking components, `linker` is the only one currently implemented | ||
(beyond parsing the CLI options). | ||
|
||
It refers to the LLD linker, built from the same LLVM revision used by rustc (named `rust-lld` to | ||
avoid naming conflicts), that is distributed via `rustup` with the compiler (and is used by default | ||
for the wasm targets). One can also opt-in to use it by combining this flag with an appropriate | ||
linker flavor: for example, `-Clinker-flavor=gnu-lld-cc -Clink-self-contained=+linker` will use the | ||
toolchain's `rust-lld` as the linker. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.