-
Notifications
You must be signed in to change notification settings - Fork 171
#152 Fix crashes in tests on x86 systems without sufficient ISA support #153
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
base: master
Are you sure you want to change the base?
Conversation
test/codec_supported.c
Outdated
| #endif // __cplusplus | ||
| #endif // _MSC_VER | ||
|
|
||
| #if __has_builtin(__builtin_cpu_supports) |
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.
This might not be very portable and it seems to be breaking CI. Perhaps it can be wrapped in an #ifdef __has_builtin?
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.
While I agree that it's bad form for the tests to crash without warning, I'm not totally sure about this solution yet. Two reasons:
- There is already some "mature" runtime feature detection code in
lib/codec_choose.c, and this PR feels like it's treading the same ground. I'd prefer to unify those things if possible. (I'm not happy with the runtime detection code there by the way - it's a wart that grew out of necessity and not a problem I want to have.) - Catching
SIGILLseems like possibly a reasonable way to deal with the issue, since these are just tests.- Catching signals portably across platforms is another can of worms.
|
Sorry I couldn't respond sooner, I've been very busy at my day job. Your comments make sense, I was initialy hesitant to use the internals of codec_choose_x86 because I didn't want to accidentally export a symbol from it that wasnt previously visible. If I can figure out how to ensure no symbols leak I'll push a new revision using that function to detect feature support rather than using compiler builtins. |
|
@aklomp Is this PR ready to land? Can you approve CI? |
CI is approved, sorry for the delay. Unfortunately it's failing. I did a quick first review on the revised code and I like the approach. It feels clean to separate the feature detection code from the codec choosing code. There are some things that I'm not fond of, like removing some of the What I think can happen now is the following. Let's say that the library is compiled at SSE4 support level, but run on an AVX2 machine. The new codec chooser picks the AVX2 codec, but that one won't work because it's a no-op in that build. The right behavior would be to fall back to SSE4. The Ironically, I think this is similar to the #152 issue that started the discussion? |
|
Thanks for taking a look! I think there are two options indeed:
I'd also be in favor of option 2. However, I'd like to argue that HAVE_AVX2 is too generic of a name, and can cause bugs in larger projects who use this project as a subproject in CMake. A generic HAVE_AVX2 leaking into the compilation flags of this project can happen easily. To that end, I propose getting rid of those aliases defined here: I could do that and make my own PR to replace this one? Or you could do it? Any preferences? |
Can you describe a realistic scenario for this? I can only think of global unity builds (where you very likely also get in trouble due to non-namespaced |
I think a simple and commonly overused |
Which does only matter if this project is part of the directory scope calling |
Resolves #152. I opted to use the compiler provided extension support rather than modify
codec_choose_x86just to be sure I didn't introduce any bugs into the autodetection logic. I've tested these changes on zen4 Genoa windows & linux, as well as qemu without kvm enabled. Changes were tested on clang, gcc, and msvc.