darmie opened PR #13481 from darmie:fix/cranelift-object-darwin-platform to bytecodealliance:main:
cranelift_native produces a Darwin(_) triple on macOS hosts, which falls through to PLATFORM_UNKNOWN (0) in the Mach-O LC_BUILD_VERSION load command. macOS ld64 rejects object files with an unknown platform, breaking native object emission on Darwin hosts.
Gate on
#[cfg(target_os = "macos")]so the override only fires when the host (and therefore the linker likely consuming the object) is itself macOS. Cross-compile pipelines that produce Darwin objects from a non-macOS host keep upstream PLATFORM_UNKNOWN behaviour — the issue is specific to ld64's host-side rejection. Map Darwin(_) to PLATFORM_MACOS the same way MacOSX(_) is mapped. Expected to dovetail with target-lexicon PR #130 once that's available upstream.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
darmie requested cfallin for a review on PR #13481.
darmie requested wasmtime-compiler-reviewers for a review on PR #13481.
darmie edited PR #13481:
cranelift_native produces a Darwin(_) triple on macOS hosts, which falls through to PLATFORM_UNKNOWN (0) in the Mach-O LC_BUILD_VERSION load command. macOS ld64 rejects object files with an unknown platform, breaking native object emission on Darwin hosts.
Gate on
#[cfg(target_os = "macos")]so the override only fires when the host (and therefore the linker likely consuming the object) is itself macOS. Cross-compile pipelines that produce Darwin objects from a non-macOS host keep upstream PLATFORM_UNKNOWN behaviour — the issue is specific to ld64's host-side rejection. Map Darwin(_) to PLATFORM_MACOS the same way MacOSX(_) is mapped. Expected to dovetail with target-lexicon PR #130.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
github-actions[bot] added the label cranelift on PR #13481.
github-actions[bot] added the label cranelift:module on PR #13481.
:memo: cfallin submitted PR review:
Thanks -- some thoughts below.
:speech_balloon: cfallin created PR review comment:
This comment is pretty verbose for what (in my reading) is basically a note that an undefined platform is problematic, and Darwin is more or less macOS for our purposes. We could probably omit it?
:speech_balloon: cfallin created PR review comment:
It doesn't seem right to me that we would change compiler behavior based on the host platform; a target is a target and we should generate identical binaries for that target no matter where we run. I see the note above that this "keeps the upstream PLATFORM_UNKOWN behavior" (a descriptive statement) but why?
:memo: darmie submitted PR review.
:speech_balloon: darmie created PR review comment:
@cfallin On my Mac (Apple M1), the
triple.operating_systemkept returningDarwininstead ofMacOSX, and that fell through toPLATFORM_UNKNOWN, and that prevented native object emission.Darwinwas never captured on that block of code, and I didn't want to generalise the fix to all Darwin targets. This is a mere redirection. Do you reckon that this fix could be applied elsewhere in the code base?
darmie updated PR #13481.
darmie updated PR #13481.
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Yes, I agree we should fix the code to make
Darwina known platform. The thing I'm objecting to is changing the compiler's output based on its host platform (what thecfgdirective does) -- the output that we produce should be a pure function of the input and configuration, and nothing else.cfgdirectives based on host platform are only appropriate in e.g. the Wasmtime runtime where the host platform is the target.So concretely I think we should remove this
cfgline. I'm not even sure what non-macOS Darwin platforms would be forcranelift-object(... running cg-clif natively on iOS? I'm not sure); and if we want ot handle those properly, we should reason about them as targets, not as hosts.
:memo: darmie submitted PR review.
:speech_balloon: darmie created PR review comment:
Update: @cfallin I have removed the cfg-target line
:thumbs_up: cfallin submitted PR review:
Thanks!
cfallin has enabled auto merge for PR #13481.
cfallin added PR #13481 cranelift-object: emit PLATFORM_MACOS for Darwin triples on macOS hosts to the merge queue.
:check: cfallin merged PR #13481.
cfallin removed PR #13481 cranelift-object: emit PLATFORM_MACOS for Darwin triples on macOS hosts from the merge queue.
Last updated: Jun 01 2026 at 09:49 UTC