(manifest: &BuildManifest)
| 401 | |
| 402 | /// Drop stdlib objects no kept object references (directly or transitively). |
| 403 | /// Program/extra objects and any object defining an entry symbol are roots. |
| 404 | fn prune_unreferenced_stdlib( |
| 405 | units: Vec<BuiltUnit>, |
| 406 | prunable: &std::collections::HashSet<String>, |
| 407 | entry: Option<&str>, |
| 408 | ) -> Vec<BuiltUnit> { |
| 409 | let entry_roots = ["_start", "_kernel_start"]; |
| 410 | let is_root = |unit: &BuiltUnit| { |
| 411 | !prunable.contains(&unit.name) |
| 412 | || unit.assembled.global_symbol_names().any(|symbol| { |
| 413 | entry_roots.contains(&symbol) || entry.is_some_and(|entry| entry == symbol) |
| 414 | }) |
| 415 | }; |
| 416 | let mut kept: Vec<bool> = units.iter().map(is_root).collect(); |
| 417 | let mut needed: std::collections::HashSet<String> = units |
| 418 | .iter() |
| 419 | .zip(&kept) |
| 420 | .filter(|(_, keep)| **keep) |
| 421 | .flat_map(|(unit, _)| unit.assembled.undefined_symbol_names()) |
| 422 | .map(str::to_owned) |
| 423 | .collect(); |
| 424 | loop { |
| 425 | let mut changed = false; |
nothing calls this directly
no test coverage detected