mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 17:24:06 +00:00
Stabilize linker-flavor
flag.
This commit moves the linker-flavor flag from a debugging option to a codegen option, thus stabilizing it. There are no feature flags associated with this flag.
This commit is contained in:
parent
d8046ed51a
commit
9536d04a2d
@ -22,6 +22,13 @@ This flag lets you append a single extra argument to the linker invocation.
|
||||
This flag lets you append multiple extra arguments to the linker invocation. The
|
||||
options should be separated by spaces.
|
||||
|
||||
## linker-flavor
|
||||
|
||||
This flag lets you control the linker flavor used by `rustc`. If a linker is given with the
|
||||
`-C linker` flag described above then the linker flavor is inferred from the value provided. If no
|
||||
linker is given then the linker flavor is used to determine the linker to use. Every `rustc` target
|
||||
defaults to some linker flavor.
|
||||
|
||||
## link-dead-code
|
||||
|
||||
Normally, the linker will remove dead code. This flag disables this behavior.
|
||||
|
@ -1,61 +0,0 @@
|
||||
# `linker-flavor`
|
||||
|
||||
The tracking issue for this feature is: None
|
||||
|
||||
------------------------
|
||||
|
||||
Every `rustc` target defaults to some linker. For example, Linux targets default
|
||||
to gcc. In some cases, you may want to override the default; you can do that
|
||||
with the unstable CLI argument: `-Z linker-flavor`.
|
||||
|
||||
Here how you would use this flag to link a Rust binary for the
|
||||
`thumbv7m-none-eabi` using LLD instead of GCC.
|
||||
|
||||
``` text
|
||||
$ xargo rustc --target thumbv7m-none-eabi -- \
|
||||
-C linker=ld.lld \
|
||||
-Z linker-flavor=ld \
|
||||
-Z print-link-args | tr ' ' '\n'
|
||||
"ld.lld"
|
||||
"-L"
|
||||
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
|
||||
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-512e9dbf385f233c.0.o"
|
||||
"-o"
|
||||
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-512e9dbf385f233c"
|
||||
"--gc-sections"
|
||||
"-L"
|
||||
"$PWD/target/thumbv7m-none-eabi/debug/deps"
|
||||
"-L"
|
||||
"$PWD/target/debug/deps"
|
||||
"-L"
|
||||
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
|
||||
"-Bstatic"
|
||||
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib/libcore-e1ccb7dfb1cb9ebb.rlib"
|
||||
"-Bdynamic"
|
||||
```
|
||||
|
||||
Whereas the default is:
|
||||
|
||||
``` text
|
||||
$ xargo rustc --target thumbv7m-none-eabi -- \
|
||||
-C link-arg=-nostartfiles \
|
||||
-Z print-link-args | tr ' ' '\n'
|
||||
"arm-none-eabi-gcc"
|
||||
"-L"
|
||||
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
|
||||
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-961e39416baa38d9.0.o"
|
||||
"-o"
|
||||
"$PWD/target/thumbv7m-none-eabi/debug/deps/app-961e39416baa38d9"
|
||||
"-Wl,--gc-sections"
|
||||
"-nodefaultlibs"
|
||||
"-L"
|
||||
"$PWD/target/thumbv7m-none-eabi/debug/deps"
|
||||
"-L"
|
||||
"$PWD/target/debug/deps"
|
||||
"-L"
|
||||
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib"
|
||||
"-Wl,-Bstatic"
|
||||
"$SYSROOT/lib/rustlib/thumbv7m-none-eabi/lib/libcore-e1ccb7dfb1cb9ebb.rlib"
|
||||
"-nostartfiles"
|
||||
"-Wl,-Bdynamic"
|
||||
```
|
@ -1136,6 +1136,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
||||
"enable incremental compilation"),
|
||||
default_linker_libraries: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
|
||||
"allow the linker to link its default libraries"),
|
||||
linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
|
||||
"Linker flavor"),
|
||||
}
|
||||
|
||||
options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||
@ -1292,8 +1294,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
||||
"pass `-install_name @rpath/...` to the macOS linker"),
|
||||
sanitizer: Option<Sanitizer> = (None, parse_sanitizer, [TRACKED],
|
||||
"Use a sanitizer"),
|
||||
linker_flavor: Option<LinkerFlavor> = (None, parse_linker_flavor, [UNTRACKED],
|
||||
"Linker flavor"),
|
||||
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
|
||||
"set the optimization fuel quota for a crate"),
|
||||
print_fuel: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||
|
@ -192,11 +192,7 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
|
||||
|
||||
// linker and linker flavor specified via command line have precedence over what the target
|
||||
// specification specifies
|
||||
if let Some(ret) = infer_from(
|
||||
sess,
|
||||
sess.opts.cg.linker.clone(),
|
||||
sess.opts.debugging_opts.linker_flavor,
|
||||
) {
|
||||
if let Some(ret) = infer_from(sess, sess.opts.cg.linker.clone(), sess.opts.cg.linker_flavor) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -C linker=llllll -Z linker-flavor=ld
|
||||
// compile-flags: -C linker=llllll -C linker-flavor=ld
|
||||
// error-pattern: linker `llllll` not found
|
||||
|
||||
fn main() {
|
||||
|
@ -9,7 +9,7 @@
|
||||
// except according to those terms.
|
||||
|
||||
// error-pattern:aFdEfSeVEE
|
||||
// compile-flags: -Z linker-flavor=ld
|
||||
// compile-flags: -C linker-flavor=ld
|
||||
|
||||
/* We're testing that link_args are indeed passed when nolink is specified.
|
||||
So we try to compile with junk link_args and make sure they are visible in
|
||||
|
@ -1,20 +0,0 @@
|
||||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// This is a fake compile fail test as there's no way to generate a
|
||||
// `#![feature(linker_flavor)]` error. The only reason we have a `linker_flavor`
|
||||
// feature gate is to be able to document `-Z linker-flavor` in the unstable
|
||||
// book
|
||||
|
||||
#[used]
|
||||
//~^ ERROR attribute must be applied to a `static` variable
|
||||
fn foo() {}
|
||||
|
||||
fn main() {}
|
@ -1,8 +0,0 @@
|
||||
error: attribute must be applied to a `static` variable
|
||||
--> $DIR/feature-gate-linker-flavor.rs:16:1
|
||||
|
|
||||
LL | #[used]
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user