Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 14 additions & 16 deletions src/bin/bpf-linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
feature = "rust-llvm-21"
))]
use aya_rustc_llvm_proxy as _;
use bpf_linker::{Cpu, Linker, LinkerOptions, OptLevel, OutputType};
use bpf_linker::{Cpu, Linker, LinkerInput, LinkerOptions, OptLevel, OutputType};
use clap::{
builder::{PathBufValueParser, TypedValueParser as _},
error::ErrorKind,
Expand Down Expand Up @@ -117,9 +117,9 @@ struct CommandLine {
#[clap(long)]
allow_bpf_trap: bool,

/// Add a directory to the library search path
/// UNUSED: it only exists for compatibility with rustc
#[clap(short = 'L', number_of_values = 1)]
libs: Vec<PathBuf>,
_libs: Vec<PathBuf>,

/// Optimization level. 0-3, s, or z
#[clap(short = 'O', default_value = "2")]
Expand Down Expand Up @@ -212,7 +212,6 @@ fn main() -> anyhow::Result<()> {
emit,
btf,
allow_bpf_trap,
libs,
optimize,
export_symbols,
log_file,
Expand All @@ -227,6 +226,7 @@ fn main() -> anyhow::Result<()> {
export,
fatal_errors,
_debug,
_libs,
} = match Parser::try_parse_from(args) {
Ok(command_line) => command_line,
Err(err) => match err.kind() {
Expand Down Expand Up @@ -271,15 +271,11 @@ fn main() -> anyhow::Result<()> {

let export_symbols = export_symbols.map(fs::read_to_string).transpose()?;

// TODO: the data is owned by this call frame; we could make this zero-alloc.
let export_symbols = export_symbols
.as_deref()
.into_iter()
.flat_map(str::lines)
.map(str::to_owned)
.chain(export)
.map(Into::into)
.collect();
.chain(export.iter().map(String::as_str));

let output_type = match *emit.as_slice() {
[] => unreachable!("emit has a default value"),
Expand All @@ -294,23 +290,25 @@ fn main() -> anyhow::Result<()> {
target,
cpu,
cpu_features,
inputs,
output,
output_type,
libs,
optimize,
export_symbols,
unroll_loops,
ignore_inline_never,
dump_module,
llvm_args,
disable_expand_memcpy_in_order,
disable_memory_builtins,
btf,
allow_bpf_trap,
});

linker.link()?;
if let Some(path) = dump_module {
linker.set_dump_module_path(path);
}

let inputs = inputs
.iter()
.map(|p| LinkerInput::new_from_file(p.as_path()));

linker.link_to_file(inputs, &output, output_type, export_symbols)?;

if fatal_errors && linker.has_errors() {
return Err(anyhow::anyhow!(
Expand Down
Loading
Loading