Skip to content

Commit

Permalink
Display compile warnings due to compiler bugs once only
Browse files Browse the repository at this point in the history
  • Loading branch information
animetosho committed Apr 8, 2023
1 parent 7292bdc commit 2d46948
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
26 changes: 19 additions & 7 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,8 @@
"type": "static_library",
"defines": ["NDEBUG"],
"sources": [
"gf16/gf16_affine_avx2.c"
"gf16/gf16_affine_avx2.c",
"src/platform_warnings.c"
],
"cflags": ["-Wno-unused-function", "-std=gnu99"],
"xcode_settings": {
Expand All @@ -671,14 +672,25 @@
"msvs_settings": {"VCCLCompilerTool": {"BufferSecurityCheck": "false"}},
"conditions": [
['target_arch in "ia32 x64" and OS!="win"', {
"variables": {"supports_gfni_avx2%": "<!(<!(echo ${CC_target:-${CC:-cc}}) -MM -E gf16/gf16_affine_avx2.c -mgfni -mavx2 2>/dev/null || true)"},
"variables": {
"supports_gfni%": "<!(<!(echo ${CC_target:-${CC:-cc}}) -MM -E gf16/gf16_affine_avx2.c -mgfni 2>/dev/null || true)",
"supports_avx2%": "<!(<!(echo ${CC_target:-${CC:-cc}}) -MM -E gf16/gf16_affine_avx2.c -mavx2 2>/dev/null || true)"
},
"conditions": [
['supports_gfni_avx2!=""', {
"cflags": ["-mgfni", "-mavx2"],
"cxxflags": ["-mgfni", "-mavx2"],
['supports_avx2!=""', {
"cflags": ["-mavx2"],
"cxxflags": ["-mavx2"],
"xcode_settings": {
"OTHER_CFLAGS": ["-mavx2"],
"OTHER_CXXFLAGS": ["-mavx2"],
}
}],
['supports_gfni!=""', {
"cflags": ["-mgfni"],
"cxxflags": ["-mgfni"],
"xcode_settings": {
"OTHER_CFLAGS": ["-mgfni", "-mavx2"],
"OTHER_CXXFLAGS": ["-mgfni", "-mavx2"],
"OTHER_CFLAGS": ["-mgfni"],
"OTHER_CXXFLAGS": ["-mgfni"],
}
}]
]
Expand Down
6 changes: 4 additions & 2 deletions src/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@
# endif
#endif


// AVX on mingw-gcc is just broken - don't do it...
#if defined(HEDLEY_GCC_VERSION) && (defined(__MINGW32__) || defined(__MINGW64__)) && defined(__AVX2__)
#if defined(HEDLEY_GCC_VERSION) && (defined(__MINGW32__) || defined(__MINGW64__)) && defined(__AVX2__) && defined(PP_PLATFORM_SHOW_WARNINGS)
HEDLEY_WARNING("Compiling AVX code on MinGW GCC may cause crashing due to stack alignment bugs [https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412]");
// as of writing, GCC 10.1 still has this problem, and it doesn't look like it'll be fixed any time soon
// ...so if you're reading this, try Clang instead
Expand All @@ -181,6 +180,9 @@ HEDLEY_WARNING("Compiling AVX code on MinGW GCC may cause crashing due to stack
// we hack around it by pretending GCC < 10 doesn't support GFNI
#if !HEDLEY_GCC_VERSION_CHECK(10,0,0) && defined(HEDLEY_GCC_VERSION) && defined(__OPTIMIZE__) && defined(__GFNI__)
# undef __GFNI__
# ifdef PP_PLATFORM_SHOW_WARNINGS
HEDLEY_WARNING("GFNI disabled on GCC < 10 due to incorrect GF2P8AFFINEQB operand placement");
# endif
#endif

#if !HEDLEY_GCC_VERSION_CHECK(5,0,0) && defined(HEDLEY_GCC_VERSION) && defined(__AVX512F__)
Expand Down
3 changes: 3 additions & 0 deletions src/platform_warnings.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// dummy compilation unit to display platform warnings
#define PP_PLATFORM_SHOW_WARNINGS
#include "platform.h"

0 comments on commit 2d46948

Please sign in to comment.