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
@sbc100

sbc100 commented Sep 14, 2026

Copy link
Copy Markdown
Member

Rust seems like a rather odd choice of language here? Is there already precedent to using rust in wasi-sdk or is this the first time? Since the CI passes it seems that at least rustc must already exist in the PATH of the CI machines? Was this already a requirement for some reason?

@alexcrichton
alexcrichton deleted the deduplicate-sysroot branch September 14, 2026 14:29
@alexcrichton

Copy link
Copy Markdown
Collaborator Author

Rust is already required for wasm-component-ld, and I didn't want to write bash for something as complicated as this. Otherwise there's not many other maintainers right now for this repo so I figured I'd pick what I'm most comfortable with.

@sbc100

sbc100 commented Sep 14, 2026

Copy link
Copy Markdown
Member

Fair enough. I guess i had memories of python being used for this kind of scripting but I think I must have been misremembering.

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

4 participants