[gcc r17-3399] libcpp: require SVE as well as SVE2 for the AArch64 lexer [PR126935]
Kyrylo Tkachov via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:ec2890c334eaccbe37e2e2eae6a4de62fefdcbf8 commit r17-3399-gec2890c334eaccbe37e2e2eae6a4de62fefdcbf8 Author: Kyrylo Tkachov <[email protected]> Date: Wed Aug 19 07:14:10 2026 +0200 libcpp: require SVE as well as SVE2 for the AArch64 lexer [PR126935] init_vectorized_lexer only tested HWCAP2_SVE2. Some virtual machines advertise SVE2 while leaving SVE clear, which is a nonsense configuration but one that occurs in practice, and there the compiler dies as soon as it lexes anything: build/genmatch --gimple ... make[3]: *** [Makefile:3102: s-gimple-match] Illegal instruction Test HWCAP_SVE alongside HWCAP2_SVE2 so the run-time dispatch declines the SVE2 helper on such a machine and keeps using Neon. SVE2 without SVE is a nonsense configuration architecture-wise and arguably the VM hypervisor is at fault here, but it is easy to work around for the sake of fixing bootstrap on such machines. libcpp/ChangeLog: PR target/126935 * lex.cc (HWCAP_SVE): Define if not already defined. (init_vectorized_lexer): Require HWCAP_SVE as well as HWCAP2_SVE2. Signed-off-by: Kyrylo Tkachov <[email protected]> Diff: --- libcpp/lex.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libcpp/lex.cc b/libcpp/lex.cc index ee6d6e01803d..bd35e28ce8f4 100644 --- a/libcpp/lex.cc +++ b/libcpp/lex.cc @@ -740,6 +740,9 @@ done: #include <arm_sve.h> #include <sys/auxv.h> +#ifndef HWCAP_SVE +#define HWCAP_SVE (1 << 22) +#endif #ifndef HWCAP2_SVE2 #define HWCAP2_SVE2 (1 << 1) #endif @@ -810,7 +813,11 @@ static bool lexer_has_sve2; static inline void init_vectorized_lexer (void) { - lexer_has_sve2 = (getauxval (AT_HWCAP2) & HWCAP2_SVE2) != 0; + /* MATCH aside, the scanner is built from base SVE instructions, so both + features have to be present. Some virtual machines advertise SVE2 + without SVE, and there even the leading CNTB traps. */ + lexer_has_sve2 = ((getauxval (AT_HWCAP) & HWCAP_SVE) != 0 + && (getauxval (AT_HWCAP2) & HWCAP2_SVE2) != 0); } #endif