[PATCH] D129824: [RISCV] Set triple based on -march flag which can be deduced in more generic way

Zixuan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Aug 7 19:11:03 PDT 2022


zixuan-wu added a comment.

In D129824#3699911 <https://reviews.llvm.org/D129824#3699911>, @kito-cheng wrote:

> Just realized the problem is trying to fixed the default value of `-mabi=`, currently `clang -target riscv32-elf -march=rv64gc -mabi=lp64d`/`riscv32-elf-clang -march=rv64gc -mabi=lp64d` is work, and match the behavior of GCC did, `riscv32-elf-gcc -march=rv64gc -mabi=lp64d`.
>
> And this patch is trying to make following two command work: `clang -target riscv32-elf -march=rv64gc`/`riscv32-elf-clang -march=rv64gc`, specify `-march` and `-target` but no `-mabi`.
>
> That is different story now, GCC isn't deduce the default abi from either target triple or abi, so if you invoke gcc with `riscv32-elf-gcc -march=rv64gc` or `riscv64-elf-gcc -march=rv32gc`, you will got error message like that: `cc1: error: ABI requires '-march=rv32'` or `cc1: error: ABI requires '-march=rv64'`.
>
> So that's not compatible issue with GCC, that's sort of clang driver specify issue, and I don't have strong opinion on this.
>
> ---
>
> As a GNU toolchain developer, I would say, we are not intend to change the behavior of default value of `-mabi` or `-march`, the consensus among RISC-V GNU toolchain maintainer is user should explicitly specify the `-march` and `-mabi` if you are not using default `-march` and `-mabi`.

This patch is not about default value of mabi. It just tries to deduce march when -march option is not provided explicitly. 
It fixes the conflict between target triple and march about 32-bit/64-bit (riscv32 or riscv64) issue as before. Before this patch, this conflict only can be solved by specifying -march option explicitly.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129824/new/

https://reviews.llvm.org/D129824



More information about the cfe-commits mailing list