From 061743006b1d7d5569ed0948ec279c8317df83a6 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Mon, 15 Jun 2020 23:23:40 +0200 Subject: [PATCH 1/5] Implementation of target_api_features --- src/doc/rustc/src/codegen-options/index.md | 27 +++++++++++++ src/librustc_interface/Cargo.toml | 1 + src/librustc_interface/tests.rs | 1 + src/librustc_interface/util.rs | 16 ++++++++ src/librustc_session/options.rs | 2 + src/librustc_span/symbol.rs | 1 + src/librustc_target/api/mod.rs | 11 ++++++ src/librustc_target/api/windows.rs | 39 +++++++++++++++++++ src/librustc_target/lib.rs | 1 + src/librustc_target/spec/mod.rs | 19 +++++++++ src/librustc_target/spec/windows_gnu_base.rs | 2 + src/librustc_target/spec/windows_msvc_base.rs | 2 + .../spec/windows_uwp_gnu_base.rs | 1 + .../spec/windows_uwp_msvc_base.rs | 2 + 14 files changed, 125 insertions(+) create mode 100644 src/librustc_target/api/mod.rs create mode 100644 src/librustc_target/api/windows.rs diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 7b0280d5b78a7..86e94d9cb2746 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -480,6 +480,33 @@ point instructions in software. It takes one of the following values: * `y`, `yes`, `on`, or no value: use soft floats. * `n`, `no`, or `off`: use hardware floats (the default). +## target-api-features + +This option tells `rustc` which operating system APIs are expected to be supported for the target. +Implied features are added as well. + +#### Windows + +Currently, this option is only used for Windows targets, where the feature +names are the `..` versions of all major releases (e.g. `10.0.10240`). +Any version selected adds all previous versions as well, allowing for "greater than" +comparisons: + +```rs +if cfg!(target_api_feature = "10.0.10240") { + println!("new win10 api here"); +} else if cfg!(target_api_feature = "6.1.7600") { + println!("regular win7 api here"); +} else if cfg!(target_api_feature = "5.1.2600") { + println!("legacy winxp api here"); +} else { + println!("not supported"); +} +``` + +Currently, the default for regular Windows targets is Windows 7 (`6.1.7600`). +For UWP targets, it is Windows 10, Version 1509 (`10.0.10240`). + ## target-cpu This instructs `rustc` to generate code specifically for a particular processor. diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index b9837c6ade9a7..2495eca9774dc 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -44,6 +44,7 @@ rustc_privacy = { path = "../librustc_privacy" } rustc_resolve = { path = "../librustc_resolve" } rustc_trait_selection = { path = "../librustc_trait_selection" } rustc_ty = { path = "../librustc_ty" } +rustc_target = { path = "../librustc_target" } tempfile = "3.0.5" once_cell = "1" diff --git a/src/librustc_interface/tests.rs b/src/librustc_interface/tests.rs index e94745519a496..205b57230b141 100644 --- a/src/librustc_interface/tests.rs +++ b/src/librustc_interface/tests.rs @@ -444,6 +444,7 @@ fn test_codegen_options_tracking_hash() { tracked!(profile_use, Some(PathBuf::from("abc"))); tracked!(relocation_model, Some(RelocModel::Pic)); tracked!(soft_float, true); + tracked!(target_api_features, Some(vec![String::from("1"), String::from("2")])); tracked!(target_cpu, Some(String::from("abc"))); tracked!(target_feature, String::from("all the features, all of them")); } diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 8816ba198cf00..8702c84af4b1f 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -53,6 +53,22 @@ pub fn add_configuration( if sess.crt_static(None) { cfg.insert((tf, Some(sym::crt_dash_static))); } + + let target_options = &sess.target.target.options; + if let Some(target_api_kind) = &target_options.target_api_kind { + let target_api_defaults = &target_options.target_api_default_features; + let selected_target_apis = + sess.opts.cg.target_api_features.as_ref().unwrap_or(target_api_defaults); + + let apis = rustc_target::api::get_enabled_target_api_features( + target_api_kind, + selected_target_apis, + ); + + let ta = sym::target_api_feature; + cfg.extend(apis.into_iter().map(|api| (ta, Some(Symbol::intern(api))))); + cfg.extend(selected_target_apis.into_iter().map(|api| (ta, Some(Symbol::intern(api))))); + } } pub fn create_session( diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs index 80164840334a2..5ce33f9f93d3d 100644 --- a/src/librustc_session/options.rs +++ b/src/librustc_session/options.rs @@ -768,6 +768,8 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, "save all temporary output files during compilation (default: no)"), soft_float: bool = (false, parse_bool, [TRACKED], "use soft float ABI (*eabihf targets only) (default: no)"), + target_api_features: Option> = (None, parse_opt_list, [TRACKED], + "a list of target APIs that are expected to be be available on the target (default: use target default)"), target_cpu: Option = (None, parse_opt_string, [TRACKED], "select target processor (`rustc --print target-cpus` for details)"), target_feature: String = (String::new(), parse_target_feature, [TRACKED], diff --git a/src/librustc_span/symbol.rs b/src/librustc_span/symbol.rs index 46612145bf02c..61856299f835a 100644 --- a/src/librustc_span/symbol.rs +++ b/src/librustc_span/symbol.rs @@ -1061,6 +1061,7 @@ symbols! { sym, sync, sync_trait, + target_api_feature, target_arch, target_endian, target_env, diff --git a/src/librustc_target/api/mod.rs b/src/librustc_target/api/mod.rs new file mode 100644 index 0000000000000..93bb002e3a9c6 --- /dev/null +++ b/src/librustc_target/api/mod.rs @@ -0,0 +1,11 @@ +pub mod windows; + +pub fn get_enabled_target_api_features( + target_kind: &str, + requested_apis: &[String], +) -> Vec<&'static str> { + match target_kind { + "windows" => windows::get_enabled_target_api_features(requested_apis), + _ => vec![], + } +} diff --git a/src/librustc_target/api/windows.rs b/src/librustc_target/api/windows.rs new file mode 100644 index 0000000000000..6786a339db31e --- /dev/null +++ b/src/librustc_target/api/windows.rs @@ -0,0 +1,39 @@ +const WINDOWS_VERSIONS: [&str; 25] = [ + "3.10.511", // NT 3.1 + "3.50.807", // NT 3.5 + "3.51.1057", // NT 3.51 + "4.0.1381", // NT 4 + "5.0.2195", // 2000 + "5.1.2600", // XP + "5.2.3790", // XP 64bit, Server 2003 + "6.0.6000", // Vista, Server 2008 + "6.0.6001", // Vista SP1, Server 2008 SP1 + "6.0.6002", // Vista SP2, Server 2008 SP2 + "6.1.7600", // 7, Server 2008 R2 + "6.1.7601", // 7 SP1, Server 2008 R2 SP1 + "6.1.8400", // Home Server 2011 + "6.2.9200", // 8, Server 2012 + "6.3.9600", // 8.1, Server 2012 R2 + "10.0.10240", // 10 1507 + "10.0.10586", // 10 1511 + "10.0.14393", // 10 1607, Server 2016 1607 + "10.0.15063", // 10 1703 + "10.0.16299", // 10 1709, Server 2016 1709 + "10.0.17134", // 10 1803 + "10.0.17763", // 10 1809, Server 2019 1809 + "10.0.18362", // 10 1903 + "10.0.18363", // 10 1909 + "10.0.19041", // 10 2004 +]; + +pub fn get_enabled_target_api_features(requested_apis: &[String]) -> Vec<&'static str> { + let highest_index = requested_apis.iter().fold(None, |old_highest_index, api| { + if let Some((index, _)) = WINDOWS_VERSIONS.iter().enumerate().find(|&(_, ver)| ver == api) { + old_highest_index.map(|old_index| std::cmp::max(old_index, index)).or(Some(index)) + } else { + old_highest_index + } + }); + + highest_index.map(|i| WINDOWS_VERSIONS[..=i].into()).unwrap_or(vec![]) +} diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index 5788e1e838598..1ded316ca9709 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -23,6 +23,7 @@ extern crate rustc_macros; extern crate tracing; pub mod abi; +pub mod api; pub mod asm; pub mod spec; diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index fa29ff3f8d80f..d2e22e74b3789 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -993,6 +993,12 @@ pub struct TargetOptions { /// used to locate unwinding information is passed /// (only has effect if the linker is `ld`-like). pub eh_frame_header: bool, + + /// Decides which logic will be used for determining the full set of target API features + pub target_api_kind: Option, + + /// The default API features for this target. + pub target_api_default_features: Vec, } impl Default for TargetOptions { @@ -1085,6 +1091,8 @@ impl Default for TargetOptions { llvm_args: vec![], use_ctors_section: false, eh_frame_header: true, + target_api_kind: None, + target_api_default_features: vec![], } } } @@ -1478,6 +1486,8 @@ impl Target { key!(llvm_args, list); key!(use_ctors_section, bool); key!(eh_frame_header, bool); + key!(target_api_kind, optional); + key!(target_api_default_features, list); // NB: The old name is deprecated, but support for it is retained for // compatibility. @@ -1716,6 +1726,8 @@ impl ToJson for Target { target_option_val!(llvm_args); target_option_val!(use_ctors_section); target_option_val!(eh_frame_header); + target_option_val!(target_api_kind); + target_option_val!(target_api_default_features); if default.unsupported_abis != self.options.unsupported_abis { d.insert( @@ -1791,3 +1803,10 @@ impl fmt::Display for TargetTriple { write!(f, "{}", self.debug_triple()) } } + +/// A target api function and an optional default, if any +#[derive(PartialEq, Clone, Debug)] +pub struct TargetApiDefinition { + pub api_kind: String, + pub target_api_default_features: Vec, +} diff --git a/src/librustc_target/spec/windows_gnu_base.rs b/src/librustc_target/spec/windows_gnu_base.rs index a864918655fb8..b698b7ad69a97 100644 --- a/src/librustc_target/spec/windows_gnu_base.rs +++ b/src/librustc_target/spec/windows_gnu_base.rs @@ -89,6 +89,8 @@ pub fn opts() -> TargetOptions { emit_debug_gdb_scripts: false, requires_uwtable: true, eh_frame_header: false, + target_api_kind: Some("windows".to_string()), + target_api_default_features: vec!["6.1.7600".to_string()], ..Default::default() } diff --git a/src/librustc_target/spec/windows_msvc_base.rs b/src/librustc_target/spec/windows_msvc_base.rs index 77171f8672e8a..1d923bb12f9e5 100644 --- a/src/librustc_target/spec/windows_msvc_base.rs +++ b/src/librustc_target/spec/windows_msvc_base.rs @@ -24,6 +24,8 @@ pub fn opts() -> TargetOptions { // linking some libraries which require a specific agreement, so it may // not ever be possible for us to pass this flag. no_default_libraries: false, + target_api_kind: Some("windows".to_string()), + target_api_default_features: vec!["6.1.7600".to_string()], ..base } diff --git a/src/librustc_target/spec/windows_uwp_gnu_base.rs b/src/librustc_target/spec/windows_uwp_gnu_base.rs index fd55a0fc6a15e..90ee614ac4336 100644 --- a/src/librustc_target/spec/windows_uwp_gnu_base.rs +++ b/src/librustc_target/spec/windows_uwp_gnu_base.rs @@ -30,6 +30,7 @@ pub fn opts() -> TargetOptions { late_link_args, late_link_args_dynamic, late_link_args_static, + target_api_default_features: vec!["10.0.10240".to_string()], ..base } diff --git a/src/librustc_target/spec/windows_uwp_msvc_base.rs b/src/librustc_target/spec/windows_uwp_msvc_base.rs index 04ffa1a0addbe..3270f8bc6976a 100644 --- a/src/librustc_target/spec/windows_uwp_msvc_base.rs +++ b/src/librustc_target/spec/windows_uwp_msvc_base.rs @@ -10,5 +10,7 @@ pub fn opts() -> TargetOptions { .unwrap() .extend(pre_link_args_msvc); + opts.target_api_default_features = vec!["10.0.10240".to_string()]; + opts } From efda8ad58780cb19291e71b31c3e9cf0b4297f73 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Wed, 5 Aug 2020 00:59:29 +0200 Subject: [PATCH 2/5] Always compile rustc/bootstrap with Win7+ support --- src/bootstrap/compile.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 373e240cb8e3e..81da512502973 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -603,6 +603,29 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS cargo.env("LLVM_NDEBUG", "1"); } } + + if target.contains("windows") { + // all `target_api_feature`s for the currently officially supported + // windows version for rust + const WINDOWS_VERSIONS: [&str; 12] = [ + "3.10.511", // NT 3.1 + "3.10.528", // NT 3.1 SP3 + "3.50.807", // NT 3.5 + "3.51.1057", // NT 3.51 + "4.0.1381", // NT 4 + "5.0.2195", // 2000 + "5.1.2600", // XP + "5.2.3790", // XP 64bit, Server 2003 + "6.0.6000", // Vista, Server 2008 + "6.0.6001", // Vista SP1, Server 2008 SP1 + "6.0.6002", // Vista SP2, Server 2008 SP2 + "6.1.7600", // 7, Server 2008 R2 + ]; + + for v in &WINDOWS_VERSIONS { + cargo.rustflag(&format!("--cfg=target_api_feature=\"{}\"", v)); + } + } } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] From fb5acb8eda43b1533b8009057567f9e6ce28597f Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Wed, 5 Aug 2020 01:19:42 +0200 Subject: [PATCH 3/5] Rename CLI option to target_api_feature, rework handling - Rename to singular form, allowing comma separation and multiple occurrences - Allow usage of `target_api_feature` even if the target has no defined `target_api_kind` --- src/doc/rustc/src/codegen-options/index.md | 5 ++++- src/librustc_interface/util.rs | 14 ++++++++++---- src/librustc_session/options.rs | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/doc/rustc/src/codegen-options/index.md b/src/doc/rustc/src/codegen-options/index.md index 86e94d9cb2746..bb64f2613bbcb 100644 --- a/src/doc/rustc/src/codegen-options/index.md +++ b/src/doc/rustc/src/codegen-options/index.md @@ -480,11 +480,14 @@ point instructions in software. It takes one of the following values: * `y`, `yes`, `on`, or no value: use soft floats. * `n`, `no`, or `off`: use hardware floats (the default). -## target-api-features +## target-api-feature This option tells `rustc` which operating system APIs are expected to be supported for the target. Implied features are added as well. +API features are added as a comma-separated list (`-C target_api_feature=a,b`). The option can be +specified more than once to add more features the the list. + #### Windows Currently, this option is only used for Windows targets, where the feature diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs index 8702c84af4b1f..703db1b2a661e 100644 --- a/src/librustc_interface/util.rs +++ b/src/librustc_interface/util.rs @@ -54,19 +54,25 @@ pub fn add_configuration( cfg.insert((tf, Some(sym::crt_dash_static))); } + let ta = sym::target_api_feature; let target_options = &sess.target.target.options; + let mut selected_target_apis = sess.opts.cg.target_api_feature.as_ref(); + if let Some(target_api_kind) = &target_options.target_api_kind { let target_api_defaults = &target_options.target_api_default_features; - let selected_target_apis = - sess.opts.cg.target_api_features.as_ref().unwrap_or(target_api_defaults); + + let api_features_to_check = selected_target_apis.unwrap_or(target_api_defaults); + selected_target_apis = Some(api_features_to_check); let apis = rustc_target::api::get_enabled_target_api_features( target_api_kind, - selected_target_apis, + api_features_to_check, ); - let ta = sym::target_api_feature; cfg.extend(apis.into_iter().map(|api| (ta, Some(Symbol::intern(api))))); + } + + if let Some(selected_target_apis) = selected_target_apis { cfg.extend(selected_target_apis.into_iter().map(|api| (ta, Some(Symbol::intern(api))))); } } diff --git a/src/librustc_session/options.rs b/src/librustc_session/options.rs index 5ce33f9f93d3d..6693d5cca92b2 100644 --- a/src/librustc_session/options.rs +++ b/src/librustc_session/options.rs @@ -273,6 +273,7 @@ macro_rules! options { pub const parse_tls_model: &str = "one of supported TLS models (`rustc --print tls-models`)"; pub const parse_target_feature: &str = parse_string; + pub const parse_target_api_feature: &str = parse_opt_comma_list; } #[allow(dead_code)] @@ -673,6 +674,17 @@ macro_rules! options { None => false, } } + + fn parse_target_api_feature(slot: &mut Option>, v: Option<&str>) -> bool { + match (slot, v) { + (Some(vec), Some(s)) => { vec.extend(s.split(',').map(|s| s.to_string())); true }, + (slot @ None, Some(s)) => { + *slot = Some(s.split(',').map(|s| s.to_string()).collect()); + true + }, + _ => false, + } + } } ) } @@ -768,8 +780,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options, "save all temporary output files during compilation (default: no)"), soft_float: bool = (false, parse_bool, [TRACKED], "use soft float ABI (*eabihf targets only) (default: no)"), - target_api_features: Option> = (None, parse_opt_list, [TRACKED], - "a list of target APIs that are expected to be be available on the target (default: use target default)"), + target_api_feature: Option> = (None, parse_target_api_feature, [TRACKED], + "a comma-separated list of target APIs that are expected to be be available on the target + (default: use target default) (can be used multiple times)"), target_cpu: Option = (None, parse_opt_string, [TRACKED], "select target processor (`rustc --print target-cpus` for details)"), target_feature: String = (String::new(), parse_target_feature, [TRACKED], From b5211a13a0c80dd0978c6f2f6452f6f70b13dcb2 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Wed, 5 Aug 2020 01:28:19 +0200 Subject: [PATCH 4/5] Add missing version entry --- src/librustc_target/api/windows.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_target/api/windows.rs b/src/librustc_target/api/windows.rs index 6786a339db31e..536c581da6b33 100644 --- a/src/librustc_target/api/windows.rs +++ b/src/librustc_target/api/windows.rs @@ -1,5 +1,6 @@ -const WINDOWS_VERSIONS: [&str; 25] = [ +const WINDOWS_VERSIONS: [&str; 26] = [ "3.10.511", // NT 3.1 + "3.10.528", // NT 3.1 SP3 "3.50.807", // NT 3.5 "3.51.1057", // NT 3.51 "4.0.1381", // NT 4 From db5d2bf2f8c9595aef6b7734283b71fb7c079b84 Mon Sep 17 00:00:00 2001 From: Dennis Duda Date: Mon, 24 Aug 2020 22:49:44 +0200 Subject: [PATCH 5/5] Enable setting target-api-features from config.toml Move api-feature logic into its own function and make it active in both the rustc and std bootstrap config --- config.toml.example | 5 ++++ src/bootstrap/compile.rs | 62 ++++++++++++++++++++++++++-------------- src/bootstrap/config.rs | 6 ++++ src/bootstrap/lib.rs | 5 ++++ 4 files changed, 56 insertions(+), 22 deletions(-) diff --git a/config.toml.example b/config.toml.example index 36587cc078441..266cd77750f18 100644 --- a/config.toml.example +++ b/config.toml.example @@ -546,6 +546,11 @@ # probably don't want to use this. #qemu-rootfs = "..." +# Comma separated list of target api features for the target. Currently, *all* +# features have to be passed if this is specified. Inherited features are not +# supported here yet. +#target-api-feature = "...,..." + # ============================================================================= # Distribution options # diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 81da512502973..4c6c06f695a85 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -205,6 +205,43 @@ fn copy_self_contained_objects( target_deps } +fn add_target_api_features_cargo( + builder: &Builder<'_>, + target: TargetSelection, + cargo: &mut Cargo, +) { + if let Some(api_features) = builder.target_api_feature(target) { + for api_feature in api_features { + cargo.rustflag("--cfg"); + cargo.rustflag(&format!("target_api_feature=\"{}\"", api_feature)); + } + } else { + if target.contains("windows") { + // all `target_api_feature`s for the currently officially supported + // windows version for rust + const WINDOWS_VERSIONS: [&str; 12] = [ + "3.10.511", // NT 3.1 + "3.10.528", // NT 3.1 SP3 + "3.50.807", // NT 3.5 + "3.51.1057", // NT 3.51 + "4.0.1381", // NT 4 + "5.0.2195", // 2000 + "5.1.2600", // XP + "5.2.3790", // XP 64bit, Server 2003 + "6.0.6000", // Vista, Server 2008 + "6.0.6001", // Vista SP1, Server 2008 SP1 + "6.0.6002", // Vista SP2, Server 2008 SP2 + "6.1.7600", // 7, Server 2008 R2 + ]; + + for v in &WINDOWS_VERSIONS { + cargo.rustflag("--cfg"); + cargo.rustflag(&format!("target_api_feature=\"{}\"", v)); + } + } + } +} + /// Configure cargo to compile the standard library, adding appropriate env vars /// and such. pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, cargo: &mut Cargo) { @@ -296,6 +333,8 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car if target.contains("riscv") { cargo.rustflag("-Cforce-unwind-tables=yes"); } + + add_target_api_features_cargo(builder, target, cargo); } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -604,28 +643,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS } } - if target.contains("windows") { - // all `target_api_feature`s for the currently officially supported - // windows version for rust - const WINDOWS_VERSIONS: [&str; 12] = [ - "3.10.511", // NT 3.1 - "3.10.528", // NT 3.1 SP3 - "3.50.807", // NT 3.5 - "3.51.1057", // NT 3.51 - "4.0.1381", // NT 4 - "5.0.2195", // 2000 - "5.1.2600", // XP - "5.2.3790", // XP 64bit, Server 2003 - "6.0.6000", // Vista, Server 2008 - "6.0.6001", // Vista SP1, Server 2008 SP1 - "6.0.6002", // Vista SP2, Server 2008 SP2 - "6.1.7600", // 7, Server 2008 R2 - ]; - - for v in &WINDOWS_VERSIONS { - cargo.rustflag(&format!("--cfg=target_api_feature=\"{}\"", v)); - } - } + add_target_api_features_cargo(builder, target, cargo); } #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 8b8b01b115327..41ad893331b35 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -240,6 +240,7 @@ pub struct Target { pub wasi_root: Option, pub qemu_rootfs: Option, pub no_std: bool, + pub target_api_feature: Option>, } impl Target { @@ -432,6 +433,7 @@ struct TomlTarget { wasi_root: Option, qemu_rootfs: Option, no_std: Option, + target_api_feature: Option, } impl Config { @@ -703,6 +705,10 @@ impl Config { target.musl_libdir = cfg.musl_libdir.clone().map(PathBuf::from); target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from); target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from); + target.target_api_feature = cfg + .target_api_feature + .as_ref() + .map(|s| s.split(',').map(String::from).collect()); config.target_config.insert(TargetSelection::from_user(triple), target); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index a42ee11bd6fe5..3757e5244d459 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -921,6 +921,11 @@ impl Build { self.config.target_config.get(&target).and_then(|t| t.qemu_rootfs.as_ref()).map(|p| &**p) } + /// Returns the target api feature list if they are present + fn target_api_feature(&self, target: TargetSelection) -> Option<&Vec> { + self.config.target_config.get(&target).and_then(|t| t.target_api_feature.as_ref()) + } + /// Path to the python interpreter to use fn python(&self) -> &Path { self.config.python.as_ref().unwrap()