OpenSiv3D
OpenSiv3D copied to clipboard
[ビルドエラー] simde_mm_loadu_epi64 redefined
エラーの内容 | Describe the build error
simde_mm_loadu_epi64
already defined
[ 0%] Building CXX object CMakeFiles/Siv3D.dir/home/duckz/dev/thirdparty/OpenSiv3D/Siv3D/src/Siv3D/BigFloat/SivBigFloat.cpp.o
In file included from /home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/Siv3D/SIMD.hpp:20,
from /home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/SMFT/SMFT.hpp:4,
from /home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/Siv3D/SMFT.hpp:15,
from /home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/Siv3D/Random.hpp:15,
from /home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/Siv3D/String.hpp:22,
from /home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/Siv3D/BigInt.hpp:19,
from /home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/Siv3D/BigFloat.hpp:17,
from /home/duckz/dev/thirdparty/OpenSiv3D/Siv3D/src/Siv3D/BigFloat/BigFloatDetail.hpp:13,
from /home/duckz/dev/thirdparty/OpenSiv3D/Siv3D/src/Siv3D/BigFloat/SivBigFloat.cpp:12:
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3514:30: error: redefinition of ‘__m128i simde_mm_loadu_epi64(const void*)’
3514 | #define _mm_loadu_epi64(a) simde_mm_loadu_epi64(a)
| ^~~~~~~~~~~~~~~~~~~~
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3494:1: note: ‘simde__m128i simde_mm_loadu_epi64(const void*)’ previously defined here
3494 | simde_mm_loadu_epi64(void const * mem_addr) {
| ^~~~~~~~~~~~~~~~~~~~
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3489:30: error: redefinition of ‘__m128i simde_mm_loadu_epi32(const void*)’
3489 | #define _mm_loadu_epi32(a) simde_mm_loadu_epi32(a)
| ^~~~~~~~~~~~~~~~~~~~
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3469:1: note: ‘simde__m128i simde_mm_loadu_epi32(const void*)’ previously defined here
3469 | simde_mm_loadu_epi32(void const * mem_addr) {
| ^~~~~~~~~~~~~~~~~~~~
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3464:30: error: redefinition of ‘__m128i simde_mm_loadu_epi16(const void*)’
3464 | #define _mm_loadu_epi16(a) simde_mm_loadu_epi16(a)
| ^~~~~~~~~~~~~~~~~~~~
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3444:1: note: ‘simde__m128i simde_mm_loadu_epi16(const void*)’ previously defined here
3444 | simde_mm_loadu_epi16(void const * mem_addr) {
| ^~~~~~~~~~~~~~~~~~~~
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3439:29: error: redefinition of ‘__m128i simde_mm_loadu_epi8(const void*)’
3439 | #define _mm_loadu_epi8(a) simde_mm_loadu_epi8(a)
| ^~~~~~~~~~~~~~~~~~~
/home/duckz/dev/thirdparty/OpenSiv3D/Linux/../Siv3D/include/ThirdParty/simde/x86/sse2.h:3419:1: note: ‘simde__m128i simde_mm_loadu_epi8(const void*)’ previously defined here
3419 | simde_mm_loadu_epi8(void const * mem_addr) {
| ^~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/Siv3D.dir/build.make:2036: CMakeFiles/Siv3D.dir/home/duckz/dev/thirdparty/OpenSiv3D/Siv3D/src/Siv3D/BigFloat/SivBigFloat.cpp.o] Errore 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/Siv3D.dir/all] Errore 2
make: *** [Makefile:91: all] Errore 2
再現方法 | To Reproduce
- configure with
cmake -DCMAKE_BUILD_TYPE=Debug ~/dev/thirdparty/OpenSiv3D/Linux/
- compile with
make -j8
or equivalent
ビルド環境 | Develop environment (please complete the following information):
- OS: Gentoo Linux
- 開発環境 | IDE: cmake + make
備考 | Additional context
Preprocessed cpp file does indeed have two definitions of simde_mm_loadu_epi16
:
__attribute__((__always_inline__)) inline static
simde__m128i
simde_mm_loadu_epi64(void const * mem_addr) {
return _mm_loadu_si128((__extension__({
# 3498 "../../../thirdparty/OpenSiv3D/Siv3D/include/ThirdParty/simde/x86/sse2.h"
#pragma GCC diagnostic push
# 3498 "../../../thirdparty/OpenSiv3D/Siv3D/include/ThirdParty/simde/x86/sse2.h"
# 3498 "../../../thirdparty/OpenSiv3D/Siv3D/include/ThirdParty/simde/x86/sse2.h"
#pragma GCC diagnostic ignored "-Wcast-align"
# 3498 "../../../thirdparty/OpenSiv3D/Siv3D/include/ThirdParty/simde/x86/sse2.h"
__m128i const * simde_r_ = (reinterpret_cast<__m128i const *>(mem_addr));
# 3498 "../../../thirdparty/OpenSiv3D/Siv3D/include/ThirdParty/simde/x86/sse2.h"
#pragma GCC diagnostic pop
# 3498 "../../../thirdparty/OpenSiv3D/Siv3D/include/ThirdParty/simde/x86/sse2.h"
simde_r_; })));
# 3510 "../../../thirdparty/OpenSiv3D/Siv3D/include/ThirdParty/simde/x86/sse2.h"
}
and
extern __inline __m128i
__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
# 798 "/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/include/avx512vlintrin.h"
simde_mm_loadu_epi64(
# 798 "/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/include/avx512vlintrin.h" 3 4
void const *__P
# 798 "/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/include/avx512vlintrin.h"
)
# 799 "/usr/lib/gcc/x86_64-pc-linux-gnu/11.2.1/include/avx512vlintrin.h" 3 4
{
return (__m128i) (*(__v2di_u *) __P);
}
The problem is with line Siv3D/include/ThirdParty/simde/x86/sse2.h:3514 #define _mm_loadu_epi64(a) simde_mm_loadu_epi64(a)
: system's avx512vlintrin.h defines function _mm_loadu_epi64()
but because of the macro at line 3514 the preprocessor replaces that function name with simde_mm_loadu_epi64
causing the issue. I'd say it's:
- a really bad idea to do macro substitution like that
- a REALLY bad idea to define any names that start with a
_
I'm looking at a possible fix but I've never seen any of the code in this project or the third party projects so I can't promise anything.
Edit: there we go, I think I found the cause of the issue :) include/Siv3D/SIMD.hpp:15 reads # define SIMDE_ENABLE_NATIVE_ALIASES
(by Ryo Suzuki, commit aaa730a5e5 on 2020-10-25). From SIMDe's readme:
If you define
SIMDE_ENABLE_NATIVE_ALIASES
before including SIMDe you can use the same names as the native functions. Unfortunately, this is somewhat error-prone due to portability issues in the APIs, so it's recommended to only do this for testing.
Just to expand on my findings from Saturday: commenting out line 15 in SIMD.hpp is only the first step. It fixes that specific error for me but I see the implications. I think the proper fix would be to prefix all calls to SIMD intrinsics in the code base with "simde", or at least make that line 15 conditional on systems where such a keyword conflict would occur. I'm not very familiar with Windows, but on Linux I'd say it's only needed on ARM? It would need some testing to confirm tho.