[PATCH] D70401: [RISCV] CodeGen of RVE and ilp32e/lp64e ABIs

Wang Pengcheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 28 00:42:16 PDT 2023


pcwang-thead added a comment.

In D70401#4226549 <https://reviews.llvm.org/D70401#4226549>, @recallmenot wrote:

> In D70401#4205333 <https://reviews.llvm.org/D70401#4205333>, @pcwang-thead wrote:
>
>> In D70401#4204511 <https://reviews.llvm.org/D70401#4204511>, @recallmenot wrote:
>>
>>> Hi, I'm working on CH32V003 for rust and it uses RV32EC core.
>>> I tried replacing my distros llvm and clang with a patched version of this like this:
>>>
>>>   git clone https://aur.archlinux.org/llvm-git.git
>>>   cd llvm-git
>>>   mkdir src
>>>   cd src
>>>   git clone https://github.com/llvm/llvm-project.git
>>>   cd llvm-project
>>>   arc patch D70401
>>>   cd ../..
>>>   mv llvm-config.h src/
>>>   makepkg -es
>>>   sudo pacman -Rd --nodeps clang llvm
>>>   makepkg -eid
>>>
>>> but that bricked my xfce-wayland-manjaro DE (one screen black)
>>> And in config.toml if I put
>>>
>>>   [build]
>>>   target = "riscv32i-unknown-none-elf"
>>>   rustflags = [
>>>   	"-C", "target-feature=+e,+c"
>>>   ]
>>>
>>> then build with cargo build
>>> LLVM still complains it doesn't implement CodeGen for RV32E yet
>>> What am I doing wrong?
>>> Ended up reverting to repository llvm and clang, desktop now works again but CodeGen is obviously missing.
>>
>> I don't see any obvious problem here.
>> I am not familiar with rust. Is `riscv32i-unknown-none-elf` a valid target for `rustc`, it should be something like `riscv32-unknown-elf` in LLVM I think. And is `target-feature=+e,+c` the right way to specify features?
>> Can you please provide the whole command/arguments passed to LLVM?
>
> Yeah so I looked at the at the target files of rustc, telling rustc to do RV32I will indeed result in RV32 and the way to enable the E and C features seems to be correct, BUT:
> rust uses their own "special sauce" version of llvm and rustc needs to be built against that to enable the new features. I tried to apply (patch) the diff directly to rusts llvm branch but there were many errors, and I couldn't figure out how to apply them manually since some things are different.
> I'm stuck, this is all way beyond my understanding. Sorry I can't test it for you guys.
> What I did was:
>
>   git clone https://github.com/rust-lang/rust.git
>   cd rust
>   nvim config.toml
>
>   [llvm]
>   download-ci-llvm = false
>
> then I started building with
>
>   ./x.py build
>
> and as soon as the rust-llvm source was downloaded completely I aborted (CTRL+C).
>
> then downloaded the raw diff from this page (button top right) into the rust llvm dir, opened a terminal in that dir and tried to patch with
>
>   patch -p1 < D70401.diff
>
> but that gives lots of errors
> resolving them manually seems way beyond me, especially since patch seems to already use fuzzy matching

So it seems that rust uses its own llvm branch based on released llvm branch, so I think you may download old version of this patch which is near the baseline of rust llvm branch and try again. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401



More information about the cfe-commits mailing list