chore(xtask): Add s390x and powerpc64 to codegen

This commit adds the s390x and powerpc architectures
to codegen. This will enable an upcoming PR to add
support for aya to support theses architectures
in both aya and aya-ebpf.

Co-authored-by: Dave Tucker <dave@dtucker.co.uk>
Signed-off-by: Billy McFall <22157057+Billy99@users.noreply.github.com>
pull/975/head
Billy McFall 5 months ago committed by Dave Tucker
parent bfafe9e786
commit 62efed1853

@ -57,6 +57,8 @@ fn codegen_bindings(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyh
aarch64_sysroot, aarch64_sysroot,
armv7_sysroot, armv7_sysroot,
riscv64_sysroot, riscv64_sysroot,
powerpc64_sysroot,
s390x_sysroot,
} = opts; } = opts;
let types = [ let types = [
// BPF // BPF
@ -179,6 +181,8 @@ fn codegen_bindings(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyh
Architecture::ARMv7 => "armv7-unknown-linux-gnu", Architecture::ARMv7 => "armv7-unknown-linux-gnu",
Architecture::AArch64 => "aarch64-unknown-linux-gnu", Architecture::AArch64 => "aarch64-unknown-linux-gnu",
Architecture::RISCV64 => "riscv64-unknown-linux-gnu", Architecture::RISCV64 => "riscv64-unknown-linux-gnu",
Architecture::PowerPC64 => "powerpc64le-unknown-linux-gnu",
Architecture::S390X => "s390x-unknown-linux-gnu",
}; };
bindgen = bindgen.clang_args(&["-target", target]); bindgen = bindgen.clang_args(&["-target", target]);
@ -189,6 +193,8 @@ fn codegen_bindings(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyh
Architecture::ARMv7 => armv7_sysroot, Architecture::ARMv7 => armv7_sysroot,
Architecture::AArch64 => aarch64_sysroot, Architecture::AArch64 => aarch64_sysroot,
Architecture::RISCV64 => riscv64_sysroot, Architecture::RISCV64 => riscv64_sysroot,
Architecture::PowerPC64 => powerpc64_sysroot,
Architecture::S390X => s390x_sysroot,
}; };
bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]); bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]);

@ -17,6 +17,8 @@ pub fn codegen(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyhow::E
aarch64_sysroot, aarch64_sysroot,
armv7_sysroot, armv7_sysroot,
riscv64_sysroot, riscv64_sysroot,
powerpc64_sysroot,
s390x_sysroot,
} = opts; } = opts;
let dir = PathBuf::from("ebpf/aya-ebpf-bindings"); let dir = PathBuf::from("ebpf/aya-ebpf-bindings");
@ -80,6 +82,8 @@ pub fn codegen(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyhow::E
Architecture::ARMv7 => "armv7-unknown-linux-gnu", Architecture::ARMv7 => "armv7-unknown-linux-gnu",
Architecture::AArch64 => "aarch64-unknown-linux-gnu", Architecture::AArch64 => "aarch64-unknown-linux-gnu",
Architecture::RISCV64 => "riscv64-unknown-linux-gnu", Architecture::RISCV64 => "riscv64-unknown-linux-gnu",
Architecture::PowerPC64 => "powerpc64le-unknown-linux-gnu",
Architecture::S390X => "s390x-unknown-linux-gnu",
}; };
bindgen = bindgen.clang_args(&["-target", target]); bindgen = bindgen.clang_args(&["-target", target]);
@ -90,6 +94,8 @@ pub fn codegen(opts: &SysrootOptions, libbpf_dir: &Path) -> Result<(), anyhow::E
Architecture::ARMv7 => armv7_sysroot, Architecture::ARMv7 => armv7_sysroot,
Architecture::AArch64 => aarch64_sysroot, Architecture::AArch64 => aarch64_sysroot,
Architecture::RISCV64 => riscv64_sysroot, Architecture::RISCV64 => riscv64_sysroot,
Architecture::PowerPC64 => powerpc64_sysroot,
Architecture::S390X => s390x_sysroot,
}; };
bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]); bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]);

@ -11,6 +11,8 @@ const SUPPORTED_ARCHS: &[Architecture] = &[
Architecture::ARMv7, Architecture::ARMv7,
Architecture::AArch64, Architecture::AArch64,
Architecture::RISCV64, Architecture::RISCV64,
Architecture::PowerPC64,
Architecture::S390X,
]; ];
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
@ -19,6 +21,8 @@ pub enum Architecture {
ARMv7, ARMv7,
AArch64, AArch64,
RISCV64, RISCV64,
PowerPC64,
S390X,
} }
impl Architecture { impl Architecture {
@ -36,6 +40,8 @@ impl std::str::FromStr for Architecture {
"armv7" => Architecture::ARMv7, "armv7" => Architecture::ARMv7,
"aarch64" => Architecture::AArch64, "aarch64" => Architecture::AArch64,
"riscv64" => Architecture::RISCV64, "riscv64" => Architecture::RISCV64,
"powerpc64" => Architecture::PowerPC64,
"s390x" => Architecture::S390X,
_ => return Err("invalid architecture"), _ => return Err("invalid architecture"),
}) })
} }
@ -48,6 +54,8 @@ impl std::fmt::Display for Architecture {
Architecture::ARMv7 => "armv7", Architecture::ARMv7 => "armv7",
Architecture::AArch64 => "aarch64", Architecture::AArch64 => "aarch64",
Architecture::RISCV64 => "riscv64", Architecture::RISCV64 => "riscv64",
Architecture::PowerPC64 => "powerpc64",
Architecture::S390X => "s390x",
}) })
} }
} }
@ -67,6 +75,12 @@ pub struct SysrootOptions {
#[arg(long, default_value = "/usr/riscv64-linux-gnu/include", action)] #[arg(long, default_value = "/usr/riscv64-linux-gnu/include", action)]
riscv64_sysroot: PathBuf, riscv64_sysroot: PathBuf,
#[arg(long, default_value = "/usr/powerpc64le-linux-gnu/include", action)]
powerpc64_sysroot: PathBuf,
#[arg(long, default_value = "/usr/s390x-linux-gnu/include", action)]
s390x_sysroot: PathBuf,
} }
#[derive(Parser)] #[derive(Parser)]

Loading…
Cancel
Save