-
Notifications
You must be signed in to change notification settings - Fork 720
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
Fix wasm2c on windows (via MSVC) #909
Conversation
* `min`/`max` are defined in windows headers, so avoid using them as symbol names. * Don't write 0-sized variable definitions; MSVC doesn't like them. * Prefix all functions with `WASM_RT_CC` to allow specifying a calling convention. On MSVC this is always `__vectorcall`, to prevent the optimizer from using the x87 stack for passing floats and doubles. * Cast the load/store offset to `u64` before adding it to the address. * MSVC doesn't have `__builtin_expect`, so just ignore it. * Copy MSVC implementations of i{32,64}.{clz,ctz,popcount} from config.h.in * Write 32-bit float constants with 10 digits of precision instead of 9. For some reason MSVC says that `3.40282347e+38f` is too big, but `3.402823466e+38f` is OK. * Refactor `run-spec-wasm2c.py` a bit to pass different command-line flags when running as MSVC. The `--msvc` flag enables this new behavior. * MSVC doesn't have `__attribute__((noreturn))` but instead has `__declspec(noreturn)`.
* Forward `--msvc` flag through `run-tests.py` to `run-spec-wasm2c.py` * Wrap some long lines * Some python2 vs python3 fixes * Default compiler with `--msvc` flag is `cl`
* Avoid undefined behavior w/ isalpha/isalnum * Track call stack size (not just call stack depth) when trying to determine call stack exhaustion
2e815a9
to
6632167
Compare
static inline unsigned long HighDword(unsigned __int64 value) { | ||
unsigned long high; | ||
memcpy(&high, (unsigned char*)&value + sizeof(high), sizeof(high)); | ||
return high; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return value >> 32;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I copied this from config.h.in, but I'm not sure why I wrote it this way. :-)
t2 result; \ | ||
memcpy(&result, &x, sizeof(result)); \ | ||
return result; \ | ||
#define DEFINE_REINTERPRET(name, t1, t2) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, though I'd rather get this working and landed before optimizing. It still isn't quite there, unfortunately. It's pretty hard for me to test, since I don't normally run windows.
Done in #1843. |
No description provided.