glam-rs is a high-performance 3D mathematics library for Rust, focused on game development and graphics applications. It provides vector, matrix, quaternion, and affine transformation types with optional SIMD acceleration across multiple architectures (SSE2, NEON, WASM, portable SIMD). The library emphasizes zero-cost abstractions, compile-time optimizations, and a consistent API through code generation and trait-based design. Key features include swizzle operations for flexible vector component access, camera matrices for LH/RH coordinate systems, and extensive optional dependencies for serialization, random number generation, and interoperability. The architecture separates concerns into numeric-type modules (f32, f64, integer vectors), SIMD backends, and feature-gated functionality. Code generation via Tera templates ensures consistency across types and operations while reducing boilerplate. The swizzle system (src/swizzles/vec_traits.rs) implements a reusable trait-based pattern for vector component manipulation that enables generic code over different vector implementations. Camera modules use const generics to parameterize handedness, depth range, and Y-axis orientation, allowing compile-time selection of graphics API conventions without runtime overhead. Maintenance is active with regular updates, comprehensive CI/CD pipelines, and a clear MSRV policy (1.68.2). The library employs automated benchmarking (gungraun) and coverage tracking to monitor performance and quality. While the feature flag system and multiple SIMD backends increase complexity, they are managed through strict versioning, dependency auditing, and code generation workflows, resulting in low technical drift. The project demonstrates strong engineering practices with extensive documentation, attribution to source inspirations, and a focus on cross-platform determinism.
This repository provides two core Rust libraries: `compiler-builtins` and `libm`. `compiler-builtins` is a pure-Rust port of LLVM's `compiler-rt` intrinsics, including integer arithmetic (division, multiplication, leading/trailing zeros), floating-point operations (add, sub, mul, div, pow, conversion, truncation, extension), memory operations (memcpy, memset, memcmp), and platform-specific atomics. It is used by the Rust compiler to link against required runtime symbols for bare-metal and embedded targets. `libm` is a pure-Rust implementation of the C standard math library, ported from musl, covering trigonometric, exponential, logarithmic, power, Bessel, error, gamma, and rounding functions for f32 and f64, with experimental f16/f128 support. Both crates are `#![no_std]` and rely only on `core`. The codebase exhibits strong engineering: extensive use of generic traits (Float, Int) to abstract over widths, macro-driven code generation (intrinsics!, division algorithm macros, benchmark macros), architecture-specific optimizations (x86 SSE/AVX, ARM NEON, AArch64 outline atomics, Wasm, LoongArch, Hexagon assembly), and rigorous correctness verification against MPFR (via rug) and musl. CI tests run across 20+ targets, including instruction-count and wall-time benchmarks. This code is foundational for the Rust ecosystem, particularly in embedded, WebAssembly, and systems programming.