Skip to content
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

Support of mingw cross compilation? #10

Open
Hideman85 opened this issue Jan 6, 2020 · 10 comments
Open

Support of mingw cross compilation? #10

Hideman85 opened this issue Jan 6, 2020 · 10 comments

Comments

@Hideman85
Copy link

HastyNoise/build (master)$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../WindowsCompileOnLinux.cmake 
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /usr/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- HN_SIMD_SSE2: ON
-- HN_SIMD_SSE41: ON
-- HN_SIMD_AVX2: ON
-- HN_SIMD_AVX512: ON
-- Configuring done
-- Generating done
-- Build files have been written to: HastyNoise/build
HastyNoise/build (master)$ make
Scanning dependencies of target hastyNoise
[  9%] Building CXX object CMakeFiles/hastyNoise.dir/HastyNoise/hastyNoise.cpp.obj
HastyNoise/HastyNoise/hastyNoise.cpp: In function ‘size_t HastyNoise::_GetFastestSIMD()’:
HastyNoise/HastyNoise/hastyNoise.cpp:175:40: error: ‘_XCR_XFEATURE_ENABLED_MASK’ was not declared in this scope
         uint64_t xcrFeatureMask=xgetbv(_XCR_XFEATURE_ENABLED_MASK);
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
HastyNoise/HastyNoise/hastyNoise.cpp:201:34: error: ‘_XCR_XFEATURE_ENABLED_MASK’ was not declared in this scope
     bool oxAVX512Support=(xgetbv(_XCR_XFEATURE_ENABLED_MASK)&0xe6)==0xe6;
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/hastyNoise.dir/build.make:63: CMakeFiles/hastyNoise.dir/HastyNoise/hastyNoise.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/hastyNoise.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Toolchain file:

# the name of the target operating system
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_EXE_LINKER_FLAGS -static-libstdc++\ -static-libgcc\ -static)

# Which compilers to use for C and C++
set(CMAKE_C_COMPILER /usr/bin/x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER /usr/bin/x86_64-w64-mingw32-windres)
@caseymcc
Copy link
Owner

caseymcc commented Jan 6, 2020

try to put

#ifndef _XCR_XFEATURE_ENABLED_MASK
#define _XCR_XFEATURE_ENABLED_MASK 0
#endif

at the top of hastyNoise.cpp

@Hideman85
Copy link
Author

When I do that it is even worst got lot of errors:

In file included from /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/include/x86intrin.h:74,
                 from /usr/share/mingw-w64/include/winnt.h:1554,
                 from /usr/share/mingw-w64/include/minwindef.h:163,
                 from /usr/share/mingw-w64/include/windef.h:8,
                 from /usr/share/mingw-w64/include/windows.h:69,
                 from /tmp/HastyNoise/HastyNoise/hastyNoise.cpp:39:
/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/include/xsaveintrin.h: In function ‘uint64_t HastyNoise::xgetbv(unsigned int)’:
/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/include/xsaveintrin.h:60:1: error: inlining failed in call to always_inline ‘long long int _xgetbv(unsigned int)’: target specific option mismatch
 _xgetbv (unsigned int __A)
 ^~~~~~~
/tmp/HastyNoise/HastyNoise/hastyNoise.cpp:130:19: note: called from here
     return _xgetbv(x);
/tmp/HastyNoise/HastyNoise/hastyNoise_internal.inl:83:51: error: expected initializer before ‘Lerp’
 static typename SIMD<_SIMDType>::Float VECTORCALL Lerp(typename SIMD<_SIMDType>::Float a, typename SIMD<_SIMDType>::Float b, typename SIMD<_SIMDType>::Float t)
                                                   ^~~~
/tmp/HastyNoise/HastyNoise/hastyNoise_internal.inl:92:51: error: expected initializer before ‘InterpQuintic’
 static typename SIMD<_SIMDType>::Float VECTORCALL InterpQuintic(typename SIMD<_SIMDType>::Float t)
                                                   ^~~~~~~~~~~~~
/tmp/HastyNoise/HastyNoise/hastyNoise_internal.inl:107:51: error: expected initializer before ‘CubicLerp’
 static typename SIMD<_SIMDType>::Float VECTORCALL CubicLerp(typename SIMD<_SIMDType>::Float a, typename SIMD<_SIMDType>::Float b, typename SIMD<_SIMDType>::Float c, typename SIMD<_SIMDType>::Float d, typename SIMD<_SIMDType>::Float t)
                                                   ^~~~~~~~~
In file included from /tmp/HastyNoise/HastyNoise/hastyNoise_none.cpp:8:
/tmp/HastyNoise/HastyNoise/hastyNoise_internal.inl:114:49: error: expected initializer before ‘Hash’
 static typename SIMD<_SIMDType>::Int VECTORCALL Hash(typename SIMD<_SIMDType>::Int seed, typename SIMD<_SIMDType>::Int x, typename SIMD<_SIMDType>::Int y, typename SIMD<_SIMDType>::Int z)
                                                 ^~~~
