Stream: git-wasmtime

Topic: wasmtime / PR #13869 Add Mach-O section parsing


view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:03):

madsmtm opened PR #13869 from madsmtm:parse-macho-section to bytecodealliance:main:

Mach-O sections have a type and a number of attributes, and are grouped in segments. There is a canonical textual representation that allows specifying this with the assembly .section directive (mostly defined by LLVM's source).

Cranelift supported this with DataDescription::custom_segment_section by letting the user implement the parsing themselves, but this complicates the API (and will require breaking changes if we want to support specifying e.g. the stub size).

Instead, DataDescription::custom_section is now just a String, and cranelift-object implements the parsing of the section name into its components. This is the same "layering" that LLVM has chosen, and it seems to work well there.

This makes it easy for rustc_cranelift_backend to implement Rust's #[link_section = ...] to support things such as the ctor crate.

Discussed a bit in https://github.com/bytecodealliance/wasmtime/pull/13137, I changed my mind since then.
Fixes https://github.com/bytecodealliance/wasmtime/issues/8901.
Replaces https://github.com/rust-lang/rustc_codegen_cranelift/pull/1648.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:03):

madsmtm requested alexcrichton for a review on PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:03):

madsmtm requested wasmtime-compiler-reviewers for a review on PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:08):

alexcrichton commented on PR #13869:

@bjorn3 would you be able to review this?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:14):

madsmtm updated PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:14):

madsmtm updated PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:15):

madsmtm updated PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:20):

bjorn3 commented on PR #13869:

Sure. Will see if I can do that later today.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:26):

:memo: madsmtm submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:26):

:speech_balloon: madsmtm created PR review comment:

LLVM's parsing is more lenient, they allow whitespace as well. I can implement that too if you want?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:28):

:memo: madsmtm submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 14:28):

:speech_balloon: madsmtm created PR review comment:

This requires a stub size (5th part of the custom section name) that should be set with:
https://docs.rs/object/latest/object/read/macho/trait.Section.html#method.symbol_stub_size

I can implement that too it if you want me to?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 15:36):

github-actions[bot] added the label cranelift:module on PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 13 2026 at 15:36):

github-actions[bot] added the label cranelift on PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 07:23):

:memo: bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 07:23):

:speech_balloon: bjorn3 created PR review comment:

Probably not necessary for now. Can always be implemented later if it turns out people actually use whitespace.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 07:26):

:memo: bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 07:26):

:speech_balloon: bjorn3 created PR review comment:

The only uses I could find are in the rustc test suite: https://github.com/rust-lang/rust/blob/55b6bd8ecbed23599e966a04508a8a13cbfe90b3/tests/ui/linkage-attr/link-section-macho.rs#L44-L58 So fine to defer for now.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 07:28):

:memo: bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 07:28):

:speech_balloon: bjorn3 created PR review comment:

Maybe use the S_* constants in this test?

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 07:29):

:thumbs_up: bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 09:22):

:memo: madsmtm submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 09:22):

:speech_balloon: madsmtm created PR review comment:

Idk., I tend to think it's valuable to not do so? At least for the foo,bar,literal_pointers,no_toc+no_dead_strip test, what we want to test is that it produces the combined value 0x5000_0005, otherwise we'd be doing S_LITERAL_POINTERS | S_ATTR_NO_TOC | S_ATTR_NO_DEAD_STRIP, and that feels like too much code in a test?

But that might just be me that's scared of bitwise operations, I'll leave it to your judgement.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 09:38):

:memo: bjorn3 submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 09:38):

:speech_balloon: bjorn3 created PR review comment:

With the test as written it isn't obvious if the mapping from strings to consts is actually correct. I don't have those consts memorized ;)

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 10:49):

madsmtm updated PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 10:50):

:memo: madsmtm submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 10:50):

:speech_balloon: madsmtm created PR review comment:

Fair. I've changed the test and squashed.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 14:20):

:thumbs_up: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 14:20):

alexcrichton added PR #13869 Add Mach-O section parsing to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 14:46):

:check: alexcrichton merged PR #13869.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 14 2026 at 14:46):

alexcrichton removed PR #13869 Add Mach-O section parsing from the merge queue.


Last updated: Jul 29 2026 at 05:03 UTC