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

ebpf: Always use release profile #96

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,19 @@ pub struct Options {
/// Set the endianness of the BPF target
#[clap(default_value = "bpfel-unknown-none", long)]
pub target: Architecture,
/// Build the release target
#[clap(long)]
pub release: bool,
}

pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let dir = PathBuf::from("{{project-name}}-ebpf");
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--release",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
];
if opts.release {
args.push("--release")
}

// 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
Expand Down
1 change: 0 additions & 1 deletion xtask/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> {
// build our ebpf program followed by our application
build_ebpf(BuildOptions {
target: opts.bpf_target,
release: opts.release,
})
.context("Error while building eBPF program")?;
build(&opts).context("Error while building userspace application")?;
Expand Down
11 changes: 0 additions & 11 deletions {{project-name}}-ebpf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ aya-log-ebpf = { git = "https://github.com/aya-rs/aya" }
name = "{{ project-name }}"
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]
lto = true
panic = "abort"
Expand Down
5 changes: 0 additions & 5 deletions {{project-name}}/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ async fn main() -> Result<(), anyhow::Error> {
// 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
// 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!(
"../../target/bpfel-unknown-none/release/{{project-name}}"
))?;
Expand Down