Skip to content

Commit

Permalink
Auto merge of #122362 - Zoxc:rustc_driver_static_std, r=oli-obk,lqd,b…
Browse files Browse the repository at this point in the history
…jorn3,Kobzol

Link `std` statically in `rustc_driver`

This makes `rustc_driver` statically link to `std`. This is done by not passing `-C prefer-dynamic` when building `rustc_driver`. However building `rustc-main` won't work currently as it tries to dynamically link to both `rustc_driver` and `std` resulting in a crate graph with `std` duplicated. To fix that new command line option `-Z prefer_deps_of_dynamic` is added which prevents linking to a dylib if there's a static variant of it already statically linked into another dylib dependency.

The main motivation for this change is to enable `#[global_allocator]` to be used in `rustc_driver` allowing overriding the allocator used in rustc on all platforms.

---

Instead of adding `-Z prefer_deps_of_dynamic`, this PR is changed to crate opt-in to the linking change via the `rustc_private` feature instead, as that would be typically needed to link to `rustc_driver` anyway.

---

try-job: aarch64-apple
try-job: x86_64-msvc
try-job: i686-mingw
try-job: dist-x86_64-msvc
try-job: aarch64-gnu
  • Loading branch information
bors committed Aug 11, 2024
2 parents 317e488 + cb174a5 commit 6c04dad
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit 6c04dad

Please # to comment.