Skip to content

Commit

Permalink
Adding to lib search path
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Jul 26, 2023
1 parent f08209e commit fcd1fc0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ use std::env;

const COMPILER_DEPENDENT_BINARIES : &[&str] = &["dfpp", "cargo-dfpp", "dfpp-explorer"];

fn add_link_path_for_compiler_binaries(s: impl std::fmt::Display) {
fn add_link_arg_for_compiler_binaries(s: impl std::fmt::Display) {
for bin in COMPILER_DEPENDENT_BINARIES {
println!("cargo:rustc-link-arg-bin={bin}=-Wl,-rpath,{s}");
println!("cargo:rustc-link-arg-bin={bin}={s}");
}
}

fn add_link_search_path_for_compiler_binaries(s: impl std::fmt::Display) {
add_link_arg_for_compiler_binaries(format!("-Wl,-rpath,{s}"))
}

/// Taken from Kani
/// (<https://github.com/model-checking/kani/blob/3d8ceddb0672e1dda6c186830f411c979bc132e2/kani-compiler/build.rs>)
/// this code links the rustc libraries directly with the compiled binaries.
Expand All @@ -26,7 +30,7 @@ pub fn link_rustc_lib() {
eprint!("{}, ", file.unwrap().file_name().to_string_lossy());
}
eprintln!();
add_link_path_for_compiler_binaries(rustup_lib.display());
add_link_search_path_for_compiler_binaries(rustup_lib.display());

// While we hard-code the above for development purposes, for a release/install we look
// in a relative location for a symlink to the local rust toolchain
Expand All @@ -35,7 +39,10 @@ pub fn link_rustc_lib() {
} else {
"$ORIGIN"
};
add_link_path_for_compiler_binaries(&format!("{origin}/../toolchain/lib"));
add_link_search_path_for_compiler_binaries(&format!("{origin}/../toolchain/lib"));
if cfg!(target_os = "linux") {
println!("cargo:rustc-link-search=native={}", rustup_lib.display());
}
}

fn main() {
Expand Down

0 comments on commit fcd1fc0

Please sign in to comment.