1. [RISCV] Match GCC `-march`/`-mabi` driver defaults (details)
  2. [clangd] Add isHeaderFile helper. (details)
Commit e3d5ff5a0b102febcddd9d58f24f18b00d4ecb4e by selliott
[RISCV] Match GCC `-march`/`-mabi` driver defaults
Summary: 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. Until now, each
place that has needed a default `-march` has calculated one itself.
This patch adds a single place where a default `-march` is calculated,
in order to avoid calculating different defaults in different places.
This patch adds a new function `riscv::getRISCVArch` which encapsulates
this logic based on GCC's 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.
GCC has convoluted logic in its build system to choose a default
`-march`/`-mabi` based on build options, which would be good to match.
This patch is based on the logic in GCC 9.2.0. This commit's logic is
different to GCC's only for baremetal targets, where we default to
rv32imac/ilp32 or rv64imac/lp64 depending on the target triple.
Tests have been updated to match the new logic.
Reviewers: asb, luismarques, rogfer01, kito-cheng, khchen
Reviewed By: asb, luismarques
Subscribers: sameer.abuasal, rbar, johnrusso, simoncook, apazos,
sabuasal, niosHD, shiva0217, jrtc27, MaskRay, zzheng, edward-jones,
MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna,
Jim, s.egerton, pzheng, cfe-commits
Tags: #clang
Differential Revision:
The file was modifiedclang/test/Driver/riscv-abi.c
The file was modifiedclang/test/Driver/riscv-gnutools.c
The file was modifiedclang/lib/Driver/ToolChains/Arch/RISCV.h
The file was modifiedclang/docs/ReleaseNotes.rst
The file was modifiedclang/lib/Driver/ToolChains/Gnu.cpp
The file was modifiedclang/lib/Driver/ToolChains/Arch/RISCV.cpp
Commit 509efe5d8edee5637b26fcb645978325de0a7283 by hokein.wu
[clangd] Add isHeaderFile helper.
Summary: we have a few places using `ASTCtx.getLangOpts().IsHeaderFile`
to determine a header file, but it relies on "-x c-header" compiler
flag, if the compilation command doesn't have this flag, we will get a
false positive. We are encountering this issue in bazel build system.
To solve this problem, we infer the file from file name, actual changes
will come in follow-ups.
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet,
usaxena95, cfe-commits
Tags: #clang
Differential Revision:
The file was modifiedclang-tools-extra/clangd/SourceCode.cpp
The file was modifiedclang-tools-extra/clangd/SourceCode.h
The file was modifiedclang-tools-extra/clangd/unittests/SourceCodeTests.cpp
The file was modifiedclang-tools-extra/clangd/index/Background.cpp