ebpf: Always use `release` profile

Using `dev` profile, even after tuning flags (to make it identical
with `release`) still causes problems and is confusing for people.

And even when we have BTF support in future, it'd be better and
less confusing to set `debug=2` in `release` profile (because we
would want debug info, but still keep the same opt-level and other
options).
pull/96/head
Mike Rostecki 1 year ago
parent afdb45341f
commit 3449c6de1b

@ -34,9 +34,6 @@ pub struct Options {
/// Set the endianness of the BPF target /// Set the endianness of the BPF target
#[clap(default_value = "bpfel-unknown-none", long)] #[clap(default_value = "bpfel-unknown-none", long)]
pub target: Architecture, pub target: Architecture,
/// Build the release target
#[clap(long)]
pub release: bool,
} }
pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> { pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
@ -44,14 +41,12 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target); let target = format!("--target={}", opts.target);
let mut args = vec![ let mut args = vec![
"build", "build",
"--release",
"--verbose", "--verbose",
target.as_str(), target.as_str(),
"-Z", "-Z",
"build-std=core", "build-std=core",
]; ];
if opts.release {
args.push("--release")
}
// Command::new creates a child process which inherits all env variables. This means env // Command::new creates a child process which inherits all env variables. This means env
// vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed // vars set by the cargo xtask command are also inherited. RUSTUP_TOOLCHAIN is removed

@ -40,7 +40,6 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> {
// build our ebpf program followed by our application // build our ebpf program followed by our application
build_ebpf(BuildOptions { build_ebpf(BuildOptions {
target: opts.bpf_target, target: opts.bpf_target,
release: opts.release,
}) })
.context("Error while building eBPF program")?; .context("Error while building eBPF program")?;
build(&opts).context("Error while building userspace application")?; build(&opts).context("Error while building userspace application")?;

@ -12,17 +12,6 @@ aya-log-ebpf = { git = "https://github.com/aya-rs/aya" }
name = "{{ project-name }}" name = "{{ project-name }}"
path = "src/main.rs" path = "src/main.rs"
[profile.dev]
opt-level = 3
debug = false
debug-assertions = false
overflow-checks = false
lto = true
panic = "abort"
incremental = false
codegen-units = 1
rpath = false
[profile.release] [profile.release]
lto = true lto = true
panic = "abort" panic = "abort"

@ -86,11 +86,6 @@ async fn main() -> Result<(), anyhow::Error> {
// runtime. This approach is recommended for most real-world use cases. If you would // runtime. This approach is recommended for most real-world use cases. If you would
// like to specify the eBPF program at runtime rather than at compile-time, you can // like to specify the eBPF program at runtime rather than at compile-time, you can
// reach for `Bpf::load_file` instead. // reach for `Bpf::load_file` instead.
#[cfg(debug_assertions)]
let mut bpf = Bpf::load(include_bytes_aligned!(
"../../target/bpfel-unknown-none/debug/{{project-name}}"
))?;
#[cfg(not(debug_assertions))]
let mut bpf = Bpf::load(include_bytes_aligned!( let mut bpf = Bpf::load(include_bytes_aligned!(
"../../target/bpfel-unknown-none/release/{{project-name}}" "../../target/bpfel-unknown-none/release/{{project-name}}"
))?; ))?;

Loading…
Cancel
Save