[all-commits] [llvm/llvm-project] f69320: [Clang][LoongArch] Consume and check -mabi and -mf...

WÁNG Xuěruì via All-commits all-commits at lists.llvm.org
Mon Jun 26 00:08:42 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f6932007ab4e047e17e04ae8a024105700b7d906
      https://github.com/llvm/llvm-project/commit/f6932007ab4e047e17e04ae8a024105700b7d906
  Author: WANG Xuerui <git at xen0n.name>
  Date:   2023-06-26 (Mon, 26 Jun 2023)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
    M clang/test/Driver/loongarch-mdouble-float.c
    M clang/test/Driver/loongarch-msingle-float.c
    M clang/test/Driver/loongarch-msoft-float.c

  Log Message:
  -----------
  [Clang][LoongArch] Consume and check -mabi and -mfpu even if -m*-float is present

This kind of CLI flags duplication can sometimes be convenient for build
systems that may have to tinker with these.

For example, in the Linux kernel we almost always want to ensure no FP
instruction is emitted, so `-msoft-float` is present by default; but
sometimes we do want to allow FPU usage (e.g. certain parts of amdgpu DC
code), in which case we want the `-msoft-float` stripped and `-mfpu=64`
added. Here we face a dilemma without this change:

* Either `-mabi` is not supplied by `arch/loongarch` Makefile, in which
  case the correct ABI has to be supplied by the driver Makefile
  (otherwise the ABI will become double-float due to `-mfpu`), which is
  arguably not appropriate for a driver;
* Or `-mabi` is still supplied by `arch/loongarch` Makefile, and the
  build immediately errors out because
  `-Werror=unused-command-line-argument` is unconditionally set for
  Clang builds.

To solve this, simply make sure to check `-mabi` and `-mfpu` (and gain
some useful diagnostics in case of conflicting settings) when
`-m*-float` is successfully parsed.

Reviewed By: SixWeining, MaskRay

Differential Revision: https://reviews.llvm.org/D153707




More information about the All-commits mailing list