Stream: git-wasmtime

Topic: wasmtime / PR #14772 Implement PIC for s390x


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

theotherjimmy opened PR #14772 from theotherjimmy:s390x-pic to bytecodealliance:main:

This uses the R_390_GOTENT relocation instead of the inline relocations previously emitted.

This is the same issue reported as #2907 but for s390x
<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

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

theotherjimmy updated PR #14772.

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

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:49):

github-actions[bot] added the label isle on PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:49):

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

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:49):

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

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:50):

github-actions[bot] commented on PR #14772:

Subscribe to Label Action

cc @avanhatt, @cfallin, @fitzgen, @mmcloughlin

<details>
This issue or pull request has been labeled: "cranelift", "cranelift:module", "isle"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Oct 16 2026 at 13:56):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 13:18):

theotherjimmy has marked PR #14772 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 13:19):

theotherjimmy requested wasmtime-compiler-s390x-reviewers for a review on PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 13:19):

theotherjimmy removed the review request for wasmtime-compiler-reviewers from PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 13:19):

theotherjimmy requested cfallin for a review on PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 13:19):

theotherjimmy requested wasmtime-compiler-reviewers for a review on PR #14772.

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

:memo: uweigand submitted PR review.

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

:speech_balloon: uweigand created PR review comment:

We can use LGRL rd, sym@GOTENT, saving one instruction. Also, I do not think it makes sense to support an offset with this relocation - it would be preferable to have no offset here (just like TlsGd), and perform any offset addition that might be necessary at the ISLE level.

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

:speech_balloon: uweigand created PR review comment:

We probably want to use (if-let false (is_pic)) here then.

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

:speech_balloon: uweigand created PR review comment:

In the case where we have a GOT, we might want to move TLS descriptors into the GOT as well (as is done by other static compilers). Otherwise, we can get the same problem with relocations on the text section ...

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

:speech_balloon: uweigand created PR review comment:

Static compilers would use the PLT here. The only difference is that going via GOT will disable lazy binding, but that may not really be relevant here ... Might still be interesting to see if brasl func@PLT would also work.

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

:speech_balloon: uweigand created PR review comment:

I think if we just hard-code 0 instead of offset here, common ISLE logic will already handle offsets elsewhere (via regular addition). But that needs to be verified.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 15:48):

:thumbs_up: cfallin submitted PR review:

Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 15:48):

cfallin added PR #14772 Implement PIC for s390x to the merge queue.

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

uweigand commented on PR #14772:

Hi @cfallin I don't think this is ready to merge just yet, see the comments above ...

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 16:16):

cfallin removed PR #14772 Implement PIC for s390x from the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 29 2026 at 16:16):

cfallin commented on PR #14772:

Ah, sorry about that, our reviews raced. Removed from queue and will wait for resolution on the above.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:15):

:memo: theotherjimmy submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:15):

:speech_balloon: theotherjimmy created PR review comment:

Added there and the 5 other non-pic fallbacks.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:15):

:speech_balloon: theotherjimmy edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:27):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:33):

:memo: theotherjimmy submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:33):

:speech_balloon: theotherjimmy created PR review comment:

Hard coding an offset here fails tests, so I don't think this is handled with regular addition. I'll add (pun intended) an isle rule for this since it's probably better in isle than rust.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:45):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:46):

:memo: theotherjimmy submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:46):

:speech_balloon: theotherjimmy created PR review comment:

Resolved with isle. That should allow it to be better maintainable.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:46):

theotherjimmy requested uweigand for a review on PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:48):

theotherjimmy commented on PR #14772:

Please excuse me pushing a middle state by mistake. It should be ready for re-review. I've moved more of logic (offsets) into isle and implemented PLT for function references instead of GOT.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:51):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 15:52):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 17:49):

:repeat: uweigand submitted PR review:

Looking better, thanks! Still a few issues, mostly related to PLT handling.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 17:49):

:speech_balloon: uweigand created PR review comment:

This doesn't look right. The R_390_PLT32DBL relocation resolves to code (the PLT stub itself), not data. There is no point in loading from the R_390_PLT32DBL relocation, it should only ever be used with direct call (brasl) instructions.

And note that the current code already uses R_390_PLT32DBL for calls. It just sometimes instead uses the load_symbol_reloc indirection. I believe this is because (some?) embedders of Cranelift may not be handling PLT relocations correctly? Normally, the embedder should do the reachability check and create a PLT stub dynamically if the target is not directly reachable.

