[PATCH] D132843: [RISCV] Ensure target features get passed to the LTO linker for RISC-V

Zakk Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 6 22:51:12 PDT 2022


khchen added a comment.

> Possible solution/results:
>
> 1. All functions in `a.o` and `b.o` using same target features during the first build stage, `-march=rv64gc` for a.o, `-march=rv64g` for `b.o`, and `-march` option given in LTO CodeGen stage is ignored, it only used for ELF attribute use (this revision).
> 2. All functions in `a.o` and `b.o` using same target features during the first build stage, `-march=rv64gc` for a.o, `-march=rv64g` for `b.o`, and deduced arch info from those `.o` for ELF attribute use (D106347 <https://reviews.llvm.org/D106347>), `-march`
> 3. All functions in `a.o` and `b.o` re-compile with `-march=rv64gc_zba` and ELF attribute use `rv64gc_zba`.
>
> Option 1: Require user use right `-march` option during LTO stage, and might fill wrong/unexpected ELF attribute if give wrong `-march` or not even not given in LTO stage.
> Option 2: Should be more ideal, but D106347 <https://reviews.llvm.org/D106347> seems no progress for a while.
> Option 3: This option will break IFUNC usage.

This patch (Option 1) is look good to me, but maybe we need to report a warning in linking stage if possible.
I think users may not easy to specific the right -march string when they're using external libraries.
We had discussed that before in here <https://reviews.llvm.org/D102925#2775524> and here <https://reviews.llvm.org/D102926#2776301>, it's why I proposed Option 2 <https://reviews.llvm.org/D106347> which encodes a module scope arch features in IR. IIRC, it's similar to what gcc did.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132843



More information about the cfe-commits mailing list