From d35680f30cfc37f2992b9e9342892c16aa766d22 Mon Sep 17 00:00:00 2001 From: gianluigi Date: Mon, 23 May 2022 10:59:24 +0200 Subject: [PATCH] Add riscv64 architecture support to xtask/codegen --- .github/workflows/gen.yml | 2 +- xtask/src/codegen/aya.rs | 2 ++ xtask/src/codegen/aya_bpf_bindings.rs | 2 ++ xtask/src/codegen/mod.rs | 7 +++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gen.yml b/.github/workflows/gen.yml index 2f11484da..8de74f239 100644 --- a/.github/workflows/gen.yml +++ b/.github/workflows/gen.yml @@ -23,7 +23,7 @@ jobs: - name: Install headers run: | sudo apt -y update - sudo apt -y install libc6-dev libc6-dev-{arm64,armel}-cross + sudo apt -y install libc6-dev libc6-dev-{arm64,armel,riscv64}-cross - name: Run codegen run: | diff --git a/xtask/src/codegen/aya.rs b/xtask/src/codegen/aya.rs index 754369af4..33ef51afb 100644 --- a/xtask/src/codegen/aya.rs +++ b/xtask/src/codegen/aya.rs @@ -171,6 +171,7 @@ fn codegen_bindings(opts: &Options) -> Result<(), anyhow::Error> { Architecture::X86_64 => "x86_64-unknown-linux-gnu", Architecture::ARMv7 => "armv7-unknown-linux-gnu", Architecture::AArch64 => "aarch64-unknown-linux-gnu", + Architecture::RISCV64 => "riscv64-unknown-linux-gnu", }; bindgen = bindgen.clang_args(&["-target", target]); @@ -180,6 +181,7 @@ fn codegen_bindings(opts: &Options) -> Result<(), anyhow::Error> { Architecture::X86_64 => &opts.x86_64_sysroot, Architecture::ARMv7 => &opts.armv7_sysroot, Architecture::AArch64 => &opts.aarch64_sysroot, + Architecture::RISCV64 => &opts.riscv64_sysroot, }; bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]); diff --git a/xtask/src/codegen/aya_bpf_bindings.rs b/xtask/src/codegen/aya_bpf_bindings.rs index 616ca7055..81aa04b6a 100644 --- a/xtask/src/codegen/aya_bpf_bindings.rs +++ b/xtask/src/codegen/aya_bpf_bindings.rs @@ -78,6 +78,7 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> { Architecture::X86_64 => "x86_64-unknown-linux-gnu", Architecture::ARMv7 => "armv7-unknown-linux-gnu", Architecture::AArch64 => "aarch64-unknown-linux-gnu", + Architecture::RISCV64 => "riscv64-unknown-linux-gnu", }; bindgen = bindgen.clang_args(&["-target", target]); @@ -87,6 +88,7 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> { Architecture::X86_64 => &opts.x86_64_sysroot, Architecture::ARMv7 => &opts.armv7_sysroot, Architecture::AArch64 => &opts.aarch64_sysroot, + Architecture::RISCV64 => &opts.riscv64_sysroot, }; bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]); diff --git a/xtask/src/codegen/mod.rs b/xtask/src/codegen/mod.rs index c42aa5344..d5b56105e 100644 --- a/xtask/src/codegen/mod.rs +++ b/xtask/src/codegen/mod.rs @@ -10,6 +10,7 @@ const SUPPORTED_ARCHS: &[Architecture] = &[ Architecture::X86_64, Architecture::ARMv7, Architecture::AArch64, + Architecture::RISCV64, ]; #[derive(Debug, Copy, Clone)] @@ -17,6 +18,7 @@ pub enum Architecture { X86_64, ARMv7, AArch64, + RISCV64, } impl Architecture { @@ -33,6 +35,7 @@ impl std::str::FromStr for Architecture { "x86_64" => Architecture::X86_64, "armv7" => Architecture::ARMv7, "aarch64" => Architecture::AArch64, + "riscv64" => Architecture::RISCV64, _ => return Err("invalid architecture".to_owned()), }) } @@ -44,6 +47,7 @@ impl std::fmt::Display for Architecture { Architecture::X86_64 => "x86_64", Architecture::ARMv7 => "armv7", Architecture::AArch64 => "aarch64", + Architecture::RISCV64 => "riscv64", }) } } @@ -64,6 +68,9 @@ pub struct Options { #[structopt(long, default_value = "/usr/arm-linux-gnueabi/include")] armv7_sysroot: PathBuf, + #[structopt(long, default_value = "/usr/riscv64-linux-gnu/include")] + riscv64_sysroot: PathBuf, + #[structopt(subcommand)] command: Option, }