-
Notifications
You must be signed in to change notification settings - Fork 174
MSVC 2022 build errors #309
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
Comments
Can you send a PR? Bonus points if you first update the CI so it uses MSVC 2022 as well so the failure surfaces. |
Fyi When I apply suggested changes above it does fix the It looks like the people at rquickjs fixed this once but I can't seem to apply those changes to fix the error... (or I simply don't understand what the patch actually changes) |
Do you know how to use MSVC 2022? This is what our Windows runners use:
|
I suspect it works around the... creative... approach of tying libc's ceil and Math.ceil together (edit: and floor, etc.) Math.ceil is implemented by means of the JS_CFUNC_SPECIAL_DEF macro, and that macro basically consists of a struct initialization that looks like this: (JSCFunctionListEntry){ u.func.cproto = ceil } // note: cproto is uint8_t, not a function pointer msvc is pretty aggressive when it comes to inlining and replacing function calls with intrinsics. I suspect that (JSCFunctionListEntry){ u.func.cfunc.f_f = ceil } // f_f is a double (*)(double) function pointer |
For the However, then I encountered It can be reproduced as follows: cmake .
cmake --build . --config Release The |
Interesting! How is --config different from build type? |
It just like you changing the option in VS2022 GUI, and yes, it will reproduce if you build it with release mode by opening quickjs.sln in VS2022 GUI. So I believe this also hints at another issue that |
I mean, even if set |
Aha, that makes sense! I'll look into it! |
Hum. I'm looking at this but cannot see that.
This is called like so: So it will be expanded to: No? The Did I miss something? |
I "fixed" the CI in #346 so now I see the errors, but they are a bit different. |
The function pragma trick seems reasonable I think! https://learn.microsoft.com/en-us/cpp/preprocessor/function-c-cpp?view=msvc-170 |
The initializer is OK, but it seems problematic to intiialize static data such as a function pointer with the address of an entry point in a dynamic loaded library, especially on Windows. We should use wrappers for all math functions, which will be the compiler the opportunity to inline the calls and avoid the DLL overhead. |
Taking the fix from this change: quickjs-ng/quickjs#309. Applied directly to our version of quickjs that we maintain in the repo.
This problem is caused when including <windows.h> before <winsock2.h>
Solution: just remove "#include <windows.h>" from cutils.h because <winsock2.h> already does it
Solution: replace
with
or with something better)
The text was updated successfully, but these errors were encountered: