zstd: Work around gcc segfault on versions older than 11.4
PATCH 1/1 zstd: Work around gcc segfault on versions older than 11.4
From: Nick Terrell <[email protected]>
Older gcc version segfault in zstd code as of 9d7de2aa8b41 on x86. This seems to be triggered by some other compilation changes. But it can be worked around by disabling DYNAMIC_BMI2 for older gcc compilers.
The original suggested patch in the thread suggested gating on gcc >= 11, but there is only positive confirmation that gcc 11.4 and later succeed, so I'm being slightly more conservative.
This will reduce performance of Zstandard decoding by ~10% if using a gcc version older than 11.4, and the binary is not compiled with BMI2 support at compile time.
I've compiled & run basic tests for gcc-9 and gcc-14.2. I've reproed the gcc segfault before the fix, and it compiles after.
--- lib/zstd/common/portability_macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
lib/zstd/common/portability_macros.h +4 -2
@@ -56,12 +56,14 @@/* Enable runtime BMI2 dispatch based on the CPU. -* Enabled for clang & gcc >=4.8 on x86 when BMI2 isn't enabled by default. +* Enabled for clang & gcc >= 11.4 on x86 when BMI2 isn't enabled by default. +* Disabled for gcc < 11.4 because of a segfault while compiling +* HUF_compress1X_usingCTable_internal_body(). */ #ifndef DYNAMIC_BMI2 # if ((defined(__clang__) &&__has_attribute (__target__)) \ || (defined(__GNUC__) \ - && (__GNUC__ >=5 || (__GNUC__ ==4 && __GNUC_MINOR__ >=8 )))) \ + && (__GNUC__ >=12 || (__GNUC__ ==11 && __GNUC_MINOR__ >=4 )))) \ && (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)) \ && !defined(__BMI2__)# define DYNAMIC_BMI2 1
Signature · 1 line
2.48.1