-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #127992 - Urgau:lazy-targets-link_args, r=<try>
Lazify `TargetOptions::*link_args` fields This PR lazify the link args by introducing `MaybeLazy`, a 3-way lazy container (borrowed, owned and lazied state). Split from #122703 r? `@petrochenkov`
- Loading branch information
Showing
78 changed files
with
524 additions
and
292 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,41 @@ | ||
//! Linker arguments | ||
use crate::spec::add_link_args; | ||
use crate::spec::{LinkerFlavor, LinkerFlavorCli}; | ||
use crate::spec::{MaybeLazy, StaticCow}; | ||
|
||
use std::collections::BTreeMap; | ||
|
||
pub type LinkArgs = BTreeMap<LinkerFlavor, Vec<StaticCow<str>>>; | ||
pub type LinkArgsCli = BTreeMap<LinkerFlavorCli, Vec<StaticCow<str>>>; | ||
|
||
pub type LazyLinkArgs = MaybeLazy<LinkArgs, LazyLinkArgsState>; | ||
|
||
pub enum LazyLinkArgsState { | ||
Simple(LinkerFlavor, &'static [&'static str]), | ||
List(&'static [(LinkerFlavor, &'static [&'static str])]), | ||
Apple(super::base::apple::ApplePreLinkArgs), | ||
} | ||
|
||
impl FnOnce<()> for LazyLinkArgsState { | ||
type Output = LinkArgs; | ||
|
||
#[inline] | ||
extern "rust-call" fn call_once(self, _args: ()) -> Self::Output { | ||
match self { | ||
LazyLinkArgsState::Simple(flavor, args) => { | ||
let mut link_args = LinkArgs::new(); | ||
add_link_args(&mut link_args, flavor, args); | ||
link_args | ||
} | ||
LazyLinkArgsState::List(l) => { | ||
let mut link_args = LinkArgs::new(); | ||
for (flavor, args) in l { | ||
add_link_args(&mut link_args, *flavor, args) | ||
} | ||
link_args | ||
} | ||
LazyLinkArgsState::Apple(args) => super::base::apple::pre_link_args(args), | ||
} | ||
} | ||
} |
Oops, something went wrong.