/tmp/HastyNoise/HastyNoise/hastyNoise_internal.inl:130:49: error: expected initializer before ‘HashHB’
 static typename SIMD<_SIMDType>::Int VECTORCALL HashHB(typename SIMD<_SIMDType>::Int seed, typename SIMD<_SIMDType>::Int x, typename SIMD<_SIMDType>::Int y, typename SIMD<_SIMDType>::Int z)
                                                 ^~~~~~
/tmp/HastyNoise/HastyNoise/hastyNoise_internal.inl:145:51: error: expected initializer before ‘ValCoord’
 static typename SIMD<_SIMDType>::Float VECTORCALL ValCoord(typename SIMD<_SIMDType>::Int seed, typename SIMD<_SIMDType>::Int x, typename SIMD<_SIMDType>::Int y, typename SIMD<_SIMDType>::Int z)
                                                   ^~~~~~~~
In file included from /tmp/HastyNoise/HastyNoise/hastyNoise_none.cpp:1:
/tmp/HastyNoise/HastyNoise/hastyNoise.h:248:20: error: expected ‘;’ at end of member declaration
 #define VECTORCALL __vectorcall
                    ^~~~~~~~~~~~
/tmp/HastyNoise/HastyNoise/hastyNoise_internal.inl:163:44: note: in expansion of macro ‘VECTORCALL’
     static typename SIMD<_SIMDType>::Float VECTORCALL _(typename SIMD<_SIMDType>::Int seed, typename SIMD<_SIMDType>::Int xi, typename SIMD<_SIMDType>::Int yi, typename SIMD<_SIMDType>::Int zi, typename SIMD<_SIMDType>::Float x, typename SIMD<_SIMDType>::Float y, typename SIMD<_SIMDType>::Float z)
....

@caseymcc
Copy link
Owner

caseymcc commented Jan 6, 2020

Yeah that just means there are more errors then the first ones. I never tried to compile it in mingw. Although you would assume gcc to be the same everywhere it really is not. May also be related to the gcc version. I do not have a mingw environment setup but if a get a chance this weekend I will take a look.

@Hideman85
Copy link
Author

For a pre made MingW64 environment look at https://github.com/dockcross/dockcross and the image windows-static-x64

@caseymcc
Copy link
Owner

checked in some fixes to https://github.com/caseymcc/HastyNoise/tree/mingw, I need to verify everything still works on the rest of the platforms before I merge it.

@Hideman85
Copy link
Author

Got this issue:

make
Scanning dependencies of target hastyNoise
[  9%] Building CXX object CMakeFiles/hastyNoise.dir/HastyNoise/hastyNoise.cpp.obj
In file included from /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/include/x86intrin.h:74,
                 from /usr/share/mingw-w64/include/winnt.h:1554,
                 from /usr/share/mingw-w64/include/minwindef.h:163,
                 from /usr/share/mingw-w64/include/windef.h:8,
                 from /usr/share/mingw-w64/include/windows.h:69,
                 from HastyNoise/HastyNoise/hastyNoise.cpp:39:
/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/include/xsaveintrin.h: In function ‘uint64_t HastyNoise::xgetbv(unsigned int)’:
/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/include/xsaveintrin.h:60:1: error: inlining failed in call to always_inline ‘long long int _xgetbv(unsigned int)’: target specific option mismatch
 _xgetbv (unsigned int __A)
 ^~~~~~~
HastyNoise/HastyNoise/hastyNoise.cpp:133:19: note: called from here
     return _xgetbv(x);
            ~~~~~~~^~~
make[2]: *** [CMakeFiles/hastyNoise.dir/build.make:63: CMakeFiles/hastyNoise.dir/HastyNoise/hastyNoise.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:112: CMakeFiles/hastyNoise.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

dockcross image don't have filesystem so it should be installed.

@caseymcc
Copy link
Owner

are you compiling for 32bit?

@Hideman85
Copy link
Author

Normally no and I didn't specified any kind of options for but this include x86intrin.h let's me having a doubt.

@Hideman85
Copy link
Author

This line is set in my toolchain file that must trigger 64bit compilation set(CMAKE_SYSTEM_PROCESSOR x86_64 CACHE STRING "System Processor")

@TokisanGames
Copy link

Mingw does not support building AVX aligned code. This repo won't be able to fix the problem without compiler support.

Here are a few of many discussion links:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412

https://sourceforge.net/p/mingw-w64/mailman/message/34453497/

https://stackoverflow.com/questions/30928265/mingw64-is-incapable-of-32-byte-stack-alignment-required-for-avx-on-windows-x64

msys2/MSYS2-packages#1209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants