[BUG] AArch64 `+no<ext>` modifiers don't disable extensions the `--mcpu` CPU enables by default

Abierto
#7,594 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
compilers

Línea de trabajo

Start in getFeaturesFromClang in Support/lib/MArchTarget/MArchTargetMinimal.cpp, where the AArch64 block appends the CPU's DefaultExtensions and keeps only the + entries, which drops an explicit -sve. The test ArchTarget.AArch64MarchNegativeModifierDoesNotOverrideCpuDefaults in Support/unittests/MArchTarget/MarchTest.cpp pins the current behavior. Done when +nosve on neoverse-v1 yields -sve, the --march=armv9-a+nosve case also yields -sve2, and the test is updated to match.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug bug_feature_triaged mojo Team: Mojo Compiler
Bug description
Actual behavior

On AArch64, a +no<ext> modifier doesn't disable an extension that the --mcpu CPU enables by default. neoverse-v1 has SVE, and +nosve is dropped whether it is written on --mcpu or on --march:

$ mojo build --target-triple=aarch64-unknown-linux-gnu --mcpu=neoverse-v1+nosve --emit=llvm -o - t.mojo | grep -o '"target-features"="[^"]*"' | sort -u | tr ',"' '\n\n' | grep -E '^[+-]sve2?$'
+sve
$ mojo build --target-triple=aarch64-unknown-linux-gnu --march=armv9-a+nosve --mcpu=neoverse-v1 --emit=llvm -o - t.mojo | grep -o '"target-features"="[^"]*"' | sort -u | tr ',"' '\n\n' | grep -E '^[+-]sve2?$'
+sve

Extensions that only the architecture brings are removed: --march=armv9-a+nosve alone, or with --mcpu=neoverse-n1 (no SVE), gives neither sve nor sve2.

The cause seems to be in getFeaturesFromClang (Support/lib/MArchTarget/MArchTargetMinimal.cpp): clang resolves the explicit -sve into opts->Features, the AArch64 block then appends the CPU's DefaultExtensions (+sve), and only the + entries are kept, so the -sve is lost.

Expected behavior

As in clang (23.1.1), an explicit +no<ext> wins over the CPU's defaults, and the CPU's other extensions stay:

$ echo 'void f(void) {}' | clang --target=aarch64-unknown-linux-gnu -mcpu=neoverse-v1+nosve -S -emit-llvm -o - -x c - | grep -o '"target-features"="[^"]*"' | tr ',"' '\n\n' | grep -E '^[+-]sve2?$'
-sve
$ echo 'void f(void) {}' | clang --target=aarch64-unknown-linux-gnu -march=armv9-a+nosve -mcpu=neoverse-v1 -S -emit-llvm -o - -x c - | grep -o '"target-features"="[^"]*"' | tr ',"' '\n\n' | grep -E '^[+-]sve2?$'
-sve
-sve2
Steps to reproduce

t.mojo:

def main():
    pass

Run the two mojo build commands above. Expected -sve (plus -sve2 for the --march case); observed +sve.

ArchTarget.AArch64MarchNegativeModifierDoesNotOverrideCpuDefaults in Support/unittests/MArchTarget/MarchTest.cpp pins the current behavior. Its FIXME points at #6918, which is the RISC-V --march/--mcpu issue; I'll point it here.

System information

Reproduced against a source build of the compiler at main (19bc97aa93c246ca432132df462a8ee6b68bf44b), not a released package, so pixi list max does not apply. macOS arm64 host (Apple M1 Pro) cross-compiling to aarch64-unknown-linux-gnu.

Lenguaje dominante
Mojo
Estrellas
30.2k
Forks
3.2k
Merge medio
6 d 20 h
PR fusionados (30 d)
25

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de modular/modular

Todos los issues de modular/modular

Issues similares

Más issues de Compilers

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.