Skip to content

Commit

Permalink
xtask can build linker in debug mode
Browse files Browse the repository at this point in the history
Signed-off-by: qjerome <[email protected]>
  • Loading branch information
qjerome committed Dec 12, 2023
1 parent 000065d commit c7f1327
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions xtask/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use std::path::{Path, PathBuf};

#[derive(Debug, Parser)]
pub struct Options {
/// build bpf-linker in debug mode
#[clap(long)]
pub debug: bool,
/// generates a cache key (mostly to be used in CI)
#[clap(long)]
pub action_cache_key: bool,
Expand Down Expand Up @@ -100,15 +103,24 @@ pub fn build_linker<T: AsRef<Path>, U: AsRef<Path>>(
})?;
}

let mut build_args = vec![
format!("--target={}", opts.target),
"--bins".into(),
// next two opts force static linking against LLVM_SYS_XXX_PREFIX
"--no-default-features".into(),
"--features=llvm-sys/force-static".into(),
];

// build release by default as debug is only needed to investigate crashes
if !opts.debug {
build_args.push("--release".into());
}

let status = std::process::Command::new("cargo")
.current_dir(linker_dir)
.env("LLVM_SYS_170_PREFIX", llvm_build_dir)
.arg("build")
.arg(&format!("--target={}", opts.target))
.arg("--release")
.arg("--bins")
.arg("--no-default-features")
.arg("--features=llvm-sys/force-static")
.args(build_args)
.status()
.expect("failed to build bpf-linker");

Expand Down

0 comments on commit c7f1327

Please sign in to comment.