[PATCH] D69383: [RISCV] Match GCC `-march`/`-mabi` driver defaults

Sam Elliott via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 24 07:02:30 PDT 2019


lenary created this revision.
lenary added reviewers: asb, luismarques, rogfer01, kito-cheng, khchen.
Herald added subscribers: cfe-commits, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, MaskRay, jrtc27, shiva0217, niosHD, sabuasal, apazos, simoncook, johnrusso, rbar.
Herald added a project: clang.
lenary added a child revision: D67508: [RISCV] support mutilib in baremetal environment.
lenary updated this revision to Diff 226252.
lenary added a comment.

- Correct code formatting issue


GCC is not a cross-compiler, and has convoluted logic in its build
system to choose a default `-march`/`-mabi` based on build options.

Clang/LLVM is a cross-compiler, and so we don't have to make a choice
about `-march`/`-mabi` at build-time, but we may have to compute a
default `-march`/`-mabi` when compiling a program.

This patch adds a new function `riscv::getRISCVArch` which encapsulates
the logic in GCC's build system for computing a default `-march` value
when none is provided. This patch also updates the logic in
`riscv::getRISCVABI` to match the logic in GCC's build system for
computing a default `-mabi`.

This patch also updates anywhere that `-march` is used to now use the
new function which can compute a default. In particular, we now
explicitly pass a `-march` value down to the gnu assembler.

Tests have been updated to match the new logic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69383

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-gnutools.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69383.226252.patch
Type: text/x-patch
Size: 9589 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191024/f7342ce6/attachment-0001.bin>


More information about the cfe-commits mailing list