Skip to content

Avoid shipping duplicate artifacts in the host and target sysroot #42645

Open
@alexcrichton

Description

@alexcrichton

All released compilers have identical dynamic libraries in two locations. The locations on Linux are:

  • $sysroot/lib/*.dylib
  • $sysroot/lib/rustlib/$target/lib/*.dylib

All of these artifacts are byte-for-byte equivalent (they're just copies of one another). These duplicate artifacts inflate our installed size, inflate downloads, and cause weird bugs like #39870. Although #39870 is itself fixed it's just a hack fix for now that would be ideally solved by fixing this issue!

Some possible thoughts I personally have on this are:

  • Symlinks won't work because they don't work on Windows
  • Hard links may work here, but I'm not sure. This'd require a lot of updates to lots of tools (rust-installer, rustup, etc)
  • Simply not shipping one of these is going to be very difficult. $sysroot/lib is required for rustc itself to run correctly (that dir is typically in LD_LIBRARY_PATH or the equivalent) and $sysroot/lib/rustlib/$target/lib is where the compiler looks for target libraries. The compiler can't look in $sysroot/lib for libs as that's typically got a ton of libs on Unix systems.
  • The most plausible solution in my mind is to create our own pseudo-symlink file format. When assembling a sysroot this is what rustbuild itself would emit (instead of copying files) but it'd basically be a file with the literal contents rustc-look-in-your-libdir. That way something like $sysroot/lib/rustlib/$target/lib/libstd.dylib would exist but essentially be an empty file (not a valid dynamic library). Instead rustc would look at $sysroot/lib/libstd.dylib for that file instead.

Unsure if I'm on the right track there, but hopefully can get discussion around this moving!

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchE-help-wantedCall for participation: Help is requested to fix this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions