ebpf: run clippy with target=bpf

This build warnings from integration tests and makes `aya-ebpf`'s build
script stricter.
reviewable/pr1361/r1
Tamir Duberstein 2 weeks ago
parent 552b69367f
commit fe99fa1d2e
No known key found for this signature in database

@ -1,3 +1,7 @@
#![cfg_attr(
target_arch = "bpf",
expect(unused_crate_dependencies, reason = "compiler_builtins")
)]
#![no_std] #![no_std]
use core::{ use core::{

@ -2,6 +2,15 @@
set -eux set -eux
cargo +nightly hack clippy \
--target bpfel-unknown-none -Zbuild-std=core \
--package aya-ebpf-bindings \
--package aya-ebpf \
--package aya-log-ebpf \
--package integration-ebpf \
--feature-powerset \
-- --deny warnings
# `-C panic=abort` because "unwinding panics are not supported without std"; integration-ebpf # `-C panic=abort` because "unwinding panics are not supported without std"; integration-ebpf
# contains `#[no_std]` binaries. # contains `#[no_std]` binaries.
# #
@ -11,4 +20,9 @@ set -eux
# unwinding behavior. # unwinding behavior.
# #
# `+nightly` because "the option `Z` is only accepted on the nightly compiler". # `+nightly` because "the option `Z` is only accepted on the nightly compiler".
cargo +nightly hack clippy "$@" --all-targets --feature-powerset -- --deny warnings -C panic=abort -Zpanic_abort_tests cargo +nightly hack clippy "$@" \
--all-targets \
--feature-powerset \
-- --deny warnings \
-C panic=abort \
-Zpanic_abort_tests

@ -1,3 +1,7 @@
#![cfg_attr(
target_arch = "bpf",
expect(unused_crate_dependencies, reason = "compiler_builtins")
)]
#![expect( #![expect(
clippy::all, clippy::all,
clippy::cast_lossless, clippy::cast_lossless,

@ -1,18 +1,7 @@
use std::env;
fn main() { fn main() {
check_rust_version();
println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH"); println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH");
if let Ok(arch) = env::var("CARGO_CFG_BPF_TARGET_ARCH") { println!("cargo:rerun-if-env-changed=HOST");
println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
} else {
let arch = env::var("HOST").unwrap();
let mut arch = arch.split_once('-').map_or(&*arch, |x| x.0);
if arch.starts_with("riscv64") {
arch = "riscv64";
}
println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
}
print!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values("); print!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values(");
for arch in [ for arch in [
"aarch64", "aarch64",
@ -28,7 +17,20 @@ fn main() {
} }
println!("))"); println!("))");
if let Some(arch) = std::env::var_os("CARGO_CFG_BPF_TARGET_ARCH") {
let arch = arch.to_str().unwrap();
println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
} else if let Some(host) = std::env::var_os("HOST") {
let host = host.to_str().unwrap();
let mut arch = host.split_once('-').map_or(host, |(arch, _rest)| arch);
if arch.starts_with("riscv64") {
arch = "riscv64";
}
println!("cargo:rustc-cfg=bpf_target_arch=\"{arch}\"");
}
println!("cargo::rustc-check-cfg=cfg(generic_const_exprs)"); println!("cargo::rustc-check-cfg=cfg(generic_const_exprs)");
check_rust_version();
} }
#[rustversion::nightly] #[rustversion::nightly]

@ -8,13 +8,18 @@
html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg",
html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg"
)] )]
// TODO(https://github.com/rust-lang/rust/issues/141492): reenable this.
#![cfg_attr( #![cfg_attr(
generic_const_exprs, generic_const_exprs,
expect(incomplete_features), expect(incomplete_features),
expect(unstable_features),
feature(generic_const_exprs) feature(generic_const_exprs)
)] )]
#![cfg_attr(target_arch = "bpf", feature(asm_experimental_arch))] #![cfg_attr(
target_arch = "bpf",
expect(unused_crate_dependencies, reason = "compiler_builtins"),
expect(unstable_features),
feature(asm_experimental_arch)
)]
#![warn(clippy::cast_lossless, clippy::cast_sign_loss)] #![warn(clippy::cast_lossless, clippy::cast_sign_loss)]
#![no_std] #![no_std]
@ -65,7 +70,6 @@ pub trait EbpfContext {
} }
} }
#[cfg_attr(target_arch = "bpf", expect(clippy::missing_safety_doc))]
mod intrinsics { mod intrinsics {
use super::cty::c_int; use super::cty::c_int;

@ -17,6 +17,3 @@ workspace = true
aya-ebpf = { version = "^0.1.1", path = "../aya-ebpf" } aya-ebpf = { version = "^0.1.1", path = "../aya-ebpf" }
aya-log-common = { version = "^0.1.15", path = "../../aya-log-common" } aya-log-common = { version = "^0.1.15", path = "../../aya-log-common" }
aya-log-ebpf-macros = { version = "^0.1.0", path = "../../aya-log-ebpf-macros" } aya-log-ebpf-macros = { version = "^0.1.0", path = "../../aya-log-ebpf-macros" }
[lib]
path = "src/lib.rs"

@ -1,3 +1,7 @@
#![cfg_attr(
target_arch = "bpf",
expect(unused_crate_dependencies, reason = "compiler_builtins")
)]
#![no_std] #![no_std]
#![warn(clippy::cast_lossless, clippy::cast_sign_loss)] #![warn(clippy::cast_lossless, clippy::cast_sign_loss)]

Loading…
Cancel
Save