1pub mod arch_table;
18pub mod arch_variant;
19pub mod cpu_level;
20pub mod detection;
21pub mod environment;
22pub mod shared;
23pub mod target;
24pub mod vector;
25
26#[cfg(feature = "nightly")]
27pub mod simd;
28
29pub use arch_table::{
31 ArchSpec, Endianness, LinuxInterpreters, OutputArtifact, PointerWidth, TargetArchitecture,
32 TargetDataLayout, ToolchainTriples, VaListAbi,
33};
34pub use arch_variant::{
35 Aarch64Level, ArchVariant, Armv7Profile, Armv7Variant, PowerLevel, RiscvIsa, VariantAxis,
36};
37pub use cpu_level::X86CpuLevel;
38pub use detection::{cpu_count, detect_host_architecture_only, detect_host_os};
39pub use environment::{CompilerRuntime, Libc, TargetEnvironment};
40pub use shared::{MemoryOrdering, SourceLoc, TlsModel};
41pub use target::{
42 Target, TargetOperatingSystem, default_environment, host_arch_list, parse_arch_token,
43 parse_architecture, target_alias_list,
44};
45pub use vector::any_vector_register_bits;
46
47#[cfg(feature = "nightly")]
48pub use simd::{ArmSimdExtension, RiscvSimdExtension, SimdCapabilities, X86SimdExtension};
49
50#[cfg(test)]
51mod tests {
52 #![allow(clippy::expect_used)]
53
54 use super::*;
55 use std::str::FromStr;
56
57 #[test]
58 fn test_from_str_roundtrip() {
59 let host = Target::detect_host().expect("host is a supported target");
60 let str_repr = host.to_str();
61 let parsed_back = Target::from_str(&str_repr).expect("Valid target should parse");
62
63 assert_eq!(
64 host, parsed_back,
65 "from_str/to_str should be a roundtrip operation"
66 );
67 }
68
69 #[test]
70 fn test_detect_functions_consistency() {
71 let combined = Target::detect_host().expect("host is a supported target");
73 let arch_str = detect_host_architecture_only();
74 let os_str = detect_host_os();
75
76 assert_eq!(
77 combined.architecture,
78 TargetArchitecture::from_str(arch_str).expect("host arch parses")
79 );
80 assert_eq!(
81 combined.operating_system,
82 TargetOperatingSystem::from_str(os_str).expect("host os parses")
83 );
84 }
85
86 #[cfg(feature = "nightly")]
87 #[test]
88 fn test_target_simd_capabilities() {
89 let target = Target::detect_host().expect("host is a supported target");
90 let caps = target.simd_capabilities();
91 assert!(caps.max_vector_width <= 2048);
93 }
94}