Skip to content

Deduplicate headers across the per-target sysroots - #656

Merged
alexcrichton merged 3 commits into
WebAssembly:mainfrom
alexcrichton:deduplicate-sysroot
Sep 11, 2026
Merged

Deduplicate headers across the per-target sysroots#656
alexcrichton merged 3 commits into
WebAssembly:mainfrom
alexcrichton:deduplicate-sysroot

Conversation

@alexcrichton

Copy link
Copy Markdown
Collaborator

This commit is an attempt at addressing #655 to remove duplicate header files across the sysroot. I don't know of an easy way of doing this with the built-in installation processes so a small script is added here which implements the logic of moving files around. The build process now configures the include install directory to be in a non-final location and the script will assemble it into the final location.

The end result is that share/wasi-sysroot/include directly includes header files which are the exact same across all targets and configurations. This doesn't include all headers, however, and per-target sysroots are still present for headers that differ like wasi/version.h or exception-related things in libcxx.

Overall this shaved ~300M off a local install which seems like a nice size reduction.

Closes #655

This commit is an attempt at addressing WebAssembly#655 to remove duplicate header
files across the sysroot. I don't know of an easy way of doing this with
the built-in installation processes so a small script is added here
which implements the logic of moving files around. The build process now
configures the include install directory to be in a non-final location
and the script will assemble it into the final location.

The end result is that `share/wasi-sysroot/include` directly includes
header files which are the exact same across all targets and
configurations. This doesn't include all headers, however, and
per-target sysroots are still present for headers that differ like
`wasi/version.h` or exception-related things in libcxx.

Overall this shaved ~300M off a local install which seems like a nice
size reduction.

Closes WebAssembly#655
@alexcrichton
alexcrichton requested a review from dicej September 9, 2026 20:44
Comment thread src/dedupe_headers.rs Outdated
// Bring all iterators up to `name`
for (other, src) in rest.iter_mut() {
while let Some((e, ft)) = other.next_if(|(e, _)| e < name) {
// cp_r(&mut src.join(&e), ft, &mut dst_root.join(&dst).join(&e));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Stray commented code?

@alexcrichton
alexcrichton enabled auto-merge (squash) September 10, 2026 22:07
@alexcrichton
alexcrichton merged commit 26941da into WebAssembly:main Sep 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicated c++ library in sysroot

3 participants