Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add riscv64 architecture support to xtask/codegen #275

Merged
merged 1 commit into from May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/gen.yml
Expand Up @@ -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: |
Expand Down
2 changes: 2 additions & 0 deletions xtask/src/codegen/aya.rs
Expand Up @@ -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]);

Expand All @@ -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()]);

Expand Down
2 changes: 2 additions & 0 deletions xtask/src/codegen/aya_bpf_bindings.rs
Expand Up @@ -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]);

Expand All @@ -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()]);

Expand Down
7 changes: 7 additions & 0 deletions xtask/src/codegen/mod.rs
Expand Up @@ -10,13 +10,15 @@ const SUPPORTED_ARCHS: &[Architecture] = &[
Architecture::X86_64,
Architecture::ARMv7,
Architecture::AArch64,
Architecture::RISCV64,
];

#[derive(Debug, Copy, Clone)]
pub enum Architecture {
X86_64,
ARMv7,
AArch64,
RISCV64,
}

impl Architecture {
Expand All @@ -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()),
})
}
Expand All @@ -44,6 +47,7 @@ impl std::fmt::Display for Architecture {
Architecture::X86_64 => "x86_64",
Architecture::ARMv7 => "armv7",
Architecture::AArch64 => "aarch64",
Architecture::RISCV64 => "riscv64",
})
}
}
Expand All @@ -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>,
}
Expand Down