Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Exclude just std from rustc deps
  • Loading branch information
Zoxc committed Aug 11, 2024
commit dd3f7578ee52af74de732f8a8e6dc5d02b284daa
14 changes: 5 additions & 9 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1838,17 +1838,13 @@ impl Step for Assemble {
for f in builder.read_dir(&src_libdir) {
let filename = f.file_name().into_string().unwrap();

// For the later stages which gets distributed only copy over the
// `rustc_driver` library so we don't end up with an extra copy of `std`.
// If we're not statically linking `std` into `rustc_driver`, just copy every library
// to ensure `std` is included.
// For the later stages which gets distributed avoid copying `std` if we're
// statically linking `std` into `rustc_driver`.
// We still need `std` for the initial stage as the bootstrap compiler may not
// have the new `rustc_private` linking behavior.
let can_be_rustc_dep = filename.starts_with("rustc_driver-")
|| filename.starts_with("librustc_driver-")
|| build_compiler.stage == 0
|| !link_std_into_rustc_driver;

let is_std = filename.starts_with("std-") || filename.starts_with("libstd-");
let can_be_rustc_dep =
!is_std || !link_std_into_rustc_driver || build_compiler.stage == 0; // cfg(bootstrap)
if can_be_rustc_dep
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this extra logic needed for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's to prevent the std dynamic library from also being included with the compiler, as it's no longer needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like it'd be worth a comment in the code. (That's probably true most times a reviewer had a question that was answered by a clarification without code change.)

&& (is_dylib(&filename) || is_debug_info(&filename))
&& !proc_macros.contains(&filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code did also copy libLLVM before this change, now that won't happen. But the LLVM library seems to appear in the target sysroot anyway, probably from some other bootstrap step, so hopefully that won't be an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to just exclude std then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a commit that does so.

Expand Down