Interestingly, I see in cranelift/jit/src/compiled_blob.rs that this is done for Reloc::X86GOTPCRel4, but not for Reloc::S390xPLTRel32Dbl - that probably should be fixed.

But that is a separate problem, I guess. For now, I think the best way is to continue to support both "near" and "far" calls, where near calls use the PLT, and far calls in the PIC case are changes to use GOT indirection instead (as your earlier patch already had it - sorry!). Later we can investigate whether the "far" call case is even needed when all embedders support proper PLT stub generation.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 17:49):

:speech_balloon: uweigand created PR review comment:

This should always use the GOT anyway. The PLT can only be used for calls, where the address is invisible. Whenever an address is visible as a pointer, it must use the GOT, to guarantee correct pointer equality checks.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 17:49):

:speech_balloon: uweigand created PR review comment:

This still intermingles a relocation in the text section. Ideally, this would be emitted in a constant pool somewhere (not sure if the Cranelift constant pool infrastructure already supports relocs on constants ...). But I guess that can be a separate PR.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 02 2026 at 17:49):

:speech_balloon: uweigand created PR review comment:

That doesn't look right - there's still cases that use r1 ...

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 03:47):

:memo: theotherjimmy submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 03:47):

:speech_balloon: theotherjimmy created PR review comment:

I've reworked the out-of-range calls to use GOT instead.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 03:48):

:memo: theotherjimmy submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 03:48):

:speech_balloon: theotherjimmy created PR review comment:

I'm looking into compiled_blob.rs to see if we need modifications there.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 04:23):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 12:38):

:memo: uweigand submitted PR review:

This now looks good except for the missing GOT support for regular calls.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 12:38):

:speech_balloon: uweigand created PR review comment:

We need GOT support for regular calls as well, not just tail calls and try_calls.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 15:48):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 15:52):

theotherjimmy requested uweigand for a review on PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 16:12):

:memo: uweigand submitted PR review:

The tests are now all failing, something seems to be missing.

Also, minor nit inline.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 03 2026 at 16:12):

:speech_balloon: uweigand created PR review comment:

We now have explicit (RelocDistance.Far) above, but use a placeholder plus rule priority here. These cases should consistently use the same method (it seems to me if we can avoid rule priorities via explicit choices, that might be preferable).

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 17:14):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 17:19):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 17:20):

:memo: theotherjimmy submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 04 2026 at 17:20):

:speech_balloon: theotherjimmy created PR review comment:

This is to ensure that we use the PIC variant when PIC is enabled (the following line is (if-let true (is-pic))). I've removed the non-pic case's priority, since it's now explicit and made the PIC rules' priority 1.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 11:10):

:memo: uweigand submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 11:11):

:speech_balloon: uweigand created PR review comment:

What I meant is: the current code never explicitly uses matching against RelocDistance.Far. Instead we always use a pair of rules, one matching against RelocDistance.Near and the other matching against a wildcard _. There is no real difference currently, but if at any point a third member of RelocDistance were added, the current code would still work fine.

Now, if it would make life easier, I'd be OK with changing this approach to always have some rules matching RelocDistance.Far and some matching RelocDistance.Near, but no wildcard in any of the rules.

What this patch (still) does, however, is to add a (seemingly random?) mix of sometimes using RelocDistance.Far and sometimes using a wildcard. Even the three -otherwise repeating- call rule blocks now use different conventions here.

This is what I was asking you to fix. Choose one strategy or the other, but then use it consistently.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 13:21):

:memo: theotherjimmy submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 13:21):

:speech_balloon: theotherjimmy created PR review comment:

Good point. I've changed all of them to implicitly match on RelocDistance.Far instead, since that's more general and all of them can be expressed that way.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 13:21):

theotherjimmy updated PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 13:47):

:thumbs_up: uweigand submitted PR review:

LGTM now, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 13:48):

:memo: uweigand submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 13:48):

:speech_balloon: uweigand created PR review comment:

Looks good, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 13:48):

uweigand added PR #14772 Implement PIC for s390x to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 14:11):

:check: uweigand merged PR #14772.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 14:11):

uweigand removed PR #14772 Implement PIC for s390x from the merge queue.


Last updated: Nov 19 2026 at 20:05 UTC