فهرست منبع

Add riscv64 architecture support to xtask/codegen

gianluigi 2 سال پیش
والد
کامیت
d35680f30c
4فایلهای تغییر یافته به همراه12 افزوده شده و 1 حذف شده
  1. 1 1
      .github/workflows/gen.yml
  2. 2 0
      xtask/src/codegen/aya.rs
  3. 2 0
      xtask/src/codegen/aya_bpf_bindings.rs
  4. 7 0
      xtask/src/codegen/mod.rs

+ 1 - 1
.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: |

+ 2 - 0
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()]);
 

+ 2 - 0
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()]);
 

+ 7 - 0
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<Command>,
 }