Skip to content

Using mmap to read files#4

Merged
Spxg merged 1 commit into
wasm-bindgen:mainfrom
Spxg:w/mmap
Jan 26, 2026
Merged

Using mmap to read files#4
Spxg merged 1 commit into
wasm-bindgen:mainfrom
Spxg:w/mmap

Conversation

@Spxg

@Spxg Spxg commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@daxpedda daxpedda left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(already working on it)

Comment thread host/ld/src/main.rs Outdated
Comment on lines +628 to +632
fn map_file(path: &Path) -> Result<Mmap, Error> {
let file = File::open(path)?;
// Safety: the file is not mutated while the mapping is in use.
unsafe { Mmap::map(&file) }
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We need to account for targets memmap2 doesn't support. So we need some type that abstracts over File and Mmap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Which targets are not supported? I took a quick look, and it supports most unix and windows targets, which I think should be sufficient for our needs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Honestly, I've no idea. But we need to ship this to Rustc eventually, so we really need to cover all our bases.

Feel free to dig into Rustc and see what they are doing, if they don't think its necessary we can go ahead and remove the abstraction I added as well.

Comment thread host/ld/src/main.rs Outdated
Comment thread host/ld/src/main.rs Outdated
@Spxg Spxg merged commit a8873d8 into wasm-bindgen:main Jan 26, 2026
@Spxg Spxg deleted the w/mmap branch January 28, 2026 07:30
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.

2 participants