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

Support build-std #85

Merged
merged 1 commit into from
Jun 4, 2022
Merged
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
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