From d0a48fa58b3bf929f4d268bead2aa9562980312c Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 19 May 2022 08:40:24 +0200 Subject: [PATCH 01/18] Add missing quote --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7bca40..296c587 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate ## [0.10.3] - 2022-05-19 ### Added -- [PR#49](https://github.com/EmbarkStudios/cfg-expr/pull/49) added support for the `has_target_atomic = "` and `panic = ""` predicates. Thanks [@sunshowers](https://github.com/sunshowers)! +- [PR#49](https://github.com/EmbarkStudios/cfg-expr/pull/49) added support for the `has_target_atomic = ""` and `panic = ""` predicates. Thanks [@sunshowers](https://github.com/sunshowers)! ## [0.10.2] - 2022-02-25 ### Changed From 9febdd3c2e7d021fe8e7e0d24cb43ab8ac6fb9c7 Mon Sep 17 00:00:00 2001 From: Rain Date: Thu, 26 May 2022 01:40:11 -0700 Subject: [PATCH 02/18] Update targets to Rust 1.61 (#50) --- Cargo.toml | 2 +- src/targets.rs | 2 +- src/targets/builtins.rs | 40 ++++++++++++++-------------------------- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cf950e0..b2b671e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ targets = ["target-lexicon"] [dependencies] smallvec = "1.8" -target-lexicon = { version = "0.12.3", optional = true } +target-lexicon = { version = "0.12.4", optional = true } [dev-dependencies] similar-asserts = "1.1" diff --git a/src/targets.rs b/src/targets.rs index d9dad10..2150312 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -364,7 +364,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo> /// versions. /// /// ``` -/// assert_eq!("1.60.0", cfg_expr::targets::rustc_version()); +/// assert_eq!("1.61.0", cfg_expr::targets::rustc_version()); /// ``` pub fn rustc_version() -> &'static str { builtins::RUSTC_VERSION diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index 74ee0a4..ac0265e 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.60.0"; +pub(crate) const RUSTC_VERSION: &str = "1.61.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -205,18 +205,6 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::abort, }, - TargetInfo { - triple: Triple::new_const("aarch64-unknown-none-hermitkernel"), - os: None, - arch: Arch::aarch64, - env: None, - vendor: Some(Vendor::unknown), - families: Families::new_const(&[]), - pointer_width: 64, - endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, - panic: Panic::abort, - }, TargetInfo { triple: Triple::new_const("aarch64-unknown-none-softfloat"), os: None, @@ -1429,6 +1417,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::new_const(&[]), panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv32im-unknown-none-elf"), + os: None, + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("riscv32imac-unknown-none-elf"), os: None, @@ -1450,7 +1450,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::unix, pointer_width: 32, endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_ptr, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, TargetInfo { @@ -2077,18 +2077,6 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, - TargetInfo { - triple: Triple::new_const("x86_64-unknown-none-hermitkernel"), - os: None, - arch: Arch::x86_64, - env: None, - vendor: Some(Vendor::unknown), - families: Families::new_const(&[]), - pointer_width: 64, - endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, - panic: Panic::abort, - }, TargetInfo { triple: Triple::new_const("x86_64-unknown-none-linuxkernel"), os: None, From 266b620f28ecdd0f79492d814c4a3cf2b35a632d Mon Sep 17 00:00:00 2001 From: Rain Date: Tue, 27 Sep 2022 05:20:19 -0700 Subject: [PATCH 03/18] Update targets to Rust 1.63 (#51) * Make target-lexicon parsing optional There are enough new weird architectures added in each version of Rust that it is difficult to keep target-lexicon aware of all of them. So try parsing triples, but don't fail if that doesn't work. * Update targets to Rust 1.63 * Update to 1.64.0 * Bump MSRV to 1.58.0 * Move lint config to .cargo/config.toml * Update CHANGELOG * Fixup README * Cleanup CI * Oops Co-authored-by: Jake Shadle --- .cargo/config.toml | 79 ++++++++++++++++++++ .github/workflows/ci.yml | 31 +++----- CHANGELOG.md | 4 + Cargo.toml | 3 +- README.md | 4 +- clippy.toml | 2 +- src/error.rs | 18 ++--- src/expr.rs | 14 ++-- src/expr/parser.rs | 156 ++++++++++++++++++++------------------- src/lib.rs | 80 -------------------- src/targets.rs | 2 +- src/targets/builtins.rs | 100 ++++++++++++++++++++++++- tests/eval.rs | 58 ++++++++------- 13 files changed, 329 insertions(+), 222 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..3d31fa7 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,79 @@ +[target.'cfg(all())'] +rustflags = [ + # BEGIN - Embark standard lints v6 for Rust 1.55+ + # do not change or add/remove here, but one can add exceptions after this section + # for more info see: + "-Dunsafe_code", + "-Wclippy::all", + "-Wclippy::await_holding_lock", + "-Wclippy::char_lit_as_u8", + "-Wclippy::checked_conversions", + "-Wclippy::dbg_macro", + "-Wclippy::debug_assert_with_mut_call", + "-Wclippy::doc_markdown", + "-Wclippy::empty_enum", + "-Wclippy::enum_glob_use", + "-Wclippy::exit", + "-Wclippy::expl_impl_clone_on_copy", + "-Wclippy::explicit_deref_methods", + "-Wclippy::explicit_into_iter_loop", + "-Wclippy::fallible_impl_from", + "-Wclippy::filter_map_next", + "-Wclippy::flat_map_option", + "-Wclippy::float_cmp_const", + "-Wclippy::fn_params_excessive_bools", + "-Wclippy::from_iter_instead_of_collect", + "-Wclippy::if_let_mutex", + "-Wclippy::implicit_clone", + "-Wclippy::imprecise_flops", + "-Wclippy::inefficient_to_string", + "-Wclippy::invalid_upcast_comparisons", + "-Wclippy::large_digit_groups", + "-Wclippy::large_stack_arrays", + "-Wclippy::large_types_passed_by_value", + "-Wclippy::let_unit_value", + "-Wclippy::linkedlist", + "-Wclippy::lossy_float_literal", + "-Wclippy::macro_use_imports", + "-Wclippy::manual_ok_or", + "-Wclippy::map_err_ignore", + "-Wclippy::map_flatten", + "-Wclippy::map_unwrap_or", + "-Wclippy::match_on_vec_items", + "-Wclippy::match_same_arms", + "-Wclippy::match_wild_err_arm", + "-Wclippy::match_wildcard_for_single_variants", + "-Wclippy::mem_forget", + "-Wclippy::mismatched_target_os", + "-Wclippy::missing_enforced_import_renames", + "-Wclippy::mut_mut", + "-Wclippy::mutex_integer", + "-Wclippy::needless_borrow", + "-Wclippy::needless_continue", + "-Wclippy::needless_for_each", + "-Wclippy::option_option", + "-Wclippy::path_buf_push_overwrite", + "-Wclippy::ptr_as_ptr", + "-Wclippy::rc_mutex", + "-Wclippy::ref_option_ref", + "-Wclippy::rest_pat_in_fully_bound_structs", + "-Wclippy::same_functions_in_if_condition", + "-Wclippy::semicolon_if_nothing_returned", + "-Wclippy::single_match_else", + "-Wclippy::string_add_assign", + "-Wclippy::string_add", + "-Wclippy::string_lit_as_bytes", + "-Wclippy::string_to_string", + "-Wclippy::todo", + "-Wclippy::trait_duplication_in_bounds", + "-Wclippy::unimplemented", + "-Wclippy::unnested_or_patterns", + "-Wclippy::unused_self", + "-Wclippy::useless_transmute", + "-Wclippy::verbose_file_reads", + "-Wclippy::zero_sized_map_values", + "-Wfuture_incompatible", + "-Wnonstandard_style", + "-Wrust_2018_idioms", + # END - Embark standard lints v6 for Rust 1.55+ +] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fffba5e..78c0af2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,22 +12,19 @@ name: CI jobs: lint: name: Lint - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable with: - toolchain: stable - override: true + components: "clippy, rustfmt" # make sure all code has been formatted with rustfmt - - run: rustup component add rustfmt - name: check rustfmt run: cargo fmt -- --check --color always # run clippy to verify we have no warnings - run: cargo fetch - - run: rustup component add clippy - name: cargo clippy run: cargo clippy --all-targets --all-features -- -D warnings @@ -35,14 +32,13 @@ jobs: name: Test strategy: matrix: - toolchain: [1.54, stable] - runs-on: ubuntu-20.04 + toolchain: [1.58.0, stable] + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.toolchain }} - override: true - run: cargo fetch - name: cargo test build run: cargo build --tests --release @@ -55,20 +51,17 @@ jobs: deny-check: name: cargo-deny - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: EmbarkStudios/cargo-deny-action@v1 publish-check: name: Publish Check runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@stable - run: cargo fetch - name: cargo publish check run: cargo publish --dry-run diff --git a/CHANGELOG.md b/CHANGELOG.md index 296c587..6e66c4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) updated the builtin target list to 1.64.0. Thanks [@sunshowers](https://github.com/sunshowers)! +- [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) bumped the MSRV to 1.58.0. + ## [0.10.3] - 2022-05-19 ### Added - [PR#49](https://github.com/EmbarkStudios/cfg-expr/pull/49) added support for the `has_target_atomic = ""` and `panic = ""` predicates. Thanks [@sunshowers](https://github.com/sunshowers)! diff --git a/Cargo.toml b/Cargo.toml index b2b671e..ccc5f1d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,9 +7,10 @@ authors = [ "Embark ", "Jake Shadle ", ] -edition = "2018" +edition = "2021" license = "MIT OR Apache-2.0" readme = "README.md" +rust-version = "1.58.0" documentation = "https://docs.rs/cfg-expr" homepage = "https://github.com/EmbarkStudios/cfg-expr" keywords = ["cargo", "rustc", "cfg"] diff --git a/README.md b/README.md index 1ea4a88..292376d 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ [![Build Status](https://github.com/EmbarkStudios/cfg-expr/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/cfg-expr/actions?workflow=CI) [![Crates.io](https://img.shields.io/crates/v/cfg-expr.svg)](https://crates.io/crates/cfg-expr) [![Docs](https://docs.rs/cfg-expr/badge.svg)](https://docs.rs/cfg-expr) -[![Minimum Stable Rust Version](https://img.shields.io/badge/Rust%20MSRV-1.54.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2021/07/29/Rust-1.54.0.html) -[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.58.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) +[![Minimum Stable Rust Version](https://img.shields.io/badge/Rust%20MSRV-1.58.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html) +[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.64.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) [![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev) diff --git a/clippy.toml b/clippy.toml index 79d4f25..aed39d9 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1,2 @@ -msrv = "1.52" +msrv = "1.58.0" avoid-breaking-exported-api = false diff --git a/src/error.rs b/src/error.rs index 52787c4..a71b7dc 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,7 +1,7 @@ use std::{error::Error, fmt}; /// An error related to parsing of a cfg expression -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct ParseError { /// The string that was parsed pub original: String, @@ -13,7 +13,7 @@ pub struct ParseError { } /// The particular reason for a `ParseError` -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Reason { /// not() takes exactly 1 predicate, unlike all() and any() InvalidNot(usize), @@ -54,18 +54,18 @@ impl fmt::Display for ParseError { // Mismatched parens/quotes have a slightly different output // than the other errors match &self.reason { - r @ Reason::UnclosedParens | r @ Reason::UnclosedQuotes => { - f.write_fmt(format_args!("- {}", r)) + r @ (Reason::UnclosedParens | Reason::UnclosedQuotes) => { + f.write_fmt(format_args!("- {r}")) } - r @ Reason::UnopenedParens | r @ Reason::UnopenedQuotes => { - f.write_fmt(format_args!("^ {}", r)) + r @ (Reason::UnopenedParens | Reason::UnopenedQuotes) => { + f.write_fmt(format_args!("^ {r}")) } other => { for _ in self.span.start..self.span.end { f.write_str("^")?; } - f.write_fmt(format_args!(" {}", other)) + f.write_fmt(format_args!(" {other}")) } } } @@ -91,7 +91,7 @@ impl fmt::Display for Reason { f.write_str("expected one of ")?; for (i, exp) in expected.iter().enumerate() { - f.write_fmt(format_args!("{}`{}`", if i > 0 { ", " } else { "" }, exp))?; + f.write_fmt(format_args!("{}`{exp}`", if i > 0 { ", " } else { "" }))?; } f.write_str(" here") } else if !expected.is_empty() { @@ -100,7 +100,7 @@ impl fmt::Display for Reason { f.write_str("the term was not expected here") } } - InvalidNot(np) => f.write_fmt(format_args!("not() takes 1 predicate, found {}", np)), + InvalidNot(np) => f.write_fmt(format_args!("not() takes 1 predicate, found {np}")), InvalidInteger => f.write_str("invalid integer"), MultipleRootPredicates => f.write_str("multiple root predicates"), InvalidHasAtomic => f.write_str("expected integer or \"ptr\""), diff --git a/src/expr.rs b/src/expr.rs index f46fdc6..fcd66ff 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -28,7 +28,7 @@ pub enum Func { use crate::targets as targ; /// All predicates that pertains to a target, except for `target_feature` -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, PartialEq, Eq, Debug)] pub enum TargetPredicate { /// [target_arch](https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch) Arch(targ::Arch), @@ -136,13 +136,15 @@ impl TargetMatcher for target_lexicon::Triple { OperatingSystem::Redox => env == &targ::Env::relibc, OperatingSystem::VxWorks => env == &targ::Env::gnu, OperatingSystem::Freebsd => match self.architecture { - Architecture::Arm(ArmArchitecture::Armv6) - | Architecture::Arm(ArmArchitecture::Armv7) => env == &targ::Env::gnueabihf, + Architecture::Arm(ArmArchitecture::Armv6 | ArmArchitecture::Armv7) => { + env == &targ::Env::gnueabihf + } _ => env.0.is_empty(), }, OperatingSystem::Netbsd => match self.architecture { - Architecture::Arm(ArmArchitecture::Armv6) - | Architecture::Arm(ArmArchitecture::Armv7) => env == &targ::Env::eabihf, + Architecture::Arm(ArmArchitecture::Armv6 | ArmArchitecture::Armv7) => { + env == &targ::Env::eabihf + } _ => env.0.is_empty(), }, OperatingSystem::None_ @@ -372,7 +374,7 @@ pub(crate) struct InnerTarget { } /// A single predicate in a `cfg()` expression -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Predicate<'a> { /// A target predicate, with the `target_` prefix Target(TargetPredicate), diff --git a/src/expr/parser.rs b/src/expr/parser.rs index 98646f5..ba937b4 100644 --- a/src/expr/parser.rs +++ b/src/expr/parser.rs @@ -216,7 +216,7 @@ impl Expression { ($span:expr) => {{ let expected: &[&str] = match last_token { None => &["", "all", "any", "not"], - Some(Token::All) | Some(Token::Any) | Some(Token::Not) => &["("], + Some(Token::All | Token::Any | Token::Not) => &["("], Some(Token::CloseParen) => &[")", ","], Some(Token::Comma) => &[")", ""], Some(Token::Equals) => &["\""], @@ -242,29 +242,32 @@ impl Expression { 'outer: for lt in lexer { let lt = lt?; match <.token { - Token::Key(k) => match last_token { - None | Some(Token::OpenParen) | Some(Token::Comma) => { + Token::Key(k) => { + if matches!(last_token, None | Some(Token::OpenParen | Token::Comma)) { pred_key = Some((k, lt.span.clone())); + } else { + token_err!(lt.span) } - _ => token_err!(lt.span), - }, - Token::Value(v) => match last_token { - Some(Token::Equals) => { + } + Token::Value(v) => { + if matches!(last_token, Some(Token::Equals)) { // We only record the span for keys and values // so that the expression doesn't need a lifetime // but in the value case we need to strip off // the quotes so that the proper raw string is // provided to callers when evaluating the expression pred_val = Some((v, lt.span.start + 1..lt.span.end - 1)); + } else { + token_err!(lt.span) } - _ => token_err!(lt.span), - }, - Token::Equals => match last_token { - Some(Token::Key(_)) => {} - _ => token_err!(lt.span), - }, - Token::All | Token::Any | Token::Not => match last_token { - None | Some(Token::OpenParen) | Some(Token::Comma) => { + } + Token::Equals => { + if !matches!(last_token, Some(Token::Key(_))) { + token_err!(lt.span) + } + } + Token::All | Token::Any | Token::Not => { + if matches!(last_token, None | Some(Token::OpenParen | Token::Comma)) { let new_fn = match lt.token { // the 0 is a dummy value -- it will be substituted for the real // number of predicates in the `CloseParen` branch below. @@ -285,23 +288,26 @@ impl Expression { predicates: SmallVec::new(), nest_level: 0, }); + } else { + token_err!(lt.span) } - _ => token_err!(lt.span), - }, - Token::OpenParen => match last_token { - Some(Token::All) | Some(Token::Any) | Some(Token::Not) => { + } + Token::OpenParen => { + if matches!(last_token, Some(Token::All | Token::Any | Token::Not)) { if let Some(ref mut fs) = func_stack.last_mut() { fs.parens_index = lt.span.start; } - } - _ => token_err!(lt.span), - }, - Token::CloseParen => match last_token { - None | Some(Token::All) | Some(Token::Any) | Some(Token::Not) - | Some(Token::Equals) => { + } else { token_err!(lt.span) } - _ => { + } + Token::CloseParen => { + if matches!( + last_token, + None | Some(Token::All | Token::Any | Token::Not | Token::Equals) + ) { + token_err!(lt.span) + } else { if let Some(top) = func_stack.pop() { let key = pred_key.take(); let val = pred_val.take(); @@ -352,15 +358,16 @@ impl Expression { reason: Reason::UnopenedParens, }); } - }, - Token::Comma => match last_token { - None - | Some(Token::OpenParen) - | Some(Token::All) - | Some(Token::Any) - | Some(Token::Not) - | Some(Token::Equals) => token_err!(lt.span), - _ => { + } + Token::Comma => { + if matches!( + last_token, + None | Some( + Token::OpenParen | Token::All | Token::Any | Token::Not | Token::Equals + ) + ) { + token_err!(lt.span) + } else { let key = pred_key.take(); let val = pred_val.take(); @@ -378,7 +385,7 @@ impl Expression { _ => {} } } - }, + } } last_token = Some(lt.token); @@ -393,49 +400,46 @@ impl Expression { } // If we still have functions on the stack, it means we have an unclosed parens - match func_stack.pop() { - Some(top) => { - if top.parens_index != 0 { - Err(ParseError { - original: original.to_owned(), - span: top.parens_index..original.len(), - reason: Reason::UnclosedParens, - }) - } else { - Err(ParseError { - original: original.to_owned(), - span: top.span, - reason: Reason::Unexpected(&["("]), - }) - } + if let Some(top) = func_stack.pop() { + if top.parens_index != 0 { + Err(ParseError { + original: original.to_owned(), + span: top.parens_index..original.len(), + reason: Reason::UnclosedParens, + }) + } else { + Err(ParseError { + original: original.to_owned(), + span: top.span, + reason: Reason::Unexpected(&["("]), + }) } - None => { - let key = pred_key.take(); - let val = pred_val.take(); + } else { + let key = pred_key.take(); + let val = pred_val.take(); - if let Some(key) = key { - root_predicate_count += 1; - expr_queue.push(ExprNode::Predicate(parse_predicate(key, val)?)); - } + if let Some(key) = key { + root_predicate_count += 1; + expr_queue.push(ExprNode::Predicate(parse_predicate(key, val)?)); + } - if expr_queue.is_empty() { - Err(ParseError { - original: original.to_owned(), - span: 0..original.len(), - reason: Reason::Empty, - }) - } else if root_predicate_count > 1 { - Err(ParseError { - original: original.to_owned(), - span: 0..original.len(), - reason: Reason::MultipleRootPredicates, - }) - } else { - Ok(Expression { - original: original.to_owned(), - expr: expr_queue, - }) - } + if expr_queue.is_empty() { + Err(ParseError { + original: original.to_owned(), + span: 0..original.len(), + reason: Reason::Empty, + }) + } else if root_predicate_count > 1 { + Err(ParseError { + original: original.to_owned(), + span: 0..original.len(), + reason: Reason::MultipleRootPredicates, + }) + } else { + Ok(Expression { + original: original.to_owned(), + expr: expr_queue, + }) } } } diff --git a/src/lib.rs b/src/lib.rs index 6346c06..30cb38c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,84 +1,4 @@ #![doc = include_str!("../README.md")] -// BEGIN - Embark standard lints v5 for Rust 1.55+ -// do not change or add/remove here, but one can add exceptions after this section -// for more info see: -#![deny(unsafe_code)] -#![warn( - clippy::all, - clippy::await_holding_lock, - clippy::char_lit_as_u8, - clippy::checked_conversions, - clippy::dbg_macro, - clippy::debug_assert_with_mut_call, - clippy::doc_markdown, - clippy::empty_enum, - clippy::enum_glob_use, - clippy::exit, - clippy::expl_impl_clone_on_copy, - clippy::explicit_deref_methods, - clippy::explicit_into_iter_loop, - clippy::fallible_impl_from, - clippy::filter_map_next, - clippy::flat_map_option, - clippy::float_cmp_const, - clippy::fn_params_excessive_bools, - clippy::from_iter_instead_of_collect, - clippy::if_let_mutex, - clippy::implicit_clone, - clippy::imprecise_flops, - clippy::inefficient_to_string, - clippy::invalid_upcast_comparisons, - clippy::large_digit_groups, - clippy::large_stack_arrays, - clippy::large_types_passed_by_value, - clippy::let_unit_value, - clippy::linkedlist, - clippy::lossy_float_literal, - clippy::macro_use_imports, - clippy::manual_ok_or, - clippy::map_err_ignore, - clippy::map_flatten, - clippy::map_unwrap_or, - clippy::match_on_vec_items, - clippy::match_same_arms, - clippy::match_wild_err_arm, - clippy::match_wildcard_for_single_variants, - clippy::mem_forget, - clippy::mismatched_target_os, - clippy::missing_enforced_import_renames, - clippy::mut_mut, - clippy::mutex_integer, - clippy::needless_borrow, - clippy::needless_continue, - clippy::needless_for_each, - clippy::option_option, - clippy::path_buf_push_overwrite, - clippy::ptr_as_ptr, - clippy::rc_mutex, - clippy::ref_option_ref, - clippy::rest_pat_in_fully_bound_structs, - clippy::same_functions_in_if_condition, - clippy::semicolon_if_nothing_returned, - clippy::single_match_else, - clippy::string_add_assign, - clippy::string_add, - clippy::string_lit_as_bytes, - clippy::string_to_string, - clippy::todo, - clippy::trait_duplication_in_bounds, - clippy::unimplemented, - clippy::unnested_or_patterns, - clippy::unused_self, - clippy::useless_transmute, - clippy::verbose_file_reads, - clippy::zero_sized_map_values, - future_incompatible, - nonstandard_style, - rust_2018_idioms -)] -// END - Embark standard lints v0.5 for Rust 1.55+ -// crate-specific exceptions: -#![allow(clippy::single_match_else)] /// Types related to parse errors pub mod error; diff --git a/src/targets.rs b/src/targets.rs index 2150312..8d458b8 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -364,7 +364,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo> /// versions. /// /// ``` -/// assert_eq!("1.61.0", cfg_expr::targets::rustc_version()); +/// assert_eq!("1.64.0", cfg_expr::targets::rustc_version()); /// ``` pub fn rustc_version() -> &'static str { builtins::RUSTC_VERSION diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index ac0265e..8a2d3c0 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.61.0"; +pub(crate) const RUSTC_VERSION: &str = "1.64.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -73,6 +73,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("aarch64-apple-watchos-sim"), + os: Some(Os::watchos), + arch: Arch::aarch64, + env: None, + vendor: Some(Vendor::apple), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("aarch64-fuchsia"), os: Some(Os::fuchsia), @@ -109,6 +121,30 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("aarch64-nintendo-switch-freestanding"), + os: Some(Os::horizon), + arch: Arch::aarch64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::abort, + }, + TargetInfo { + triple: Triple::new_const("aarch64-pc-windows-gnullvm"), + os: Some(Os::windows), + arch: Arch::aarch64, + env: Some(Env::gnu), + vendor: Some(Vendor::pc), + families: Families::windows, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("aarch64-pc-windows-msvc"), os: Some(Os::windows), @@ -361,6 +397,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("arm64_32-apple-watchos"), + os: Some(Os::watchos), + arch: Arch::aarch64, + env: None, + vendor: Some(Vendor::apple), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("armebv7r-none-eabi"), os: None, @@ -649,6 +697,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("armv7k-apple-watchos"), + os: Some(Os::watchos), + arch: Arch::arm, + env: None, + vendor: Some(Vendor::apple), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("armv7r-none-eabi"), os: None, @@ -1441,6 +1501,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv32imac-unknown-xous-elf"), + os: Some(Os::xous), + arch: Arch::riscv32, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("riscv32imc-esp-espidf"), os: Some(Os::espidf), @@ -1861,6 +1933,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("x86_64-apple-watchos-sim"), + os: Some(Os::watchos), + arch: Arch::x86_64, + env: None, + vendor: Some(Vendor::apple), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("x86_64-fortanix-unknown-sgx"), os: Some(Os::unknown), @@ -1921,6 +2005,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("x86_64-pc-windows-gnullvm"), + os: Some(Os::windows), + arch: Arch::x86_64, + env: Some(Env::gnu), + vendor: Some(Vendor::pc), + families: Families::windows, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("x86_64-pc-windows-msvc"), os: Some(Os::windows), @@ -2229,7 +2325,9 @@ impl super::Os { pub const unknown: Os = Os::new_const("unknown"); pub const vxworks: Os = Os::new_const("vxworks"); pub const wasi: Os = Os::new_const("wasi"); + pub const watchos: Os = Os::new_const("watchos"); pub const windows: Os = Os::new_const("windows"); + pub const xous: Os = Os::new_const("xous"); } impl super::Family { diff --git a/tests/eval.rs b/tests/eval.rs index 1b8baa7..b2a89de 100644 --- a/tests/eval.rs +++ b/tests/eval.rs @@ -7,7 +7,7 @@ use cfg_expr::{ struct Target { builtin: &'static cfg_expr::targets::TargetInfo, #[cfg(feature = "targets")] - lexicon: target_lexicon::Triple, + lexicon: Option, } impl Target { @@ -22,16 +22,22 @@ impl Target { // the presence of this triple in most normal cases use target_lexicon as tl; match s { - "avr-unknown-gnu-atmega328" => tl::Triple { + "avr-unknown-gnu-atmega328" => Some(tl::Triple { architecture: tl::Architecture::Avr, vendor: tl::Vendor::Unknown, operating_system: tl::OperatingSystem::Unknown, environment: tl::Environment::Unknown, binary_format: tl::BinaryFormat::Unknown, - }, + }), triple => match triple.parse() { - Ok(l) => l, - Err(e) => panic!("failed to parse '{}': {:?}", triple, e), + Ok(l) => Some(l), + Err(e) => { + // There are enough new weird architectures added in each version of + // Rust that it is difficult to keep target-lexicon aware of all of + // them. So try parsing this triple, but don't fail if it doesn't work. + eprintln!("failed to parse '{}': {:?}", triple, e); + None + } }, } }, @@ -49,14 +55,16 @@ macro_rules! tg_match { if !matches!(tg, TargetPredicate::HasAtomic(_)) && !matches!(tg, TargetPredicate::Panic(_)) { - let linfo = tg.matches(&$target.lexicon); - assert_eq!( - tinfo, linfo, - "{:#?} builtin didn't match lexicon {:#?} for predicate {:#?}", - $target.builtin, $target.lexicon, tg, - ); - - return linfo; + if let Some(l) = &$target.lexicon { + let linfo = tg.matches(l); + assert_eq!( + tinfo, linfo, + "{:#?} builtin didn't match lexicon {:#?} for predicate {:#?}", + $target.builtin, $target.lexicon, tg, + ); + + return linfo; + } } tinfo @@ -74,14 +82,16 @@ macro_rules! tg_match { if !matches!(tg, TargetPredicate::HasAtomic(_)) && !matches!(tg, TargetPredicate::Panic(_)) { - let linfo = tg.matches(&$target.lexicon); - assert_eq!( - tinfo, linfo, - "{:#?} builtin didn't match lexicon {:#?} for predicate {:#?}", - $target.builtin, $target.lexicon, tg, - ); - - return linfo; + if let Some(l) = &$target.lexicon { + let linfo = tg.matches(l); + assert_eq!( + tinfo, linfo, + "{:#?} builtin didn't match lexicon {:#?} for predicate {:#?}", + $target.builtin, $target.lexicon, tg, + ); + + return linfo; + } } tinfo @@ -178,11 +188,7 @@ fn very_specific() { } else { "".to_owned() }, - target - .env - .as_ref() - .map(|e| e.as_str()) - .unwrap_or_else(|| ""), + target.env.as_ref().map_or("", |e| e.as_str()), ); let specific = Expression::parse(&expr).unwrap(); From 1c7eda7192b927b3245f56f4da176d040d0cd038 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Tue, 27 Sep 2022 14:20:57 +0200 Subject: [PATCH 04/18] Release 0.11.0 --- CHANGELOG.md | 4 +++- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e66c4a..a4dcfa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## [0.11.0] - 2022-09-27 ### Changed - [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) updated the builtin target list to 1.64.0. Thanks [@sunshowers](https://github.com/sunshowers)! - [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) bumped the MSRV to 1.58.0. @@ -118,7 +119,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial add of all the things -[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.3...HEAD +[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.11.0...HEAD +[0.11.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.3...0.11.0 [0.10.3]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.2...0.10.3 [0.10.2]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.1...0.10.2 [0.10.1]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.0...0.10.1 diff --git a/Cargo.toml b/Cargo.toml index ccc5f1d..8479229 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cfg-expr" description = "A parser and evaluator for Rust `cfg()` expressions." repository = "https://github.com/EmbarkStudios/cfg-expr" -version = "0.10.3" +version = "0.11.0" authors = [ "Embark ", "Jake Shadle ", From 1065ebcc4991ff88147c0d73792a6595ec11a258 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Tue, 27 Sep 2022 14:22:28 +0200 Subject: [PATCH 05/18] Fix README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 292376d..33a577a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # `⚙️ cfg-expr` -**A parser and evaluator for Rust `cfg()` expressions. Targets as of [Rust 1.58.0](https://forge.rust-lang.org/release/platform-support.html) are supported.** +**A parser and evaluator for Rust `cfg()` expressions. Targets as of [Rust 1.64.0](https://forge.rust-lang.org/release/platform-support.html) are supported.** [![Build Status](https://github.com/EmbarkStudios/cfg-expr/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/cfg-expr/actions?workflow=CI) [![Crates.io](https://img.shields.io/crates/v/cfg-expr.svg)](https://crates.io/crates/cfg-expr) From 9e5b68bc22989e69622b603a1daf70944c8b95d4 Mon Sep 17 00:00:00 2001 From: Rain Date: Sat, 5 Nov 2022 01:47:24 -0700 Subject: [PATCH 06/18] Update targets for Rust 1.65 (#53) * Update targets for Rust 1.65 Also include target-lexicon updates and fixes. * Fix clippy issues on Rust 1.65 --- Cargo.toml | 2 +- src/expr.rs | 9 ++++--- src/expr/parser.rs | 2 ++ src/targets.rs | 10 +++---- src/targets/builtins.rs | 58 +++++++++++++++++++++++++++++++++++++---- tests/eval.rs | 2 +- 6 files changed, 68 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8479229..31ca78a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ targets = ["target-lexicon"] [dependencies] smallvec = "1.8" -target-lexicon = { version = "0.12.4", optional = true } +target-lexicon = { version = "0.12.5", optional = true } [dev-dependencies] similar-asserts = "1.1" diff --git a/src/expr.rs b/src/expr.rs index fcd66ff..41f2103 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -164,6 +164,7 @@ impl TargetMatcher for target_lexicon::Triple { | Environment::Androideabi | Environment::Eabi | Environment::Eabihf + | Environment::Sim ) } else { match env.0.parse::() { @@ -177,7 +178,8 @@ impl TargetMatcher for target_lexicon::Triple { | Environment::Gnuspe | Environment::Gnux32 | Environment::GnuIlp32 - | Environment::Gnueabihf => true, + | Environment::Gnueabihf + | Environment::GnuLlvm => true, // Rust 1.49.0 changed all android targets to have the // gnu environment Environment::Android | Environment::Androideabi @@ -221,7 +223,7 @@ impl TargetMatcher for target_lexicon::Triple { AmdHsa, Bitrig, Cloudabi, Cuda, Darwin, Dragonfly, Emscripten, Espidf, Freebsd, Fuchsia, Haiku, Hermit, Horizon, Illumos, Ios, L4re, Linux, MacOSX, Nebulet, Netbsd, None_, Openbsd, Redox, Solaris, Tvos, Uefi, Unknown, VxWorks, Wasi, - Windows, + Watchos, Windows, }; match self.operating_system { AmdHsa | Bitrig | Cloudabi | Cuda | Hermit | Nebulet | None_ | Uefi => false, @@ -241,7 +243,8 @@ impl TargetMatcher for target_lexicon::Triple { | Redox | Solaris | Tvos - | VxWorks => fam == &crate::targets::Family::unix, + | VxWorks + | Watchos => fam == &crate::targets::Family::unix, Emscripten => { match self.architecture { // asmjs, wasm32 and wasm64 are part of both the wasm and unix families diff --git a/src/expr/parser.rs b/src/expr/parser.rs index ba937b4..83715b5 100644 --- a/src/expr/parser.rs +++ b/src/expr/parser.rs @@ -312,6 +312,8 @@ impl Expression { let key = pred_key.take(); let val = pred_val.take(); + // In this context, the boolean to int conversion is confusing. + #[allow(clippy::bool_to_int_with_if)] let num_predicates = top.predicates.len() + if key.is_some() { 1 } else { 0 } + top.nest_level as usize; diff --git a/src/targets.rs b/src/targets.rs index 8d458b8..b6845f9 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -162,14 +162,14 @@ impl Families { impl Deref for Families { type Target = [Family]; fn deref(&self) -> &Self::Target { - &*self.0 + &self.0 } } impl AsRef<[Family]> for Families { #[inline] fn as_ref(&self) -> &[Family] { - &*self.0 + &self.0 } } @@ -222,14 +222,14 @@ impl HasAtomics { impl Deref for HasAtomics { type Target = [HasAtomic]; fn deref(&self) -> &Self::Target { - &*self.0 + &self.0 } } impl AsRef<[HasAtomic]> for HasAtomics { #[inline] fn as_ref(&self) -> &[HasAtomic] { - &*self.0 + &self.0 } } @@ -364,7 +364,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo> /// versions. /// /// ``` -/// assert_eq!("1.64.0", cfg_expr::targets::rustc_version()); +/// assert_eq!("1.65.0", cfg_expr::targets::rustc_version()); /// ``` pub fn rustc_version() -> &'static str { builtins::RUSTC_VERSION diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index 8a2d3c0..db0e141 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.64.0"; +pub(crate) const RUSTC_VERSION: &str = "1.65.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -142,7 +142,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::windows, pointer_width: 64, endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, TargetInfo { @@ -154,7 +154,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::windows, pointer_width: 64, endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, TargetInfo { @@ -286,7 +286,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::new_const(&[]), pointer_width: 64, endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::abort, }, TargetInfo { @@ -298,7 +298,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::windows, pointer_width: 64, endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, TargetInfo { @@ -406,6 +406,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::unix, pointer_width: 32, endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::unwind, + }, + TargetInfo { + triple: Triple::new_const("armeb-unknown-linux-gnueabi"), + os: Some(Os::linux), + arch: Arch::arm, + env: Some(Env::gnu), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 32, + endian: Endian::big, has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, @@ -433,6 +445,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("armv4t-none-eabi"), + os: None, + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("armv4t-unknown-linux-gnueabi"), os: Some(Os::linux), @@ -1393,6 +1417,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("powerpc64-unknown-openbsd"), + os: Some(Os::openbsd), + arch: Arch::powerpc64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::big, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("powerpc64-wrs-vxworks"), os: Some(Os::vxworks), @@ -1585,6 +1621,18 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("riscv64gc-unknown-openbsd"), + os: Some(Os::openbsd), + arch: Arch::riscv64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("riscv64imac-unknown-none-elf"), os: None, diff --git a/tests/eval.rs b/tests/eval.rs index b2a89de..f0c7c74 100644 --- a/tests/eval.rs +++ b/tests/eval.rs @@ -29,7 +29,7 @@ impl Target { environment: tl::Environment::Unknown, binary_format: tl::BinaryFormat::Unknown, }), - triple => match triple.parse() { + triple => match triple.parse::() { Ok(l) => Some(l), Err(e) => { // There are enough new weird architectures added in each version of From c2e3b86fc2b058fadb6537e57f29158ba59f1772 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 7 Nov 2022 08:55:10 +0100 Subject: [PATCH 07/18] Add support for `abi` if it is present (#54) * Parse target_abi if it's present even though it's unstable * Add missing abi to new builtins Co-authored-by: Carol (Nichols || Goulding) --- src/expr.rs | 19 +++- src/expr/parser.rs | 1 + src/targets.rs | 8 ++ src/targets/builtins.rs | 193 ++++++++++++++++++++++++++++++++++++++++ tests/eval.rs | 54 +++++++++++ update/src/main.rs | 13 +++ 6 files changed, 286 insertions(+), 2 deletions(-) diff --git a/src/expr.rs b/src/expr.rs index 41f2103..ed1f4e1 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -30,6 +30,8 @@ use crate::targets as targ; /// All predicates that pertains to a target, except for `target_feature` #[derive(Clone, PartialEq, Eq, Debug)] pub enum TargetPredicate { + /// [target_abi](https://github.com/rust-lang/rust/issues/80970) + Abi(targ::Abi), /// [target_arch](https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch) Arch(targ::Arch), /// [target_endian](https://doc.rust-lang.org/reference/conditional-compilation.html#target_endian) @@ -59,10 +61,15 @@ pub trait TargetMatcher { impl TargetMatcher for targ::TargetInfo { fn matches(&self, tp: &TargetPredicate) -> bool { use TargetPredicate::{ - Arch, Endian, Env, Family, HasAtomic, Os, Panic, PointerWidth, Vendor, + Abi, Arch, Endian, Env, Family, HasAtomic, Os, Panic, PointerWidth, Vendor, }; match tp { + // The ABI is allowed to be an empty string + Abi(abi) => match &self.abi { + Some(a) => abi == a, + None => abi.0.is_empty(), + }, Arch(a) => a == &self.arch, Endian(end) => *end == self.endian, // The environment is allowed to be an empty string @@ -90,10 +97,14 @@ impl TargetMatcher for target_lexicon::Triple { fn matches(&self, tp: &TargetPredicate) -> bool { use target_lexicon::*; use TargetPredicate::{ - Arch, Endian, Env, Family, HasAtomic, Os, Panic, PointerWidth, Vendor, + Abi, Arch, Endian, Env, Family, HasAtomic, Os, Panic, PointerWidth, Vendor, }; match tp { + Abi(_) => { + // `target_abi` is unstable. Assume false for this. + false + } Arch(arch) => { if arch == &targ::Arch::x86 { matches!(self.architecture, Architecture::X86_32(_)) @@ -359,6 +370,7 @@ impl TargetPredicate { #[derive(Clone, Debug)] pub(crate) enum Which { + Abi, Arch, Endian(targ::Endian), Env, @@ -422,6 +434,9 @@ impl InnerPredicate { match self { IP::Target(it) => match &it.which { + Which::Abi => Target(TargetPredicate::Abi(targ::Abi::new( + s[it.span.clone().unwrap()].to_owned(), + ))), Which::Arch => Target(TargetPredicate::Arch(targ::Arch::new( s[it.span.clone().unwrap()].to_owned(), ))), diff --git a/src/expr/parser.rs b/src/expr/parser.rs index 83715b5..3f3706c 100644 --- a/src/expr/parser.rs +++ b/src/expr/parser.rs @@ -144,6 +144,7 @@ impl Expression { } let tp = match &target_key[7..] { + "abi" => tp!(Abi), "arch" => tp!(Arch), "feature" => { if val.is_empty() { diff --git a/src/targets.rs b/src/targets.rs index b6845f9..ba91d16 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -11,6 +11,10 @@ pub use builtins::ALL_BUILTINS; #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct Triple(pub Cow<'static, str>); +/// The "abi" field +#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +pub struct Abi(pub Cow<'static, str>); + /// The "architecture" field #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct Arch(pub Cow<'static, str>); @@ -79,6 +83,7 @@ macro_rules! field_impls { } field_impls!(Triple); +field_impls!(Abi); field_impls!(Arch); field_impls!(Vendor); field_impls!(Os); @@ -316,6 +321,9 @@ pub struct TargetInfo { /// [target_os](https://doc.rust-lang.org/reference/conditional-compilation.html#target_os) /// predicate. pub os: Option, + /// The target's ABI, if any. Used by the + /// [target_abi](https://github.com/rust-lang/rust/issues/80970) predicate. + pub abi: Option, /// The target's CPU architecture. Used by the /// [target_arch](https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch) /// predicate. diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index db0e141..e0e0949 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -16,6 +16,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-apple-darwin"), os: Some(Os::macos), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::apple), @@ -28,6 +29,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-apple-ios"), os: Some(Os::ios), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::apple), @@ -40,6 +42,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-apple-ios-macabi"), os: Some(Os::ios), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::apple), @@ -52,6 +55,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-apple-ios-sim"), os: Some(Os::ios), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::apple), @@ -64,6 +68,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-apple-tvos"), os: Some(Os::tvos), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::apple), @@ -76,6 +81,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-apple-watchos-sim"), os: Some(Os::watchos), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::apple), @@ -88,6 +94,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-fuchsia"), os: Some(Os::fuchsia), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -100,6 +107,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-kmc-solid_asp3"), os: Some(Os::solid_asp3), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::kmc), @@ -112,6 +120,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-linux-android"), os: Some(Os::android), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -124,6 +133,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-nintendo-switch-freestanding"), os: Some(Os::horizon), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -136,6 +146,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-pc-windows-gnullvm"), os: Some(Os::windows), + abi: None, arch: Arch::aarch64, env: Some(Env::gnu), vendor: Some(Vendor::pc), @@ -148,6 +159,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-pc-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::aarch64, env: Some(Env::msvc), vendor: Some(Vendor::pc), @@ -160,6 +172,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -172,6 +185,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-hermit"), os: Some(Os::hermit), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -184,6 +198,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::aarch64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -196,6 +211,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-linux-gnu_ilp32"), os: Some(Os::linux), + abi: None, arch: Arch::aarch64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -208,6 +224,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::aarch64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -220,6 +237,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-netbsd"), os: Some(Os::netbsd), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -232,6 +250,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-none"), os: None, + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -244,6 +263,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-none-softfloat"), os: None, + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -256,6 +276,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-openbsd"), os: Some(Os::openbsd), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -268,6 +289,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-redox"), os: Some(Os::redox), + abi: None, arch: Arch::aarch64, env: Some(Env::relibc), vendor: Some(Vendor::unknown), @@ -280,6 +302,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-unknown-uefi"), os: Some(Os::uefi), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::unknown), @@ -292,6 +315,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-uwp-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::aarch64, env: Some(Env::msvc), vendor: Some(Vendor::uwp), @@ -304,6 +328,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64-wrs-vxworks"), os: Some(Os::vxworks), + abi: None, arch: Arch::aarch64, env: Some(Env::gnu), vendor: Some(Vendor::wrs), @@ -316,6 +341,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64_be-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::aarch64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -328,6 +354,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("aarch64_be-unknown-linux-gnu_ilp32"), os: Some(Os::linux), + abi: None, arch: Arch::aarch64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -340,6 +367,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("arm-linux-androideabi"), os: Some(Os::android), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -352,6 +380,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("arm-unknown-linux-gnueabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -364,6 +393,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("arm-unknown-linux-gnueabihf"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -376,6 +406,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("arm-unknown-linux-musleabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -388,6 +419,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("arm-unknown-linux-musleabihf"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -400,6 +432,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("arm64_32-apple-watchos"), os: Some(Os::watchos), + abi: None, arch: Arch::aarch64, env: None, vendor: Some(Vendor::apple), @@ -412,6 +445,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armeb-unknown-linux-gnueabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -424,6 +458,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armebv7r-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -436,6 +471,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armebv7r-none-eabihf"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -448,6 +484,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv4t-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -460,6 +497,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv4t-unknown-linux-gnueabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -472,6 +510,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv5te-unknown-linux-gnueabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -484,6 +523,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv5te-unknown-linux-musleabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -496,6 +536,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv5te-unknown-linux-uclibceabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::uclibc), vendor: Some(Vendor::unknown), @@ -508,6 +549,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv6-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::arm, env: Some(Env::gnueabihf), vendor: Some(Vendor::unknown), @@ -520,6 +562,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv6-unknown-netbsd-eabihf"), os: Some(Os::netbsd), + abi: None, arch: Arch::arm, env: Some(Env::eabihf), vendor: Some(Vendor::unknown), @@ -532,6 +575,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv6k-nintendo-3ds"), os: Some(Os::horizon), + abi: None, arch: Arch::arm, env: Some(Env::newlib), vendor: Some(Vendor::nintendo), @@ -544,6 +588,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-apple-ios"), os: Some(Os::ios), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::apple), @@ -556,6 +601,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-linux-androideabi"), os: Some(Os::android), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -568,6 +614,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::arm, env: Some(Env::gnueabihf), vendor: Some(Vendor::unknown), @@ -580,6 +627,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-linux-gnueabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -592,6 +640,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-linux-gnueabihf"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -604,6 +653,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-linux-musleabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -616,6 +666,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-linux-musleabihf"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -628,6 +679,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-linux-uclibceabi"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::uclibc), vendor: Some(Vendor::unknown), @@ -640,6 +692,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-linux-uclibceabihf"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::uclibc), vendor: Some(Vendor::unknown), @@ -652,6 +705,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-unknown-netbsd-eabihf"), os: Some(Os::netbsd), + abi: None, arch: Arch::arm, env: Some(Env::eabihf), vendor: Some(Vendor::unknown), @@ -664,6 +718,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7-wrs-vxworks-eabihf"), os: Some(Os::vxworks), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::wrs), @@ -676,6 +731,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7a-kmc-solid_asp3-eabi"), os: Some(Os::solid_asp3), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::kmc), @@ -688,6 +744,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7a-kmc-solid_asp3-eabihf"), os: Some(Os::solid_asp3), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::kmc), @@ -700,6 +757,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7a-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -712,6 +770,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7a-none-eabihf"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -724,6 +783,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7k-apple-watchos"), os: Some(Os::watchos), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::apple), @@ -736,6 +796,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7r-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -748,6 +809,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7r-none-eabihf"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -760,6 +822,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("armv7s-apple-ios"), os: Some(Os::ios), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::apple), @@ -772,6 +835,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("asmjs-unknown-emscripten"), os: Some(Os::emscripten), + abi: None, arch: Arch::wasm32, env: None, vendor: Some(Vendor::unknown), @@ -784,6 +848,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("avr-unknown-gnu-atmega328"), os: None, + abi: None, arch: Arch::avr, env: None, vendor: Some(Vendor::unknown), @@ -796,6 +861,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("bpfeb-unknown-none"), os: None, + abi: None, arch: Arch::bpf, env: None, vendor: Some(Vendor::unknown), @@ -808,6 +874,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("bpfel-unknown-none"), os: None, + abi: None, arch: Arch::bpf, env: None, vendor: Some(Vendor::unknown), @@ -820,6 +887,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("hexagon-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::hexagon, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -832,6 +900,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i386-apple-ios"), os: Some(Os::ios), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::apple), @@ -844,6 +913,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i586-pc-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::x86, env: Some(Env::msvc), vendor: Some(Vendor::pc), @@ -856,6 +926,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i586-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::x86, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -868,6 +939,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i586-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::x86, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -880,6 +952,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-apple-darwin"), os: Some(Os::macos), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::apple), @@ -892,6 +965,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-linux-android"), os: Some(Os::android), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::unknown), @@ -904,6 +978,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-pc-windows-gnu"), os: Some(Os::windows), + abi: None, arch: Arch::x86, env: Some(Env::gnu), vendor: Some(Vendor::pc), @@ -916,6 +991,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-pc-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::x86, env: Some(Env::msvc), vendor: Some(Vendor::pc), @@ -928,6 +1004,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::unknown), @@ -940,6 +1017,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-unknown-haiku"), os: Some(Os::haiku), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::unknown), @@ -952,6 +1030,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::x86, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -964,6 +1043,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::x86, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -976,6 +1056,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-unknown-netbsd"), os: Some(Os::netbsd), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::unknown), @@ -988,6 +1069,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-unknown-openbsd"), os: Some(Os::openbsd), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::unknown), @@ -1000,6 +1082,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-unknown-uefi"), os: Some(Os::uefi), + abi: None, arch: Arch::x86, env: None, vendor: Some(Vendor::unknown), @@ -1012,6 +1095,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-uwp-windows-gnu"), os: Some(Os::windows), + abi: None, arch: Arch::x86, env: Some(Env::gnu), vendor: Some(Vendor::uwp), @@ -1024,6 +1108,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-uwp-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::x86, env: Some(Env::msvc), vendor: Some(Vendor::uwp), @@ -1036,6 +1121,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("i686-wrs-vxworks"), os: Some(Os::vxworks), + abi: None, arch: Arch::x86, env: Some(Env::gnu), vendor: Some(Vendor::wrs), @@ -1048,6 +1134,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("m68k-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::m68k, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1060,6 +1147,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1072,6 +1160,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1084,6 +1173,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips-unknown-linux-uclibc"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::uclibc), vendor: Some(Vendor::unknown), @@ -1096,6 +1186,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips64-openwrt-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::mips64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1108,6 +1199,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips64-unknown-linux-gnuabi64"), os: Some(Os::linux), + abi: None, arch: Arch::mips64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1120,6 +1212,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips64-unknown-linux-muslabi64"), os: Some(Os::linux), + abi: None, arch: Arch::mips64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1132,6 +1225,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips64el-unknown-linux-gnuabi64"), os: Some(Os::linux), + abi: None, arch: Arch::mips64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1144,6 +1238,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mips64el-unknown-linux-muslabi64"), os: Some(Os::linux), + abi: None, arch: Arch::mips64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1156,6 +1251,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsel-sony-psp"), os: Some(Os::psp), + abi: None, arch: Arch::mips, env: None, vendor: Some(Vendor::sony), @@ -1168,6 +1264,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsel-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1180,6 +1277,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsel-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1192,6 +1290,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsel-unknown-linux-uclibc"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::uclibc), vendor: Some(Vendor::unknown), @@ -1204,6 +1303,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsel-unknown-none"), os: None, + abi: None, arch: Arch::mips, env: None, vendor: Some(Vendor::unknown), @@ -1216,6 +1316,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsisa32r6-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1228,6 +1329,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsisa32r6el-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::mips, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1240,6 +1342,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsisa64r6-unknown-linux-gnuabi64"), os: Some(Os::linux), + abi: None, arch: Arch::mips64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1252,6 +1355,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("mipsisa64r6el-unknown-linux-gnuabi64"), os: Some(Os::linux), + abi: None, arch: Arch::mips64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1264,6 +1368,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("msp430-none-elf"), os: None, + abi: None, arch: Arch::msp430, env: None, vendor: Some(Vendor::unknown), @@ -1276,6 +1381,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("nvptx64-nvidia-cuda"), os: Some(Os::cuda), + abi: None, arch: Arch::nvptx64, env: None, vendor: Some(Vendor::nvidia), @@ -1288,6 +1394,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::powerpc, env: None, vendor: Some(Vendor::unknown), @@ -1300,6 +1407,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::powerpc, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1312,6 +1420,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-unknown-linux-gnuspe"), os: Some(Os::linux), + abi: None, arch: Arch::powerpc, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1324,6 +1433,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::powerpc, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1336,6 +1446,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-unknown-netbsd"), os: Some(Os::netbsd), + abi: None, arch: Arch::powerpc, env: None, vendor: Some(Vendor::unknown), @@ -1348,6 +1459,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-unknown-openbsd"), os: Some(Os::openbsd), + abi: None, arch: Arch::powerpc, env: None, vendor: Some(Vendor::unknown), @@ -1360,6 +1472,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-wrs-vxworks"), os: Some(Os::vxworks), + abi: None, arch: Arch::powerpc, env: Some(Env::gnu), vendor: Some(Vendor::wrs), @@ -1372,6 +1485,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc-wrs-vxworks-spe"), os: Some(Os::vxworks), + abi: None, arch: Arch::powerpc, env: Some(Env::gnu), vendor: Some(Vendor::wrs), @@ -1384,6 +1498,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::powerpc64, env: None, vendor: Some(Vendor::unknown), @@ -1396,6 +1511,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::powerpc64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1408,6 +1524,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::powerpc64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1420,6 +1537,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64-unknown-openbsd"), os: Some(Os::openbsd), + abi: None, arch: Arch::powerpc64, env: None, vendor: Some(Vendor::unknown), @@ -1432,6 +1550,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64-wrs-vxworks"), os: Some(Os::vxworks), + abi: None, arch: Arch::powerpc64, env: Some(Env::gnu), vendor: Some(Vendor::wrs), @@ -1444,6 +1563,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64le-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::powerpc64, env: None, vendor: Some(Vendor::unknown), @@ -1456,6 +1576,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64le-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::powerpc64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1468,6 +1589,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("powerpc64le-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::powerpc64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1480,6 +1602,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32gc-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::riscv32, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1492,6 +1615,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32gc-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::riscv32, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1504,6 +1628,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32i-unknown-none-elf"), os: None, + abi: None, arch: Arch::riscv32, env: None, vendor: Some(Vendor::unknown), @@ -1516,6 +1641,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32im-unknown-none-elf"), os: None, + abi: None, arch: Arch::riscv32, env: None, vendor: Some(Vendor::unknown), @@ -1528,6 +1654,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32imac-unknown-none-elf"), os: None, + abi: None, arch: Arch::riscv32, env: None, vendor: Some(Vendor::unknown), @@ -1540,6 +1667,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32imac-unknown-xous-elf"), os: Some(Os::xous), + abi: None, arch: Arch::riscv32, env: None, vendor: Some(Vendor::unknown), @@ -1552,6 +1680,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32imc-esp-espidf"), os: Some(Os::espidf), + abi: None, arch: Arch::riscv32, env: Some(Env::newlib), vendor: Some(Vendor::espressif), @@ -1564,6 +1693,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv32imc-unknown-none-elf"), os: None, + abi: None, arch: Arch::riscv32, env: None, vendor: Some(Vendor::unknown), @@ -1576,6 +1706,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv64gc-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::riscv64, env: None, vendor: Some(Vendor::unknown), @@ -1588,6 +1719,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv64gc-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::riscv64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1600,6 +1732,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv64gc-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::riscv64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1612,6 +1745,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv64gc-unknown-none-elf"), os: None, + abi: None, arch: Arch::riscv64, env: None, vendor: Some(Vendor::unknown), @@ -1624,6 +1758,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv64gc-unknown-openbsd"), os: Some(Os::openbsd), + abi: None, arch: Arch::riscv64, env: None, vendor: Some(Vendor::unknown), @@ -1636,6 +1771,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("riscv64imac-unknown-none-elf"), os: None, + abi: None, arch: Arch::riscv64, env: None, vendor: Some(Vendor::unknown), @@ -1648,6 +1784,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("s390x-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::s390x, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1660,6 +1797,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("s390x-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::s390x, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1672,6 +1810,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("sparc-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::sparc, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1684,6 +1823,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("sparc64-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::sparc64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1696,6 +1836,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("sparc64-unknown-netbsd"), os: Some(Os::netbsd), + abi: None, arch: Arch::sparc64, env: None, vendor: Some(Vendor::unknown), @@ -1708,6 +1849,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("sparc64-unknown-openbsd"), os: Some(Os::openbsd), + abi: None, arch: Arch::sparc64, env: None, vendor: Some(Vendor::unknown), @@ -1720,6 +1862,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("sparcv9-sun-solaris"), os: Some(Os::solaris), + abi: None, arch: Arch::sparc64, env: None, vendor: Some(Vendor::sun), @@ -1732,6 +1875,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv4t-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1744,6 +1888,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv6m-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1756,6 +1901,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7a-pc-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::arm, env: Some(Env::msvc), vendor: Some(Vendor::pc), @@ -1768,6 +1914,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7a-uwp-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::arm, env: Some(Env::msvc), vendor: Some(Vendor::uwp), @@ -1780,6 +1927,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7em-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1792,6 +1940,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7em-none-eabihf"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1804,6 +1953,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7m-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1816,6 +1966,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7neon-linux-androideabi"), os: Some(Os::android), + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1828,6 +1979,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7neon-unknown-linux-gnueabihf"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -1840,6 +1992,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv7neon-unknown-linux-musleabihf"), os: Some(Os::linux), + abi: None, arch: Arch::arm, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -1852,6 +2005,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv8m.base-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1864,6 +2018,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv8m.main-none-eabi"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1876,6 +2031,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("thumbv8m.main-none-eabihf"), os: None, + abi: None, arch: Arch::arm, env: None, vendor: Some(Vendor::unknown), @@ -1888,6 +2044,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("wasm32-unknown-emscripten"), os: Some(Os::emscripten), + abi: None, arch: Arch::wasm32, env: None, vendor: Some(Vendor::unknown), @@ -1900,6 +2057,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("wasm32-unknown-unknown"), os: Some(Os::unknown), + abi: None, arch: Arch::wasm32, env: None, vendor: Some(Vendor::unknown), @@ -1912,6 +2070,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("wasm32-wasi"), os: Some(Os::wasi), + abi: None, arch: Arch::wasm32, env: None, vendor: Some(Vendor::unknown), @@ -1924,6 +2083,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("wasm64-unknown-unknown"), os: Some(Os::unknown), + abi: None, arch: Arch::wasm64, env: None, vendor: Some(Vendor::unknown), @@ -1936,6 +2096,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-apple-darwin"), os: Some(Os::macos), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::apple), @@ -1948,6 +2109,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-apple-ios"), os: Some(Os::ios), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::apple), @@ -1960,6 +2122,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-apple-ios-macabi"), os: Some(Os::ios), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::apple), @@ -1972,6 +2135,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-apple-tvos"), os: Some(Os::tvos), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::apple), @@ -1984,6 +2148,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-apple-watchos-sim"), os: Some(Os::watchos), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::apple), @@ -1996,6 +2161,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-fortanix-unknown-sgx"), os: Some(Os::unknown), + abi: None, arch: Arch::x86_64, env: Some(Env::sgx), vendor: Some(Vendor::fortanix), @@ -2008,6 +2174,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-fuchsia"), os: Some(Os::fuchsia), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2020,6 +2187,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-linux-android"), os: Some(Os::android), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2032,6 +2200,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-pc-solaris"), os: Some(Os::solaris), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::pc), @@ -2044,6 +2213,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-pc-windows-gnu"), os: Some(Os::windows), + abi: None, arch: Arch::x86_64, env: Some(Env::gnu), vendor: Some(Vendor::pc), @@ -2056,6 +2226,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-pc-windows-gnullvm"), os: Some(Os::windows), + abi: None, arch: Arch::x86_64, env: Some(Env::gnu), vendor: Some(Vendor::pc), @@ -2068,6 +2239,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-pc-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::x86_64, env: Some(Env::msvc), vendor: Some(Vendor::pc), @@ -2080,6 +2252,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-sun-solaris"), os: Some(Os::solaris), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::sun), @@ -2092,6 +2265,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-dragonfly"), os: Some(Os::dragonfly), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2104,6 +2278,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-freebsd"), os: Some(Os::freebsd), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2116,6 +2291,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-haiku"), os: Some(Os::haiku), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2128,6 +2304,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-hermit"), os: Some(Os::hermit), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2140,6 +2317,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-illumos"), os: Some(Os::illumos), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2152,6 +2330,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-l4re-uclibc"), os: Some(Os::l4re), + abi: None, arch: Arch::x86_64, env: Some(Env::uclibc), vendor: Some(Vendor::unknown), @@ -2164,6 +2343,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-linux-gnu"), os: Some(Os::linux), + abi: None, arch: Arch::x86_64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -2176,6 +2356,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-linux-gnux32"), os: Some(Os::linux), + abi: None, arch: Arch::x86_64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -2188,6 +2369,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-linux-musl"), os: Some(Os::linux), + abi: None, arch: Arch::x86_64, env: Some(Env::musl), vendor: Some(Vendor::unknown), @@ -2200,6 +2382,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-netbsd"), os: Some(Os::netbsd), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2212,6 +2395,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-none"), os: None, + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2224,6 +2408,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-none-linuxkernel"), os: None, + abi: None, arch: Arch::x86_64, env: Some(Env::gnu), vendor: Some(Vendor::unknown), @@ -2236,6 +2421,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-openbsd"), os: Some(Os::openbsd), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2248,6 +2434,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-redox"), os: Some(Os::redox), + abi: None, arch: Arch::x86_64, env: Some(Env::relibc), vendor: Some(Vendor::unknown), @@ -2260,6 +2447,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-unknown-uefi"), os: Some(Os::uefi), + abi: None, arch: Arch::x86_64, env: None, vendor: Some(Vendor::unknown), @@ -2272,6 +2460,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-uwp-windows-gnu"), os: Some(Os::windows), + abi: None, arch: Arch::x86_64, env: Some(Env::gnu), vendor: Some(Vendor::uwp), @@ -2284,6 +2473,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-uwp-windows-msvc"), os: Some(Os::windows), + abi: None, arch: Arch::x86_64, env: Some(Env::msvc), vendor: Some(Vendor::uwp), @@ -2296,6 +2486,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { triple: Triple::new_const("x86_64-wrs-vxworks"), os: Some(Os::vxworks), + abi: None, arch: Arch::x86_64, env: Some(Env::gnu), vendor: Some(Vendor::wrs), @@ -2307,6 +2498,8 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ }, ]; +impl super::Abi {} + impl super::Arch { pub const aarch64: Arch = Arch::new_const("aarch64"); pub const arm: Arch = Arch::new_const("arm"); diff --git a/tests/eval.rs b/tests/eval.rs index f0c7c74..7eda39c 100644 --- a/tests/eval.rs +++ b/tests/eval.rs @@ -253,6 +253,60 @@ fn complex() { assert!(!complex.eval(|pred| tg_match!(pred, android))); } +#[test] +fn unstable_target_abi() { + let linux_gnu = Target::make("x86_64-unknown-linux-gnu"); + let linux_musl = Target::make("x86_64-unknown-linux-musl"); + let windows_msvc = Target::make("x86_64-pc-windows-msvc"); + let mac = Target::make("x86_64-apple-darwin"); + let android = Target::make("aarch64-linux-android"); + + let target_with_abi_that_matches = cfg_expr::targets::TargetInfo { + triple: cfg_expr::targets::Triple::new_const("aarch64-apple-darwin"), + os: None, + abi: Some(cfg_expr::targets::Abi::new_const("eabihf")), + arch: cfg_expr::targets::Arch::aarch64, + env: None, + vendor: None, + families: cfg_expr::targets::Families::unix, + pointer_width: 64, + endian: cfg_expr::targets::Endian::little, + has_atomics: cfg_expr::targets::HasAtomics::atomic_8_16_32_64_128_ptr, + panic: cfg_expr::targets::Panic::unwind, + }; + + let target_with_abi_that_doesnt_match = cfg_expr::targets::TargetInfo { + abi: Some(cfg_expr::targets::Abi::new_const("ilp32")), + ..target_with_abi_that_matches.clone() + }; + + let abi_pred = + Expression::parse(r#"cfg(any(target_arch = "wasm32", target_abi = "eabihf"))"#).unwrap(); + + // Should match a specified target_abi that's the same + assert!(abi_pred.eval(|pred| { + match pred { + Predicate::Target(tp) => tp.matches(&target_with_abi_that_matches), + _ => false, + } + })); + + // Should *not* match a specified target_abi that isn't the same + assert!(!abi_pred.eval(|pred| { + match pred { + Predicate::Target(tp) => tp.matches(&target_with_abi_that_doesnt_match), + _ => false, + } + })); + + // Should *not* match any builtins at this point because target_abi isn't stable + assert!(!abi_pred.eval(|pred| tg_match!(pred, linux_gnu))); + assert!(!abi_pred.eval(|pred| tg_match!(pred, linux_musl))); + assert!(!abi_pred.eval(|pred| tg_match!(pred, mac))); + assert!(!abi_pred.eval(|pred| tg_match!(pred, windows_msvc))); + assert!(!abi_pred.eval(|pred| tg_match!(pred, android))); +} + #[test] fn wasm_family() { let wasm = Expression::parse(r#"cfg(target_family = "wasm")"#).unwrap(); diff --git a/update/src/main.rs b/update/src/main.rs index a2409cf..47d9648 100644 --- a/update/src/main.rs +++ b/update/src/main.rs @@ -85,6 +85,7 @@ fn real_main() -> Result<(), String> { // triple even if the only part that matters is the architecture //let mut arches = HashMap::new(); + let mut abis: Vec = Vec::new(); let mut arches: Vec = Vec::new(); let mut vendors: Vec = Vec::new(); let mut oses: Vec = Vec::new(); @@ -116,6 +117,7 @@ fn real_main() -> Result<(), String> { let kv = String::from_utf8(output.stdout).unwrap(); //let mut num_feats = 0; + let mut abi = None; let mut arch = None; let mut endian = None; let mut env = None; @@ -140,6 +142,11 @@ fn real_main() -> Result<(), String> { "panic" => { panic = Some(val); } + "target_abi" => { + if !val.is_empty() { + abi = Some(val) + } + } "target_arch" => { arch = Some(val); // if arches.get(val).is_none() { @@ -225,6 +232,7 @@ fn real_main() -> Result<(), String> { } } + insert(abi, &mut abis); insert(arch, &mut arches); insert(vendor, &mut vendors); insert(os, &mut oses); @@ -251,6 +259,7 @@ fn real_main() -> Result<(), String> { " TargetInfo {{ triple: Triple::new_const(\"{triple}\"), os: {os}, + abi: {abi}, arch: Arch::{arch}, env: {env}, vendor: {vendor}, @@ -264,6 +273,9 @@ fn real_main() -> Result<(), String> { os = os .map(|os| format!("Some(Os::{})", os)) .unwrap_or_else(|| "None".to_owned()), + abi = abi + .map(|a| format!("Some(Abi::{})", a)) + .unwrap_or_else(|| "None".to_owned()), arch = arch.expect("target had no arch"), env = env .map(|e| format!("Some(Env::{})", e)) @@ -280,6 +292,7 @@ fn real_main() -> Result<(), String> { writeln!(out, "];").unwrap(); + write_impls(&mut out, "Abi", abis); write_impls(&mut out, "Arch", arches); write_impls(&mut out, "Vendor", vendors); write_impls(&mut out, "Os", oses); From a5f6d19c758907104d92d789b9a184dfe7525e3c Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 7 Nov 2022 08:59:36 +0100 Subject: [PATCH 08/18] Update CHANGELOG --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4dcfa3..aecb251 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## Changed +- [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) updated the builtin target list to 1.65.0. Thanks [@sunshowers](https://github.com/sunshowers)! + +## Added +- [PR#52](https://github.com/EmbarkStudios/cfg-expr/pull/52) added support for `abi`, which is currently nightly only, but should have no affect on stable. Thanks [@carols10cents](https://github.com/carols10cents)! + ## [0.11.0] - 2022-09-27 ### Changed - [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) updated the builtin target list to 1.64.0. Thanks [@sunshowers](https://github.com/sunshowers)! From d6f8a002c020b06506a56bffc03116b2fbbea3be Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 7 Nov 2022 08:59:58 +0100 Subject: [PATCH 09/18] Release 0.12.0 --- CHANGELOG.md | 4 +++- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aecb251..b5f5c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## [0.12.0] - 2022-11-07 ## Changed - [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) updated the builtin target list to 1.65.0. Thanks [@sunshowers](https://github.com/sunshowers)! @@ -125,7 +126,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial add of all the things -[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.11.0...HEAD +[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.12.0...HEAD +[0.12.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.11.0...0.12.0 [0.11.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.3...0.11.0 [0.10.3]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.2...0.10.3 [0.10.2]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.1...0.10.2 diff --git a/Cargo.toml b/Cargo.toml index 31ca78a..c6c707a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cfg-expr" description = "A parser and evaluator for Rust `cfg()` expressions." repository = "https://github.com/EmbarkStudios/cfg-expr" -version = "0.11.0" +version = "0.12.0" authors = [ "Embark ", "Jake Shadle ", From 8db9e4fcfe5012a420997cc68adb10d85e1f1e60 Mon Sep 17 00:00:00 2001 From: Rain Date: Mon, 19 Dec 2022 02:23:47 -0800 Subject: [PATCH 10/18] Update targets for Rust 1.66 (#56) --- README.md | 4 ++-- src/targets.rs | 2 +- src/targets/builtins.rs | 28 +++++++++++++++++++++++++++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 33a577a..b29a450 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # `⚙️ cfg-expr` -**A parser and evaluator for Rust `cfg()` expressions. Targets as of [Rust 1.64.0](https://forge.rust-lang.org/release/platform-support.html) are supported.** +**A parser and evaluator for Rust `cfg()` expressions. Targets as of [Rust 1.66.0](https://forge.rust-lang.org/release/platform-support.html) are supported.** [![Build Status](https://github.com/EmbarkStudios/cfg-expr/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/cfg-expr/actions?workflow=CI) [![Crates.io](https://img.shields.io/crates/v/cfg-expr.svg)](https://crates.io/crates/cfg-expr) @@ -22,7 +22,7 @@ `cfg-expr` is a crate that can be used to parse and evaluate Rust `cfg()` expressions, both as declarable in Rust code itself, as well in cargo manifests' `[target.'cfg()'.dependencies]` sections. -It contains a list of all builtin targets known to rustc as of `1.58.0` that can be used to determine if a particular cfg expression is satisfiable. +It contains a list of all builtin targets known to rustc as of `1.66.0` that can be used to determine if a particular cfg expression is satisfiable. ```rust use cfg_expr::{targets::get_builtin_target_by_triple, Expression, Predicate}; diff --git a/src/targets.rs b/src/targets.rs index ba91d16..e6c0d72 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -372,7 +372,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo> /// versions. /// /// ``` -/// assert_eq!("1.65.0", cfg_expr::targets::rustc_version()); +/// assert_eq!("1.66.0", cfg_expr::targets::rustc_version()); /// ``` pub fn rustc_version() -> &'static str { builtins::RUSTC_VERSION diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index e0e0949..ecf6706 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.65.0"; +pub(crate) const RUSTC_VERSION: &str = "1.66.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -507,6 +507,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("armv5te-none-eabi"), + os: None, + abi: None, + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("armv5te-unknown-linux-gnueabi"), os: Some(Os::linux), @@ -1885,6 +1898,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::new_const(&[]), panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("thumbv5te-none-eabi"), + os: None, + abi: None, + arch: Arch::arm, + env: None, + vendor: Some(Vendor::unknown), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("thumbv6m-none-eabi"), os: None, From 81681a4b10aad7e095cc18a20427c7ebc0e7db24 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 19 Dec 2022 12:34:35 +0100 Subject: [PATCH 11/18] Update CHANGELOG --- CHANGELOG.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5f5c88..40c7141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,12 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#56](https://github.com/EmbarkStudios/cfg-expr/pull/56) updated the builtin target list to 1.66.0. Thanks [@sunshowers](https://github.com/sunshowers)! + ## [0.12.0] - 2022-11-07 -## Changed -- [PR#51](https://github.com/EmbarkStudios/cfg-expr/pull/51) updated the builtin target list to 1.65.0. Thanks [@sunshowers](https://github.com/sunshowers)! +### Changed +- [PR#53](https://github.com/EmbarkStudios/cfg-expr/pull/53) updated the builtin target list to 1.65.0. Thanks [@sunshowers](https://github.com/sunshowers)! -## Added -- [PR#52](https://github.com/EmbarkStudios/cfg-expr/pull/52) added support for `abi`, which is currently nightly only, but should have no affect on stable. Thanks [@carols10cents](https://github.com/carols10cents)! +### Added +- [PR#54](https://github.com/EmbarkStudios/cfg-expr/pull/54) added support for `abi`, which is currently nightly only, but should have no affect on stable. Thanks [@carols10cents](https://github.com/carols10cents)! ## [0.11.0] - 2022-09-27 ### Changed From c1e7ab7dd90e02e15da6e161f826e693d90d3d05 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Mon, 19 Dec 2022 12:35:02 +0100 Subject: [PATCH 12/18] Release 0.13.0 --- CHANGELOG.md | 4 +++- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40c7141..e8cb830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## [0.13.0] - 2022-12-19 ### Changed - [PR#56](https://github.com/EmbarkStudios/cfg-expr/pull/56) updated the builtin target list to 1.66.0. Thanks [@sunshowers](https://github.com/sunshowers)! @@ -129,7 +130,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial add of all the things -[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.12.0...HEAD +[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.13.0...HEAD +[0.13.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.12.0...0.13.0 [0.12.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.11.0...0.12.0 [0.11.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.3...0.11.0 [0.10.3]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.2...0.10.3 diff --git a/Cargo.toml b/Cargo.toml index c6c707a..f7e4a1f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cfg-expr" description = "A parser and evaluator for Rust `cfg()` expressions." repository = "https://github.com/EmbarkStudios/cfg-expr" -version = "0.12.0" +version = "0.13.0" authors = [ "Embark ", "Jake Shadle ", From 8212431e4a8db78e370bc2c5357b11bc9b3c106f Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 27 Jan 2023 15:14:28 +0100 Subject: [PATCH 13/18] Update to 1.67.0 (#57) * Update to 1.67.0 * Fix lints --- CHANGELOG.md | 3 ++ src/targets.rs | 8 ++--- src/targets/builtins.rs | 72 +++++++++++++++++++++++++++++++++-------- tests/eval.rs | 10 +++--- 4 files changed, 70 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8cb830..c5da832 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#57](https://github.com/EmbarkStudios/cfg-expr/pull/57) updated the builtin target list to 1.67.0. + ## [0.13.0] - 2022-12-19 ### Changed - [PR#56](https://github.com/EmbarkStudios/cfg-expr/pull/56) updated the builtin target list to 1.66.0. Thanks [@sunshowers](https://github.com/sunshowers)! diff --git a/src/targets.rs b/src/targets.rs index e6c0d72..c906e8f 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -122,7 +122,7 @@ impl std::str::FromStr for HasAtomic { impl std::fmt::Display for HasAtomic { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Self::IntegerSize(size) => write!(f, "{}", size), + Self::IntegerSize(size) => write!(f, "{size}"), Self::Pointer => write!(f, "ptr"), } } @@ -183,7 +183,7 @@ impl std::fmt::Display for Families { write!(f, "{{")?; let len = self.0.len(); for (idx, family) in self.0.iter().enumerate() { - write!(f, "{}", family)?; + write!(f, "{family}")?; if idx + 1 < len { write!(f, ", ")?; } @@ -243,7 +243,7 @@ impl std::fmt::Display for HasAtomics { write!(f, "{{")?; let len = self.0.len(); for (idx, has_atomic) in self.0.iter().enumerate() { - write!(f, "{}", has_atomic)?; + write!(f, "{has_atomic}")?; if idx + 1 < len { write!(f, ", ")?; } @@ -372,7 +372,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo> /// versions. /// /// ``` -/// assert_eq!("1.66.0", cfg_expr::targets::rustc_version()); +/// assert_eq!("1.67.0", cfg_expr::targets::rustc_version()); /// ``` pub fn rustc_version() -> &'static str { builtins::RUSTC_VERSION diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index ecf6706..2b06675 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.66.0"; +pub(crate) const RUSTC_VERSION: &str = "1.67.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -273,6 +273,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::abort, }, + TargetInfo { + triple: Triple::new_const("aarch64-unknown-nto-qnx710"), + os: Some(Os::nto), + abi: None, + arch: Arch::aarch64, + env: Some(Env::nto71), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("aarch64-unknown-openbsd"), os: Some(Os::openbsd), @@ -1274,6 +1287,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("mipsel-sony-psx"), + os: None, + abi: None, + arch: Arch::mips, + env: Some(Env::psx), + vendor: Some(Vendor::sony), + families: Families::new_const(&[]), + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::new_const(&[]), + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("mipsel-unknown-linux-gnu"), os: Some(Os::linux), @@ -1508,6 +1534,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("powerpc64-ibm-aix"), + os: Some(Os::aix), + abi: None, + arch: Arch::powerpc64, + env: None, + vendor: Some(Vendor::ibm), + families: Families::unix, + pointer_width: 64, + endian: Endian::big, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("powerpc64-unknown-freebsd"), os: Some(Os::freebsd), @@ -2223,6 +2262,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("x86_64-pc-nto-qnx710"), + os: Some(Os::nto), + abi: None, + arch: Arch::x86_64, + env: Some(Env::nto71), + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("x86_64-pc-solaris"), os: Some(Os::solaris), @@ -2431,19 +2483,6 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::abort, }, - TargetInfo { - triple: Triple::new_const("x86_64-unknown-none-linuxkernel"), - os: None, - abi: None, - arch: Arch::x86_64, - env: Some(Env::gnu), - vendor: Some(Vendor::unknown), - families: Families::new_const(&[]), - pointer_width: 64, - endian: Endian::little, - has_atomics: HasAtomics::atomic_8_16_32_64_ptr, - panic: Panic::abort, - }, TargetInfo { triple: Triple::new_const("x86_64-unknown-openbsd"), os: Some(Os::openbsd), @@ -2554,6 +2593,7 @@ impl super::Vendor { pub const apple: Vendor = Vendor::new_const("apple"); pub const espressif: Vendor = Vendor::new_const("espressif"); pub const fortanix: Vendor = Vendor::new_const("fortanix"); + pub const ibm: Vendor = Vendor::new_const("ibm"); pub const kmc: Vendor = Vendor::new_const("kmc"); pub const nintendo: Vendor = Vendor::new_const("nintendo"); pub const nvidia: Vendor = Vendor::new_const("nvidia"); @@ -2566,6 +2606,7 @@ impl super::Vendor { } impl super::Os { + pub const aix: Os = Os::new_const("aix"); pub const android: Os = Os::new_const("android"); pub const cuda: Os = Os::new_const("cuda"); pub const dragonfly: Os = Os::new_const("dragonfly"); @@ -2582,6 +2623,7 @@ impl super::Os { pub const linux: Os = Os::new_const("linux"); pub const macos: Os = Os::new_const("macos"); pub const netbsd: Os = Os::new_const("netbsd"); + pub const nto: Os = Os::new_const("nto"); pub const openbsd: Os = Os::new_const("openbsd"); pub const psp: Os = Os::new_const("psp"); pub const redox: Os = Os::new_const("redox"); @@ -2622,6 +2664,8 @@ impl super::Env { pub const msvc: Env = Env::new_const("msvc"); pub const musl: Env = Env::new_const("musl"); pub const newlib: Env = Env::new_const("newlib"); + pub const nto71: Env = Env::new_const("nto71"); + pub const psx: Env = Env::new_const("psx"); pub const relibc: Env = Env::new_const("relibc"); pub const sgx: Env = Env::new_const("sgx"); pub const uclibc: Env = Env::new_const("uclibc"); diff --git a/tests/eval.rs b/tests/eval.rs index 7eda39c..a9efc17 100644 --- a/tests/eval.rs +++ b/tests/eval.rs @@ -35,7 +35,7 @@ impl Target { // There are enough new weird architectures added in each version of // Rust that it is difficult to keep target-lexicon aware of all of // them. So try parsing this triple, but don't fail if it doesn't work. - eprintln!("failed to parse '{}': {:?}", triple, e); + eprintln!("failed to parse '{triple}': {e:?}"); None } }, @@ -59,8 +59,8 @@ macro_rules! tg_match { let linfo = tg.matches(l); assert_eq!( tinfo, linfo, - "{:#?} builtin didn't match lexicon {:#?} for predicate {:#?}", - $target.builtin, $target.lexicon, tg, + "{:#?} builtin didn't match lexicon {:#?} for predicate {tg:#?}", + $target.builtin, $target.lexicon, ); return linfo; @@ -86,8 +86,8 @@ macro_rules! tg_match { let linfo = tg.matches(l); assert_eq!( tinfo, linfo, - "{:#?} builtin didn't match lexicon {:#?} for predicate {:#?}", - $target.builtin, $target.lexicon, tg, + "{:#?} builtin didn't match lexicon {:#?} for predicate {tg:#?}", + $target.builtin, $target.lexicon, ); return linfo; From f769aed6d4e05d2dd9aea7f12d13dbe0269533fd Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Fri, 27 Jan 2023 15:15:06 +0100 Subject: [PATCH 14/18] Release 0.14.0 --- CHANGELOG.md | 4 +++- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5da832..d170667 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## [0.14.0] - 2023-01-27 ### Changed - [PR#57](https://github.com/EmbarkStudios/cfg-expr/pull/57) updated the builtin target list to 1.67.0. @@ -133,7 +134,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial add of all the things -[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.13.0...HEAD +[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.14.0...HEAD +[0.14.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.13.0...0.14.0 [0.13.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.12.0...0.13.0 [0.12.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.11.0...0.12.0 [0.11.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.10.3...0.11.0 diff --git a/Cargo.toml b/Cargo.toml index f7e4a1f..270b58f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cfg-expr" description = "A parser and evaluator for Rust `cfg()` expressions." repository = "https://github.com/EmbarkStudios/cfg-expr" -version = "0.13.0" +version = "0.14.0" authors = [ "Embark ", "Jake Shadle ", From 8e5db5b43bb32292169cf06a14d90838dbf6941b Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Tue, 4 Apr 2023 10:26:10 +0200 Subject: [PATCH 15/18] Update to 1.68.2 (#58) * Update to 1.68.2 * Update CHANGELOG * Fix clippy lints * Fix doctest * Fix misattribution --- CHANGELOG.md | 3 +++ src/expr.rs | 11 +++++----- src/expr/lexer.rs | 4 ++-- src/targets.rs | 2 +- src/targets/builtins.rs | 48 ++++++++++++++++++++++++++++++++++++++--- 5 files changed, 57 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d170667..b3c171d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#58](https://github.com/EmbarkStudios/cfg-expr/pull/58) updated the builtin target list to 1.68.2. + ## [0.14.0] - 2023-01-27 ### Changed - [PR#57](https://github.com/EmbarkStudios/cfg-expr/pull/57) updated the builtin target list to 1.67.0. diff --git a/src/expr.rs b/src/expr.rs index ed1f4e1..2e1aa01 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -231,14 +231,15 @@ impl TargetMatcher for target_lexicon::Triple { } Family(fam) => { use target_lexicon::OperatingSystem::{ - AmdHsa, Bitrig, Cloudabi, Cuda, Darwin, Dragonfly, Emscripten, Espidf, Freebsd, - Fuchsia, Haiku, Hermit, Horizon, Illumos, Ios, L4re, Linux, MacOSX, Nebulet, - Netbsd, None_, Openbsd, Redox, Solaris, Tvos, Uefi, Unknown, VxWorks, Wasi, - Watchos, Windows, + Aix, AmdHsa, Bitrig, Cloudabi, Cuda, Darwin, Dragonfly, Emscripten, Espidf, + Freebsd, Fuchsia, Haiku, Hermit, Horizon, Illumos, Ios, L4re, Linux, MacOSX, + Nebulet, Netbsd, None_, Openbsd, Redox, Solaris, Tvos, Uefi, Unknown, VxWorks, + Wasi, Watchos, Windows, }; match self.operating_system { AmdHsa | Bitrig | Cloudabi | Cuda | Hermit | Nebulet | None_ | Uefi => false, - Darwin + Aix + | Darwin | Dragonfly | Espidf | Freebsd diff --git a/src/expr/lexer.rs b/src/expr/lexer.rs index 9bd6e30..a5f0c2d 100644 --- a/src/expr/lexer.rs +++ b/src/expr/lexer.rs @@ -95,12 +95,12 @@ impl<'a> Iterator for Lexer<'a> { #[inline] fn is_ident_start(ch: char) -> bool { - ch == '_' || (('a'..='z').contains(&ch) || ('A'..='Z').contains(&ch)) + ch == '_' || ch.is_ascii_lowercase() || ch.is_ascii_uppercase() } #[inline] fn is_ident_rest(ch: char) -> bool { - is_ident_start(ch) || ('0'..='9').contains(&ch) + is_ident_start(ch) || ch.is_ascii_digit() } match self.inner.chars().next() { diff --git a/src/targets.rs b/src/targets.rs index c906e8f..c4eaf40 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -372,7 +372,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo> /// versions. /// /// ``` -/// assert_eq!("1.67.0", cfg_expr::targets::rustc_version()); +/// assert_eq!("1.68.2", cfg_expr::targets::rustc_version()); /// ``` pub fn rustc_version() -> &'static str { builtins::RUSTC_VERSION diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index 2b06675..8660118 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.67.0"; +pub(crate) const RUSTC_VERSION: &str = "1.68.2"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -182,6 +182,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("aarch64-unknown-fuchsia"), + os: Some(Os::fuchsia), + abi: None, + arch: Arch::aarch64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_128_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("aarch64-unknown-hermit"), os: Some(Os::hermit), @@ -637,6 +650,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("armv7-sony-vita-newlibeabihf"), + os: Some(Os::vita), + abi: None, + arch: Arch::arm, + env: Some(Env::newlib), + vendor: Some(Vendor::sony), + families: Families::unix, + pointer_width: 32, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_ptr, + panic: Panic::abort, + }, TargetInfo { triple: Triple::new_const("armv7-unknown-freebsd"), os: Some(Os::freebsd), @@ -894,7 +920,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::new_const(&[]), pointer_width: 64, endian: Endian::big, - has_atomics: HasAtomics::new_const(&[]), + has_atomics: HasAtomics::atomic_64_ptr, panic: Panic::abort, }, TargetInfo { @@ -907,7 +933,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::new_const(&[]), pointer_width: 64, endian: Endian::little, - has_atomics: HasAtomics::new_const(&[]), + has_atomics: HasAtomics::atomic_64_ptr, panic: Panic::abort, }, TargetInfo { @@ -2366,6 +2392,19 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ has_atomics: HasAtomics::atomic_8_16_32_64_ptr, panic: Panic::unwind, }, + TargetInfo { + triple: Triple::new_const("x86_64-unknown-fuchsia"), + os: Some(Os::fuchsia), + abi: None, + arch: Arch::x86_64, + env: None, + vendor: Some(Vendor::unknown), + families: Families::unix, + pointer_width: 64, + endian: Endian::little, + has_atomics: HasAtomics::atomic_8_16_32_64_ptr, + panic: Panic::unwind, + }, TargetInfo { triple: Triple::new_const("x86_64-unknown-haiku"), os: Some(Os::haiku), @@ -2632,6 +2671,7 @@ impl super::Os { pub const tvos: Os = Os::new_const("tvos"); pub const uefi: Os = Os::new_const("uefi"); pub const unknown: Os = Os::new_const("unknown"); + pub const vita: Os = Os::new_const("vita"); pub const vxworks: Os = Os::new_const("vxworks"); pub const wasi: Os = Os::new_const("wasi"); pub const watchos: Os = Os::new_const("watchos"); @@ -2692,6 +2732,7 @@ const __has_atomics_8_16_32_ptr: &[HasAtomic] = &[ HasAtomic::IntegerSize(32), HasAtomic::Pointer, ]; +const __has_atomics_64_ptr: &[HasAtomic] = &[HasAtomic::IntegerSize(64), HasAtomic::Pointer]; impl super::HasAtomics { pub const atomic_8_16_32_64_128_ptr: HasAtomics = @@ -2699,6 +2740,7 @@ impl super::HasAtomics { pub const atomic_8_16_32_64_ptr: HasAtomics = HasAtomics::new_const(__has_atomics_8_16_32_64_ptr); pub const atomic_8_16_32_ptr: HasAtomics = HasAtomics::new_const(__has_atomics_8_16_32_ptr); + pub const atomic_64_ptr: HasAtomics = HasAtomics::new_const(__has_atomics_64_ptr); } impl super::Panic { From 295353e0ba1b2952b3254ac64453f0d4e4fe707b Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Tue, 4 Apr 2023 10:26:45 +0200 Subject: [PATCH 16/18] Release 0.15.0 --- CHANGELOG.md | 4 +++- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3c171d..049bf93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## [0.15.0] - 2023-04-04 ### Changed - [PR#58](https://github.com/EmbarkStudios/cfg-expr/pull/58) updated the builtin target list to 1.68.2. @@ -137,7 +138,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial add of all the things -[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.14.0...HEAD +[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.15.0...HEAD +[0.15.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.14.0...0.15.0 [0.14.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.13.0...0.14.0 [0.13.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.12.0...0.13.0 [0.12.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.11.0...0.12.0 diff --git a/Cargo.toml b/Cargo.toml index 270b58f..f533e0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cfg-expr" description = "A parser and evaluator for Rust `cfg()` expressions." repository = "https://github.com/EmbarkStudios/cfg-expr" -version = "0.14.0" +version = "0.15.0" authors = [ "Embark ", "Jake Shadle ", From 33c2f81b35e2a40ed0c58203fc43dcdb16ee60bd Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 20 Apr 2023 20:05:06 +0200 Subject: [PATCH 17/18] Update target list to 1.69.0 (#59) * Update target list to 1.69.0 * Update docs --- CHANGELOG.md | 3 +++ README.md | 4 ++-- src/targets.rs | 2 +- src/targets/builtins.rs | 8 +++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 049bf93..8371342 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +### Changed +- [PR#59](https://github.com/EmbarkStudios/cfg-expr/pull/59) updated the builtin target list to 1.69.0. + ## [0.15.0] - 2023-04-04 ### Changed - [PR#58](https://github.com/EmbarkStudios/cfg-expr/pull/58) updated the builtin target list to 1.68.2. diff --git a/README.md b/README.md index b29a450..965083a 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ # `⚙️ cfg-expr` -**A parser and evaluator for Rust `cfg()` expressions. Targets as of [Rust 1.66.0](https://forge.rust-lang.org/release/platform-support.html) are supported.** +**A parser and evaluator for Rust `cfg()` expressions. Builtin targets as of [Rust 1.69.0](https://forge.rust-lang.org/release/platform-support.html) are supported.** [![Build Status](https://github.com/EmbarkStudios/cfg-expr/workflows/CI/badge.svg)](https://github.com/EmbarkStudios/cfg-expr/actions?workflow=CI) [![Crates.io](https://img.shields.io/crates/v/cfg-expr.svg)](https://crates.io/crates/cfg-expr) [![Docs](https://docs.rs/cfg-expr/badge.svg)](https://docs.rs/cfg-expr) [![Minimum Stable Rust Version](https://img.shields.io/badge/Rust%20MSRV-1.58.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2022/01/13/Rust-1.58.0.html) -[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.64.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) +[![Rust Targets](https://img.shields.io/badge/Rust%20Targets-1.69.0-blue.svg)](https://forge.rust-lang.org/release/platform-support.html) [![Contributor Covenant](https://img.shields.io/badge/contributor%20covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md) [![Embark](https://img.shields.io/badge/embark-open%20source-blueviolet.svg)](https://embark.dev) diff --git a/src/targets.rs b/src/targets.rs index c4eaf40..2587587 100644 --- a/src/targets.rs +++ b/src/targets.rs @@ -372,7 +372,7 @@ pub fn get_builtin_target_by_triple(triple: &str) -> Option<&'static TargetInfo> /// versions. /// /// ``` -/// assert_eq!("1.68.2", cfg_expr::targets::rustc_version()); +/// assert_eq!("1.69.0", cfg_expr::targets::rustc_version()); /// ``` pub fn rustc_version() -> &'static str { builtins::RUSTC_VERSION diff --git a/src/targets/builtins.rs b/src/targets/builtins.rs index 8660118..4564356 100644 --- a/src/targets/builtins.rs +++ b/src/targets/builtins.rs @@ -10,7 +10,7 @@ use super::*; -pub(crate) const RUSTC_VERSION: &str = "1.68.2"; +pub(crate) const RUSTC_VERSION: &str = "1.69.0"; pub const ALL_BUILTINS: &[TargetInfo] = &[ TargetInfo { @@ -920,7 +920,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::new_const(&[]), pointer_width: 64, endian: Endian::big, - has_atomics: HasAtomics::atomic_64_ptr, + has_atomics: HasAtomics::new_const(&[]), panic: Panic::abort, }, TargetInfo { @@ -933,7 +933,7 @@ pub const ALL_BUILTINS: &[TargetInfo] = &[ families: Families::new_const(&[]), pointer_width: 64, endian: Endian::little, - has_atomics: HasAtomics::atomic_64_ptr, + has_atomics: HasAtomics::new_const(&[]), panic: Panic::abort, }, TargetInfo { @@ -2732,7 +2732,6 @@ const __has_atomics_8_16_32_ptr: &[HasAtomic] = &[ HasAtomic::IntegerSize(32), HasAtomic::Pointer, ]; -const __has_atomics_64_ptr: &[HasAtomic] = &[HasAtomic::IntegerSize(64), HasAtomic::Pointer]; impl super::HasAtomics { pub const atomic_8_16_32_64_128_ptr: HasAtomics = @@ -2740,7 +2739,6 @@ impl super::HasAtomics { pub const atomic_8_16_32_64_ptr: HasAtomics = HasAtomics::new_const(__has_atomics_8_16_32_64_ptr); pub const atomic_8_16_32_ptr: HasAtomics = HasAtomics::new_const(__has_atomics_8_16_32_ptr); - pub const atomic_64_ptr: HasAtomics = HasAtomics::new_const(__has_atomics_64_ptr); } impl super::Panic { From 013f67b8063b6a3e6c1d76b66ee01c048326562f Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Thu, 20 Apr 2023 20:05:43 +0200 Subject: [PATCH 18/18] Release 0.15.1 --- CHANGELOG.md | 4 +++- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8371342..14b653f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ReleaseDate +## [0.15.1] - 2023-04-20 ### Changed - [PR#59](https://github.com/EmbarkStudios/cfg-expr/pull/59) updated the builtin target list to 1.69.0. @@ -141,7 +142,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial add of all the things -[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.15.0...HEAD +[Unreleased]: https://github.com/EmbarkStudios/cfg-expr/compare/0.15.1...HEAD +[0.15.1]: https://github.com/EmbarkStudios/cfg-expr/compare/0.15.0...0.15.1 [0.15.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.14.0...0.15.0 [0.14.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.13.0...0.14.0 [0.13.0]: https://github.com/EmbarkStudios/cfg-expr/compare/0.12.0...0.13.0 diff --git a/Cargo.toml b/Cargo.toml index f533e0b..d8fb78f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "cfg-expr" description = "A parser and evaluator for Rust `cfg()` expressions." repository = "https://github.com/EmbarkStudios/cfg-expr" -version = "0.15.0" +version = "0.15.1" authors = [ "Embark ", "Jake Shadle ",