1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Cédric Mesnil <cslashm@pm.me>
//! Build script: emit the `ct_thumb2` cfg for ARM targets whose ISA has the
//! Thumb-2 **IT-block** conditional execution used by the `ct::thumbv7`
//! constant-time backend. `ct/mod.rs` gates on it to pick the IT-block
//! backend (`thumbv7.rs`) vs the 2-operand Thumb-1 backend (`thumbv6m.rs`)
//! reliably across every M-profile core.
//!
//! # Why not a `cfg` / `target_feature`?
//!
//! rustc (checked on 1.96) emits **no** `target_feature = "thumb2"` for any
//! bare-metal M-profile target, and `target_has_atomic` is present on
//! `thumbv8m.base` (an M23 core that has **no** IT blocks), so neither is a
//! sound discriminator. The only reliable signal is the target triple:
//! IT blocks are valid iff the core is a Thumb-2 M-profile part — ARMv7-M
//! (`thumbv7…`) or ARMv8-M.main (`thumbv8m.main…`). ARMv6-M (`thumbv6m`) and
//! ARMv8-M.baseline (`thumbv8m.base`, Cortex-M23) have no IT.
//!
//! The `thumb` prefix is load-bearing: it excludes `armv7*` / `armv7a*`
//! (ARM/A32 state, where the `ite` instruction is undefined) while still
//! including `thumbv7a`/`thumbv7neon` (Thumb state on Cortex-A, where IT is
//! valid). See `ct/mod.rs` and the `asm-thumbv7` / `asm-thumbv6m` features.
use env;