Environment
- OS: ALT Linux (e2k / Elbrus)
- Compiler: LCC (
e2k-alt-linux-gcc)
- Package version: 1.5.7.2+ (with vendored zstd sources)
Problem description
When installing the package via pip on the Elbrus (e2k) architecture, the compilation fails due to a false positive trigger in the compile-time static assert macro. The LCC compiler throws an error stating that the array size must be greater than zero during the size comparison of bitContainer and U32.
Error Log
lcc: "zstd/lib/common/debug.h", line 39: error #94: the size of an array must be greater than zero
#define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
^
in expansion of macro "DEBUG_STATIC_ASSERT" at line 168 of
"zstd/lib/common/bitstream.h"
DEBUG_STATIC_ASSERT(sizeof(bitContainer) == sizeof(U32));
1 error detected in the compilation of "zstd/lib/common/entropy_common.c".
error: command '/usr/bin/e2k-alt-linux-gcc' failed with exit code 1
Suggested Solution
To prevent breaking compatibility with mainstream compilers (GCC, Clang, MSVC) on x86/ARM while enabling successful builds on Elbrus, we can conditionally bypass or adapt this macro when the __LCC__ compiler flag is detected.
Modifying zstd/lib/common/debug.h as follows resolves the issue:
#if defined(__LCC__)
# if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
# define DEBUG_STATIC_ASSERT(c) _Static_assert((c), #c)
# else
# define DEBUG_STATIC_ASSERT(c) ((void)0)
# endif
#else
# define DEBUG_STATIC_ASSERT(c) (void)sizeof(char[(c) ? 1 : -1])
#endif
Could you please consider adding this or a similar fix in the next release? Thank you!
Environment
e2k-alt-linux-gcc)Problem description
When installing the package via
pipon the Elbrus (e2k) architecture, the compilation fails due to a false positive trigger in the compile-time static assert macro. The LCC compiler throws an error stating that the array size must be greater than zero during the size comparison ofbitContainerandU32.Error Log
Suggested Solution
To prevent breaking compatibility with mainstream compilers (GCC, Clang, MSVC) on x86/ARM while enabling successful builds on Elbrus, we can conditionally bypass or adapt this macro when the
__LCC__compiler flag is detected.Modifying
zstd/lib/common/debug.has follows resolves the issue:Could you please consider adding this or a similar fix in the next release? Thank you!