diff --git a/aya-log-common/src/lib.rs b/aya-log-common/src/lib.rs index 48c1d018..37591f7e 100644 --- a/aya-log-common/src/lib.rs +++ b/aya-log-common/src/lib.rs @@ -1,3 +1,7 @@ +#![cfg_attr( + target_arch = "bpf", + expect(unused_crate_dependencies, reason = "compiler_builtins") +)] #![no_std] use core::{ diff --git a/clippy.sh b/clippy.sh index 62de2bb5..a710c7c1 100755 --- a/clippy.sh +++ b/clippy.sh @@ -2,6 +2,15 @@ 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 # contains `#[no_std]` binaries. # @@ -11,4 +20,9 @@ set -eux # unwinding behavior. # # `+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 diff --git a/ebpf/aya-ebpf-bindings/src/lib.rs b/ebpf/aya-ebpf-bindings/src/lib.rs index 6317bfce..8fff6f05 100644 --- a/ebpf/aya-ebpf-bindings/src/lib.rs +++ b/ebpf/aya-ebpf-bindings/src/lib.rs @@ -1,3 +1,7 @@ +#![cfg_attr( + target_arch = "bpf", + expect(unused_crate_dependencies, reason = "compiler_builtins") +)] #![expect( clippy::all, clippy::cast_lossless, diff --git a/ebpf/aya-ebpf/build.rs b/ebpf/aya-ebpf/build.rs index 95792c2d..b38c385b 100644 --- a/ebpf/aya-ebpf/build.rs +++ b/ebpf/aya-ebpf/build.rs @@ -1,18 +1,7 @@ -use std::env; - fn main() { - check_rust_version(); println!("cargo:rerun-if-env-changed=CARGO_CFG_BPF_TARGET_ARCH"); - if let Ok(arch) = env::var("CARGO_CFG_BPF_TARGET_ARCH") { - 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}\""); - } + println!("cargo:rerun-if-env-changed=HOST"); + print!("cargo::rustc-check-cfg=cfg(bpf_target_arch, values("); for arch in [ "aarch64", @@ -28,7 +17,20 @@ fn main() { } 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)"); + check_rust_version(); } #[rustversion::nightly] diff --git a/ebpf/aya-ebpf/src/lib.rs b/ebpf/aya-ebpf/src/lib.rs index dc59d351..91d9fa27 100644 --- a/ebpf/aya-ebpf/src/lib.rs +++ b/ebpf/aya-ebpf/src/lib.rs @@ -8,13 +8,18 @@ html_logo_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( generic_const_exprs, expect(incomplete_features), + expect(unstable_features), 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)] #![no_std] @@ -65,7 +70,6 @@ pub trait EbpfContext { } } -#[cfg_attr(target_arch = "bpf", expect(clippy::missing_safety_doc))] mod intrinsics { use super::cty::c_int; diff --git a/ebpf/aya-log-ebpf/Cargo.toml b/ebpf/aya-log-ebpf/Cargo.toml index 401fe361..90c54198 100644 --- a/ebpf/aya-log-ebpf/Cargo.toml +++ b/ebpf/aya-log-ebpf/Cargo.toml @@ -17,6 +17,3 @@ workspace = true aya-ebpf = { version = "^0.1.1", path = "../aya-ebpf" } aya-log-common = { version = "^0.1.15", path = "../../aya-log-common" } aya-log-ebpf-macros = { version = "^0.1.0", path = "../../aya-log-ebpf-macros" } - -[lib] -path = "src/lib.rs" diff --git a/ebpf/aya-log-ebpf/src/lib.rs b/ebpf/aya-log-ebpf/src/lib.rs index 96e56a6c..7238c006 100644 --- a/ebpf/aya-log-ebpf/src/lib.rs +++ b/ebpf/aya-log-ebpf/src/lib.rs @@ -1,3 +1,7 @@ +#![cfg_attr( + target_arch = "bpf", + expect(unused_crate_dependencies, reason = "compiler_builtins") +)] #![no_std] #![warn(clippy::cast_lossless, clippy::cast_sign_loss)]