Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make WASI and w2c2_base.h compile on MSVC 4.0 #101

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

SergioFLS
Copy link

@SergioFLS SergioFLS commented Jul 30, 2024

Why MSVC 4.0 specifically? Mostly because it's the only compiler that I'm aware of that can target the RISC versions of Windows NT 4.0 (yes, there were official versions for MIPS, PowerPC and Alpha).

Generated code will still not compile with it though, as there's no long long type in MSVC4. You can replace all LL suffixes with i64 though, around c.c:1049:

w2c2/w2c2/c.c

Lines 1047 to 1050 in 22a9ade

case wasmValueTypeI64: {
MUST (stringBuilderAppendI64(builder, value.i64))
MUST (stringBuilderAppend(builder, "ULL"))
break;

The only reason that I didn't include it in this PR is that I wasn't able to find a way to add a type toggle switch while making the code pretty. (UPDATE: Made a W2C2_LL macro, no need for this anymore.)

There's still stuff to do to get the generated code to work completely with MSVC4, such as finding workarounds to the following errors:

  • error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64
  • fatal error C1053: 'fXXXX' : function too large

Also, while not exactly fatal, the endianness check fails on MIPS for some reason (untested on PowerPC and Alpha).

Those errors come from the Python example, although I was able to get the ls and Rust examples working from the current patches.

Copy link
Owner

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice, thank you for adding support for that compiler 👍

w2c2/w2c2_base.h Outdated Show resolved Hide resolved
@turbolent turbolent merged commit f0f16b3 into turbolent:main Jul 31, 2024
72 of 73 checks passed
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