compiler-explorer / compiler-explorer/compiler-explorer

[BUG]: clang RISC-V `-mcpu` effectively ignored due to default `-march=rv64gc`

Open
#8,551 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
19.1k
Forks
2.1k
Avg merge
3d 15h
Merged PRs (30d)
67

Description

### Describe the bug

For "RISC-V rv64gc clang (...)" compilers, using flags such as `-O3 -mcpu=sifive-p670` doesn't result in enabling the given CPU architecture, due to the default `-march=rv64gc` flag.

### Steps to reproduce

See reproduction link

### Expected behavior

The clang compiler sees `clzw` / vector use as gcc does. Can also see the desired behavior in an x86-64 clang compiler manually overridden to do RISC-V via `--target=riscv64-linux-gnu -O3 -mcpu=sifive-p670`.

A potential fix would be to not automatically add the default `-march=rv64gc` flag if `-mcpu` is present. (or perhaps not add the `-march` at all? Pretty sure it's the default anyways)

### Reproduction link

https://riscvc.godbolt.org/z/sWoWxKEn4

### Screenshots

Not applicable

### Operating System

_No response_

### Browser version

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.