Skip to content

[doc] How to cross compile v8 for riscv32 architecture on x86_64 linux #694

@VitalyAnkh

Description

@VitalyAnkh

Prerequisite: you are on a up-to-date x86_64 linux environment.

  1. download riscv32 gnu gcc toolchain: https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2022.06.10/riscv32-glibc-ubuntu-20.04-nightly-2022.06.10-nightly.tar.gz, then extract them to /opt/riscv/. Your /opt/riscv should look like this (ignore the riscv64-unknow-linux-gnu entry, it's present because I also installed the gnu gcc riscv64 toolchain):
    image
  2. cd to your v8 directory, then cd build. The build directory contains toolchain configurations for building v8. Download this patch from @luyahan: https://gist.github.com/VitalyAnkh/6e064ab3dcdf1be1032111bc8fa61acb. Then git apply <path-to-the-patch>.
  3. Edit v8/build/config/riscv.gni, assign values to riscv_gcc_toolchain_path and riscv_sysroot, like this
    image
  4. cd to your v8 directory, run gn gen out/riscv32.native.debug --args='is_component_build=false is_debug=true target_cpu="riscv32" v8_target_cpu="riscv32" use_goma=false goma_dir="None" treat_warnings_as_errors=false is_clang=false', then ninja -C out/riscv32.native.debug -j12.

Enjoy hacking!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions