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

integration-test: Prefer system-wide lld over rust-lld #908

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions xtask/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::{
use anyhow::{anyhow, bail, Context as _, Result};
use cargo_metadata::{Artifact, CompilerMessage, Message, Target};
use clap::Parser;
use which::which;
use xtask::{exec, Errors, AYA_BUILD_INTEGRATION_BPF};

#[derive(Parser)]
Expand Down Expand Up @@ -55,11 +56,21 @@ pub fn build<F>(target: Option<&str>, f: F) -> Result<Vec<(String, PathBuf)>>
where
F: FnOnce(&mut Command) -> &mut Command,
{
// Always use rust-lld and -Zbuild-std in case we're cross-compiling.
// Always use lld and -Zbuild-std in case we're cross-compiling.
let mut cmd = Command::new("cargo");
cmd.args(["build", "--message-format=json"]);
if let Some(target) = target {
let config = format!("target.{target}.linker = \"rust-lld\"");
let linker = if which("clang").is_ok() && which("lld").is_ok() {
// If clang and lld are available in the system, use them.
"clang"
} else {
// Otherwise, fall back to rust-lld. However, it's unaware of
// system library paths and therefore it might throw "unable to
// find library" errors. When experiencing that, better install an
// LLVM toolchain.
"rust-lld"
};
let config = format!("target.{target}.linker = \"{linker}\"");
cmd.args(["--target", target, "--config", &config]);
}
f(&mut cmd);
Expand Down