Skip to content

Commit

Permalink
Support build-std
Browse files Browse the repository at this point in the history
With build-std there are no precompiled rlibs for the standard library,
so just treating std the same as normal libraries is sufficient.
  • Loading branch information
jschwe committed May 27, 2022
1 parent 5542b9c commit dca90b3
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,6 @@ fn process_crate(args: &Args) -> Result<CrateData, Error> {
});
}

let target_dylib_path = stdlibs_dir(&target_triple)?;

let mut rlib_paths = Vec::new();

let mut dep_crates = Vec::new();
Expand All @@ -674,19 +672,29 @@ fn process_crate(args: &Args) -> Result<CrateData, Error> {
dep_crates.dedup();
dep_crates.sort();

let std_paths = collect_rlib_paths(&target_dylib_path);
let mut std_crates: Vec<String> = std_paths.iter().map(|v| v.0.clone()).collect();
rlib_paths.extend_from_slice(&std_paths);
std_crates.sort();

// Remove std crates that was explicitly added as dependencies.
//
// Like: getopts, bitflags, backtrace, log, etc.
for c in &dep_crates {
if let Some(idx) = std_crates.iter().position(|v| v == c) {
std_crates.remove(idx);
let std_crates: Vec<String> = if args
.unstable
.iter()
.any(|unstable_arg| unstable_arg.starts_with("build-std"))
{
Vec::new()
} else {
let target_dylib_path = stdlibs_dir(&target_triple)?;
let std_paths = collect_rlib_paths(&target_dylib_path);
let mut std_crates: Vec<String> = std_paths.iter().map(|v| v.0.clone()).collect();
rlib_paths.extend_from_slice(&std_paths);
std_crates.sort();

// Remove std crates that was explicitly added as dependencies.
//
// Like: getopts, bitflags, backtrace, log, etc.
for c in &dep_crates {
if let Some(idx) = std_crates.iter().position(|v| v == c) {
std_crates.remove(idx);
}
}
}
std_crates
};

let deps_symbols = collect_deps_symbols(rlib_paths)?;

Expand Down

0 comments on commit dca90b3

Please sign in to comment.