llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28k stars 11.56k forks source link

[RISC-V] -mcpu=help emits unsupported cpu targets (generic, rocket) #102962

Open patrick-rivos opened 1 month ago

patrick-rivos commented 1 month ago

Godbolts: https://godbolt.org/z/Tzcb8f4vz https://godbolt.org/z/YPohsdEso

clang: error: unsupported argument 'rocket' to option '-mcpu='
clang: error: unsupported argument 'generic' to option '-mcpu='
error: unknown target CPU 'sifive-s54'
clang: error: unsupported argument 'sifive-7-series' to option '-mcpu='
error: unknown target CPU 'xiangshan-nanhu'

Related: #102959

patrick-rivos commented 1 month ago

This might be an invalid issue. The error: unknown target CPU 'sifive-s54' and error: unknown target CPU 'xiangshan-nanhu' error messages were from -mtune and the unsupported argument error messages appear to be cpu group names?

topperc commented 1 month ago

I think the problem here is that the error message uses fillValidCPUArchList/fillValidTuneCPUArchList from RISCVTargetParser.cpp which is called by clang/lib/Basic/Targets/RISCV.cpp

The list for help is generated by the clang driver invoking the -mcpu=help handling in MCSubtargetInfo.cpp. There's no hook for the target to filter this list, it's just the raw tablegen generated CPU list.