Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e7f8895
save/restore `pessimistic_yield` when entering bodies
nikomatsakis Mar 24, 2020
041e170
use of wmemchr for faster searching in [u16]
tesuji Dec 29, 2019
89bc236
Use unrolled loop
tesuji Apr 2, 2020
87d859a
Don't lint for self-recursion when the function can diverge
jonas-schievink Apr 5, 2020
9dd18a3
Move closure check upwards
jonas-schievink Apr 5, 2020
60e9927
Merge redundant match arms
jonas-schievink Apr 5, 2020
dec9078
Add some comments and rename variable
jonas-schievink Apr 5, 2020
cd9f709
add nested regression test
nikomatsakis Apr 6, 2020
ce25dab
linker: Make argument building interface in `trait Linker` richer
petrochenkov Apr 4, 2020
032462e
linker: Combine argument building into a single function
petrochenkov Apr 4, 2020
927db7d
linker: Factor out linking of pre- and post-link objects
petrochenkov Apr 5, 2020
7f42d81
linker: Factor out addition of pre-, post- and late link args
petrochenkov Apr 5, 2020
fd6fa68
linker: Add more markup and comments to code producing linker arguments
petrochenkov Apr 5, 2020
379c255
linker: Factor out more parts of `linker_with_args` and add some docs
petrochenkov Apr 5, 2020
b30d906
Add some more comments
jonas-schievink Apr 6, 2020
5a4fa45
linker: Some minor code cleanup
petrochenkov Apr 6, 2020
b8f416d
Further improve comments
jonas-schievink Apr 7, 2020
859b8da
Implement Chain with Option fuses
cuviper Apr 7, 2020
8aac107
Reduce callsites in Chain::count()
cuviper Apr 7, 2020
2c4cffd
Reduce callsites in Chain::last()
cuviper Apr 7, 2020
ce8abc6
Avoid extra &mut in Chain::fold and try_fold
cuviper Apr 7, 2020
f6c729d
track_caller: harden naked interactions
Centril Apr 8, 2020
f03db79
rustc_session: forbid lints override regardless of position
tobithiel Apr 8, 2020
563152d
comment pessimistic yield and saving/restoring state
nikomatsakis Apr 8, 2020
45589b5
track_caller: support on FFI imports
Centril Apr 8, 2020
e89cb07
Rollup merge of #67705 - lzutao:wmemchr, r=wesleywiser
Centril Apr 9, 2020
ba50bc5
Rollup merge of #70367 - nikomatsakis:issue-69307, r=Aaron1011
Centril Apr 9, 2020
a209b4f
Rollup merge of #70822 - jonas-schievink:curse-of-the-recursion, r=ec…
Centril Apr 9, 2020
cefee7b
Rollup merge of #70868 - petrochenkov:linkorder, r=nagisa,mati865
Centril Apr 9, 2020
ecc4e2a
Rollup merge of #70896 - cuviper:optional-chain, r=scottmcm
Centril Apr 9, 2020
4f00396
Rollup merge of #70916 - Centril:track-caller-ffi, r=eddyb
Centril Apr 9, 2020
09052a6
Rollup merge of #70918 - tobithiel:fix_forbid_override, r=davidtwco
Centril Apr 9, 2020
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
Prev Previous commit
Next Next commit
linker: Make argument building interface in trait Linker richer
by redirecting everything to `Command`
  • Loading branch information
