Fix stdc atomics detection and add vs2019 msvc job#592
Fix stdc atomics detection and add vs2019 msvc job#592saghul merged 4 commits intoquickjs-ng:masterfrom
Conversation
|
I think you need to use the windows-2019 image: https://github.com/actions/runner-images |
|
Hmm, maybe escaping |
|
I think the problem is that we now unconditionally import the atomics compat header: https://github.com/search?q=repo%3Aquickjs-ng%2Fquickjs%20%23include%20%22quickjs-c-atomics.h%22&type=code Skipping the run-262 build should be doable, and we only use it in a single place in quickjs-libc.c so I think if we address that we should be good to go. In your case (radare2) I guess you only care about the former problem, right? |
|
Looking at https://learn.microsoft.com/en-us/cpp/overview/compiler-versions?view=msvc-170 and knowing C11 atomics made it to Visual Studio 2022 version 17.5, A working build: A failed one: I think our best bet here is to use Windows specific code for those older compiler versions. We could borrow some code from here I think: https://github.com/videolan/dav1d/blob/master/include/compat/msvc/stdatomic.h Pinging @bnoordhuis so he is aware :-) |
|
Thanks a ton for such a rich answer, it's amazing how much I can learn here 😀
Yes, the sole problem with radare2 was that we omitted adding C standard to meson build, so
Will |
Alas no, because |
|
Meh, could you please give me any hint on how this can be solved 😕 ? |
|
You can probably guard on: #if defined(_MSC_VER) && _MSC_VER < 1935
// do whatever for old msvc
#else
#include <stdatomic.h>
#endifedit: |
|
To add, you can borrow the functions we need from https://github.com/videolan/dav1d/blob/master/include/compat/msvc/stdatomic.h and snadwhich them in the if-defs Ben pointed out. |
|
Great! Thank you both for your answers, will try to copy it here |
2895c2a to
f86f91f
Compare
|
still failing :/ |
bnoordhuis
left a comment
There was a problem hiding this comment.
The polyfill is broken. It won't work for e.g. _Atomic uint8_t *.
quickjs-c-atomics.h
Outdated
| *expected = InterlockedCompareExchange(obj, desired, orig); | ||
| return *expected == orig; | ||
| } | ||
| #define atomic_compare_exchange_strong(p_a, expected, desired) atomic_compare_exchange_strong_int((LONG *)p_a, (LONG *)expected, (LONG)desired) |
There was a problem hiding this comment.
This and atomic_load/atomic_store/etc. aren't safe. quickjs.c definitely calls them on values that aren't sizeof(LONG).
There was a problem hiding this comment.
Will removing the casting to LONG make them safe?
There was a problem hiding this comment.
No. There's https://learn.microsoft.com/en-us/previous-versions/ttk2z1ws(v=vs.85) for compare-and-swap for 16, 32 and 64 bits values, but not 8 bits, AFAIK.
There was a problem hiding this comment.
Will replacing these functions with _ alternatives do?
There was a problem hiding this comment.
My suggestion would be to use _Generic, to dispatch based on the type. That should (fingers crossed) work with 2019.
|
How come that |
|
Looks like ready to merge |
|
https://github.com/quickjs-ng/quickjs/pull/592/files#r1797425774 is still unresolved. I don't know of a way to implement compare-and-swap for 8 bit types (not without falling back to assembly) so maybe the best way forward is to:
|
|
The CO does pass but I think Ben's comments haven't been addressed yet. |
The problem is libc now depends on atomics too (can_poll) so that's a problem... |
|
Yes, that's addressed by (2), generic overloads for int32 and uint32 for three atomic operations. quickjs-libc.c doesn't use anything else (for now, anyway.) |
|
Great, let's strive for 2 then! |
|
Woow, didn't know that you can invoke a different function based on different type in C, will try that, thanks 😎 |
5d7c4da to
178c002
Compare
|
Done EDIT: Eh, again fail :/// |
|
The build step looks successful but it really failed with some syntax errors... |
|
|
|
I just landed the PR which removed the need for atomics on quickjs-libc. So, you can probably get away with not implementing support for them yourself now ;-) |
|
Great! Thanks a lot, I will try to update qjs on radare2 and see how it goes, will let u know |
178c002 to
afbbaf3
Compare
|
Short note: It's working now for radare2 !! |
|
Great to hear! 👏👏 |
Made a PR as mentioned in issue #586