diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-04-23 00:46:45 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-04-26 11:18:47 +0300 |
| commit | fb91e5ed2fe72c6ce38abe0ec2ca47cbeac78d8d (patch) | |
| tree | c1079e34d3118a1cf9ee561296a1814253327fe1 /src/librustc_codegen_ssa | |
| parent | 019ab732ce63a117cbb446db1488916c5c0bd2a7 (diff) | |
| download | rust-fb91e5ed2fe72c6ce38abe0ec2ca47cbeac78d8d.tar.gz rust-fb91e5ed2fe72c6ce38abe0ec2ca47cbeac78d8d.zip | |
rustc_target: Stop using "string typing" for relocation models
Introduce `enum RelocModel` instead.
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/back/link.rs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/librustc_codegen_ssa/back/link.rs b/src/librustc_codegen_ssa/back/link.rs index 8725bfaa025..9d42db8ec42 100644 --- a/src/librustc_codegen_ssa/back/link.rs +++ b/src/librustc_codegen_ssa/back/link.rs @@ -12,7 +12,7 @@ use rustc_session::search_paths::PathKind; /// need out of the shared crate context before we get rid of it. use rustc_session::{filesearch, Session}; use rustc_span::symbol::Symbol; -use rustc_target::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelroLevel}; +use rustc_target::spec::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, RelroLevel}; use super::archive::ArchiveBuilder; use super::command::Command; @@ -1352,7 +1352,7 @@ fn add_position_independent_executable_args( if sess.target.target.options.position_independent_executables { let attr_link_args = &*codegen_results.crate_info.link_args; let mut user_defined_link_args = sess.opts.cg.link_args.iter().chain(attr_link_args); - if is_pic(sess) + if sess.relocation_model() == RelocModel::Pic && !sess.crt_static(Some(crate_type)) && !user_defined_link_args.any(|x| x == "-static") { @@ -1992,12 +1992,3 @@ fn are_upstream_rust_objects_already_included(sess: &Session) -> bool { config::Lto::No | config::Lto::ThinLocal => false, } } - -fn is_pic(sess: &Session) -> bool { - let reloc_model_arg = match sess.opts.cg.relocation_model { - Some(ref s) => &s[..], - None => &sess.target.target.options.relocation_model[..], - }; - - reloc_model_arg == "pic" -} |
