unify LinkSelfContained and LinkSelfContainedDefault

Removes the backwards-compatible `LinkSelfContainedDefault`, by
incorporating the remaining specifics into `LinkSelfContained`.

Then renames the modern options to keep the old name.
This commit is contained in:
Rémy Rakic
2023-10-18 13:15:20 +00:00
parent b816207e05
commit e569a3691a
8 changed files with 60 additions and 91 deletions

View File

@@ -40,11 +40,9 @@
//! but not gcc's. As a result rustc cannot link with C++ static libraries (#36710)
//! when linking in self-contained mode.
use crate::json::{Json, ToJson};
use crate::spec::LinkOutputKind;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::str::FromStr;
pub type CrtObjects = BTreeMap<LinkOutputKind, Vec<Cow<'static, str>>>;
@@ -123,39 +121,3 @@ pub(super) fn pre_wasi_self_contained() -> CrtObjects {
pub(super) fn post_wasi_self_contained() -> CrtObjects {
new(&[])
}
/// Which logic to use to determine whether to use self-contained linking mode
/// if `-Clink-self-contained` is not specified explicitly.
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
pub enum LinkSelfContainedDefault {
False,
True,
Musl,
Mingw,
}
impl FromStr for LinkSelfContainedDefault {
type Err = ();
fn from_str(s: &str) -> Result<LinkSelfContainedDefault, ()> {
Ok(match s {
"false" => LinkSelfContainedDefault::False,
"true" | "wasm" => LinkSelfContainedDefault::True,
"musl" => LinkSelfContainedDefault::Musl,
"mingw" => LinkSelfContainedDefault::Mingw,
_ => return Err(()),
})
}
}
impl ToJson for LinkSelfContainedDefault {
fn to_json(&self) -> Json {
match *self {
LinkSelfContainedDefault::False => "false",
LinkSelfContainedDefault::True => "true",
LinkSelfContainedDefault::Musl => "musl",
LinkSelfContainedDefault::Mingw => "mingw",
}
.to_json()
}
}