[PATCH] D67508: [RISCV] support mutilib in baremetal environment

Sam Elliott via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 23 08:14:25 PDT 2019


lenary requested changes to this revision.
lenary added a comment.
This revision now requires changes to proceed.

Sorry for approving, and then requesting changes. I've been investigating issues with this patch.

When I try to use `-print-multi-lib` (a clang option that is very under-documented, but I think it's there to match GCC's option), this often doesn't always print out available multilibs, which is confusing.

1. `clang --gcc-toolchain=<..> --target=riscv32-unknown-elf -print-multi-lib` does print out available multilibs (as gcc would)
2. `clang --gcc-toolchain=<..> --target=riscv64-unknown-elf -print-multi-lib` does not print out anything.
3. `clang --gcc-toolchain=<..> --target=riscv64-unknown-elf -march=rv64gc -mabi=lp64d -print-multi-lib` does not print anything.
4. `clang --gcc-toolchain=<..> --target=riscv64-unknown-elf -march=rv64imafdc -mabi=lp64d -print-multi-lib` does print out available multilibs (as gcc would).

In all cases, I'm using a crosstool-ng configured toolchain for `riscv64-unknown-elf`.

I get the correct output for `2.` if I change the line noted in the line comment below. Note that choosing a reasonable default here has to match other defaults chosen in clang.

I think the reason that `3.` is not working is because of MULTILIB_REUSE. I do not think that blocks this patch, as I've said, this patch does not need to include MULTILIB_REUSE support.



================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:1547
+  else if (IsRV64)
+    MArch = "rv64i";
+  else
----------------
I think this line is the issue: where someone doesn't specify `-march`, you choose a default `-march` that does not appear in the list of multilib arches in `RISCVMultilibSet` above.

I think this issue probably didn't arise when you had `rv64i/lp64` in the list, but given that's not in the riscv-gcc `t-elf-multilib`, so this code should choose a new default. I don't know how this new default will affect defaults chosen in other parts of the clang codebase.


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

https://reviews.llvm.org/D67508





More information about the cfe-commits mailing list