Skip to content

Commit 56b7095

Browse files
committed
translate-libs: Use is_std to determine stability
1 parent 17b0895 commit 56b7095

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/bin/mir-json-translate-libs.rs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ struct UnitGraphUnit {
5555
/// `artifact_outputs` with it instead of `src_path`.
5656
pkg_id: String,
5757
target: Target,
58+
#[serde(default)]
59+
is_std: bool,
5860
dependencies: Vec<UnitGraphDependency>,
5961
}
6062

@@ -166,6 +168,10 @@ struct CustomTargetLib {
166168
cfgs: Vec<String>,
167169
/// environment variables
168170
env: Vec<(String, String)>,
171+
/// Whether this library is one of the standard libraries (not necessarily
172+
/// `std` specifically). Used to determine whether to pass
173+
/// standard-library-specific flags.
174+
is_stdlib: bool,
169175
}
170176

171177
impl CustomTarget<CustomTargetLib> {
@@ -666,6 +672,7 @@ fn main() {
666672
.chain(cfgs)
667673
.collect(),
668674
env,
675+
is_stdlib: unit.is_std,
669676
}
670677
}),
671678
dependencies: unit.dependencies,
@@ -699,6 +706,7 @@ fn main() {
699706
linked_paths: vec![],
700707
cfgs: vec![],
701708
env: vec![],
709+
is_stdlib: false,
702710
},
703711
vec![dep_compiler_builtins.clone(), dep_core.clone()],
704712
);
@@ -719,6 +727,7 @@ fn main() {
719727
linked_paths: vec![],
720728
cfgs: vec![],
721729
env: vec![],
730+
is_stdlib: false,
722731
}),
723732
dependencies: vec![dep_core.clone(), dep_compiler_builtins.clone()],
724733
});
@@ -733,6 +742,7 @@ fn main() {
733742
linked_paths: vec![],
734743
cfgs: vec![],
735744
env: vec![],
745+
is_stdlib: false,
736746
}),
737747
dependencies: vec![
738748
dep_core.clone(),
@@ -759,6 +769,7 @@ fn main() {
759769
linked_paths: vec![],
760770
cfgs: vec!["feature=\"std\"".into()],
761771
env: vec![],
772+
is_stdlib: false,
762773
}),
763774
dependencies: vec![dep_core, dep_std, dep_compiler_builtins],
764775
});
@@ -801,16 +812,6 @@ fn main() {
801812
.map(|lib| CmdInvocation {
802813
program: "mir-json".into(),
803814
args: {
804-
// Stdlib crates need `-Z force-unstable-if-unmarked` to
805-
// make stability attributes work properly. But `crucible`
806-
// must not be built with this flag, since the flag makes
807-
// everything unstable by default, requiring users to use
808-
// `#[feature(rustc_private)]`.
809-
let enable_stability_attrs =
810-
!(&*lib.target.crate_name == EXTRA_LIB_CRUCIBLE
811-
|| &*lib.target.crate_name == EXTRA_LIB_INT512
812-
|| &*lib.target.crate_name == EXTRA_LIB_BYTES
813-
|| &*lib.target.crate_name == EXTRA_LIB_BYTEORDER);
814815
let mut args = vec![
815816
lib.target.src_path.into(),
816817
"--edition".into(),
@@ -840,7 +841,12 @@ fn main() {
840841
args.push("rlib".into());
841842
args.push("--remap-path-prefix".into());
842843
args.push(format!("{}=.", cwd));
843-
if enable_stability_attrs {
844+
// Stdlib crates need `-Z force-unstable-if-unmarked` to
845+
// make stability attributes work properly. But the extra
846+
// libs must not be built with this flag, since the flag
847+
// makes everything unstable by default, requiring users to
848+
// use `#[feature(rustc_private)]`.
849+
if lib.target.is_stdlib {
844850
args.push("-Z".into());
845851
args.push("force-unstable-if-unmarked".into());
846852
}

0 commit comments

Comments
 (0)