1
Fork 0

Replace LinkArgs with Cow<'static, str>

This commit is contained in:
Loïc BRANSTETT 2022-03-28 15:06:46 +02:00
parent ce61d4044d
commit c16a558f24
5 changed files with 12 additions and 11 deletions

View file

@ -17,7 +17,7 @@ pub fn target(target_cpu: &'static str) -> Target {
linker: Some("avr-gcc".into()),
executables: true,
eh_frame_header: false,
pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu)])]
pre_link_args: [(LinkerFlavor::Gcc, vec![format!("-mmcu={}", target_cpu).into()])]
.into_iter()
.collect(),
late_link_args: [(LinkerFlavor::Gcc, vec!["-lgcc".into()])].into_iter().collect(),

View file

@ -459,7 +459,7 @@ impl fmt::Display for LinkOutputKind {
}
}
pub type LinkArgs = BTreeMap<LinkerFlavor, Vec<String>>;
pub type LinkArgs = BTreeMap<LinkerFlavor, Vec<Cow<'static, str>>>;
#[derive(Clone, Copy, Hash, Debug, PartialEq, Eq)]
pub enum SplitDebuginfo {
@ -1978,7 +1978,7 @@ impl Target {
.map(|(i,s)| {
let s = s.as_string().ok_or_else(||
format!("{}.{}[{}]: expected a JSON string", name, k, i))?;
Ok(s.into())
Ok(s.to_string().into())
})
.collect::<Result<Vec<_>, String>>()?;

View file

@ -5,9 +5,9 @@ use std::collections::BTreeMap;
pub fn options() -> TargetOptions {
let mut lld_args = Vec::new();
let mut clang_args = Vec::new();
let mut arg = |arg: &str| {
let mut arg = |arg: &'static str| {
lld_args.push(arg.into());
clang_args.push(format!("-Wl,{}", arg));
clang_args.push(format!("-Wl,{}", arg).into());
};
// By default LLD only gives us one page of stack (64k) which is a

View file

@ -68,7 +68,7 @@ pub fn target() -> Target {
position_independent_executables: true,
pre_link_args: iter::once((
LinkerFlavor::Lld(LldFlavor::Ld),
PRE_LINK_ARGS.iter().cloned().map(String::from).collect(),
PRE_LINK_ARGS.iter().cloned().map(Cow::from).collect(),
))
.collect(),
override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(Cow::from).collect()),