petrochenkov committed Apr 6, 2020
commit ce25dabc66d4b7905dba3bf63ad766d9d6f421ab
9 changes: 4 additions & 5 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ fn link_sanitizer_runtime(sess: &Session, crate_type: config::CrateType, linker:
// PR #41352 for details).
let libname = format!("rustc{}_rt.{}", channel, name);
let rpath = default_tlib.to_str().expect("non-utf8 component in path");
linker.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]);
linker.args(&["-Wl,-rpath", "-Xlinker", rpath]);
linker.link_dylib(Symbol::intern(&libname));
}
"x86_64-unknown-linux-gnu" | "x86_64-fuchsia" | "aarch64-fuchsia" => {
Expand Down Expand Up @@ -1300,16 +1300,15 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(
}

let attr_link_args = codegen_results.crate_info.link_args.iter();
let user_link_args: Vec<_> =
sess.opts.cg.link_args.iter().chain(attr_link_args).cloned().collect();
let user_link_args = sess.opts.cg.link_args.iter().chain(attr_link_args);

if crate_type == config::CrateType::Executable {
let mut position_independent_executable = false;

if t.options.position_independent_executables {
if is_pic(sess)
&& !sess.crt_static(Some(crate_type))
&& !user_link_args.iter().any(|x| x == "-static")
&& !user_link_args.clone().any(|x| x == "-static")
{
position_independent_executable = true;
}
Expand Down Expand Up @@ -1440,7 +1439,7 @@ fn link_args<'a, B: ArchiveBuilder<'a>>(

// Finally add all the linker arguments provided on the command line along
// with any #[link_args] attributes found inside the crate
cmd.args(&user_link_args);
cmd.args(user_link_args);
}

// # Native library linking
Expand Down
47 changes: 28 additions & 19 deletions src/librustc_codegen_ssa/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ impl LinkerInfo {
/// used to dispatch on whether a GNU-like linker (generally `ld.exe`) or an
/// MSVC linker (e.g., `link.exe`) is being used.
pub trait Linker {
fn cmd(&mut self) -> &mut Command;
fn link_dylib(&mut self, lib: Symbol);
fn link_rust_dylib(&mut self, lib: Symbol, path: &Path);
fn link_framework(&mut self, framework: Symbol);
Expand All @@ -111,7 +112,6 @@ pub trait Linker {
fn no_default_libraries(&mut self);
fn build_dylib(&mut self, out_filename: &Path);
fn build_static_executable(&mut self);
fn args(&mut self, args: &[String]);
fn export_symbols(&mut self, tmpdir: &Path, crate_type: CrateType);
fn subsystem(&mut self, subsystem: &str);
fn group_start(&mut self);
Expand All @@ -121,6 +121,16 @@ pub trait Linker {
fn finalize(&mut self) -> Command;
}

impl dyn Linker + '_ {
pub fn arg(&mut self, arg: impl AsRef<OsStr>) {
self.cmd().arg(arg);
}

pub fn args(&mut self, args: impl IntoIterator<Item: AsRef<OsStr>>) {
self.cmd().args(args);
}
}

pub struct GccLinker<'a> {
cmd: Command,
sess: &'a Session,
Expand Down Expand Up @@ -208,6 +218,9 @@ impl<'a> GccLinker<'a> {
}

impl<'a> Linker for GccLinker<'a> {
fn cmd(&mut self) -> &mut Command {
&mut self.cmd
}
fn link_dylib(&mut self, lib: Symbol) {
self.hint_dynamic();
self.cmd.arg(format!("-l{}", lib));
Expand Down Expand Up @@ -251,9 +264,6 @@ impl<'a> Linker for GccLinker<'a> {
fn build_static_executable(&mut self) {
self.cmd.arg("-static");
}
fn args(&mut self, args: &[String]) {
self.cmd.args(args);
}

fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
self.hint_dynamic();
Expand Down Expand Up @@ -545,15 +555,15 @@ pub struct MsvcLinker<'a> {
}

impl<'a> Linker for MsvcLinker<'a> {
fn cmd(&mut self) -> &mut Command {
&mut self.cmd
}
fn link_rlib(&mut self, lib: &Path) {
self.cmd.arg(lib);
}
fn add_object(&mut self, path: &Path) {
self.cmd.arg(path);
}
fn args(&mut self, args: &[String]) {
self.cmd.args(args);
}

fn build_dylib(&mut self, out_filename: &Path) {
self.cmd.arg("/DLL");
Expand Down Expand Up @@ -778,6 +788,9 @@ pub struct EmLinker<'a> {
}

impl<'a> Linker for EmLinker<'a> {
fn cmd(&mut self) -> &mut Command {
&mut self.cmd
}
fn include_path(&mut self, path: &Path) {
self.cmd.arg("-L").arg(path);
}
Expand Down Expand Up @@ -837,10 +850,6 @@ impl<'a> Linker for EmLinker<'a> {
// noop
}

fn args(&mut self, args: &[String]) {
self.cmd.args(args);
}

fn framework_path(&mut self, _path: &Path) {
bug!("frameworks are not supported on Emscripten")
}
Expand Down Expand Up @@ -992,6 +1001,10 @@ impl<'a> WasmLd<'a> {
}

impl<'a> Linker for WasmLd<'a> {
fn cmd(&mut self) -> &mut Command {
&mut self.cmd
}

fn link_dylib(&mut self, lib: Symbol) {
self.cmd.arg("-l").sym_arg(lib);
}
Expand Down Expand Up @@ -1030,10 +1043,6 @@ impl<'a> Linker for WasmLd<'a> {

fn build_static_executable(&mut self) {}

fn args(&mut self, args: &[String]) {
self.cmd.args(args);
}

fn link_rust_dylib(&mut self, lib: Symbol, _path: &Path) {
self.cmd.arg("-l").sym_arg(lib);
}
Expand Down Expand Up @@ -1162,6 +1171,10 @@ pub struct PtxLinker<'a> {
}

impl<'a> Linker for PtxLinker<'a> {
fn cmd(&mut self) -> &mut Command {
&mut self.cmd
}

fn link_rlib(&mut self, path: &Path) {
self.cmd.arg("--rlib").arg(path);
}
Expand All @@ -1182,10 +1195,6 @@ impl<'a> Linker for PtxLinker<'a> {
self.cmd.arg("--bitcode").arg(path);
}

fn args(&mut self, args: &[String]) {
self.cmd.args(args);
}

fn optimize(&mut self) {
match self.sess.lto() {
Lto::Thin | Lto::Fat | Lto::ThinLocal => {
Expand Down