libcpp: Require SVE for AArch64 vectorized lexer
Ensures AArch64 vectorized lexer requires SVE, not just SVE2, to prevent crashes on misconfigured VMs.
The libcpp initialization of its vectorized lexer (init_vectorized_lexer) incorrectly only checked for HWCAP2_SVE2. This caused issues on some virtual machines that advertise SVE2 support while disabling SVE, a nonsensical configuration that nonetheless occurs. Such systems would crash with an ‘Illegal instruction’ error upon lexing any input. This commit modifies the check to require both HWCAP_SVE and HWCAP2_SVE2, ensuring the vectorized lexer is only used when SVE is properly available, thereby fixing bootstrap issues on these misconfigured environments.
In Details
The init_vectorized_lexer function in libcpp is intended to enable hardware-accelerated lexing using ARM's Scalable Vector Extension (SVE). The function previously checked only for HWCAP2_SVE2, assuming SVE would implicitly be present. However, some hypervisors incorrectly advertise SVE2 without SVE. This commit rectifies the check to require HWCAP_SVE alongside HWCAP2_SVE2, preventing the use of the SVE2-dependent vectorized lexer on systems lacking SVE support and thus avoiding crashes during compilation (e.g., when build/genmatch is invoked).
- libcpp
- The C++ preprocessor included with GCC. It handles directives like #include and #define.
- SVE
- Scalable Vector Extension. An ARM architecture feature allowing vector registers to dynamically scale in size.
- SVE2
- A later version of ARM's Scalable Vector Extension, adding new instructions and capabilities.
- HWCAP
- Hardware Capabilities. A mechanism on Linux that exposes CPU features and extensions to user-space applications.
- HWCAP2_SVE2
- A specific hardware capability flag indicating support for the SVE2 instruction set.
- vectorized lexer
- A preprocessor component that uses SIMD (Single Instruction, Multiple Data) instructions to speed up the process of tokenizing source code.