stdlib
stdlib copied to clipboard
Build error with ifx on windows
I tried building with ifx on windows. The way the compiler options are handled, the default language mode is set to fortran 18 (/stand:f18) files in .f90 have a large number of warnings for deprecated constructs. Also there is a large amount of unused variable warnings. Edit: I see the warnings are due to the normal build being a RelWithDebInfo. So the debug flags are used as well. However the build also fails with and issue with finding c++ standard library symbols.
FAILED: test/hash_functions/test_hash_functions.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=test\hash_functions\CMakeFiles\test_hash_functions.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\mt.exe --manifests -- C:\PROGRA~2\Intel\oneAPI\compiler\latest\bin\ifx.exe /nologo test\hash_functions\CMakeFiles\test_hash_functions.dir\test_hash_functions.f90.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\nmhash.c.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\pengyhash.c.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\SpookyV2.cpp.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\SpookyV2Test.cpp.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\waterhash.c.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\generate_hash_arrays.cpp.obj /Qoption,link,/machine:x64 /Qoption,link,/debug /Qoption,link,/INCREMENTAL /Qoption,link,/subsystem:console src\fortran_stdlib.lib _deps\test-drive-build\test-drive.lib user32.lib /link /out:test\hash_functions\test_hash_functions.exe /implib:test\hash_functions\test_hash_functions.lib /pdb:test\hash_functions\test_hash_functions.pdb /version:0.0 && cd ."
LINK: command "C:\PROGRA~2\Intel\oneAPI\compiler\latest\bin\ifx.exe /nologo test\hash_functions\CMakeFiles\test_hash_functions.dir\test_hash_functions.f90.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\nmhash.c.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\pengyhash.c.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\SpookyV2.cpp.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\SpookyV2Test.cpp.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\waterhash.c.obj test\hash_functions\CMakeFiles\test_hash_functions.dir\generate_hash_arrays.cpp.obj /Qoption,link,/machine:x64 /Qoption,link,/debug /Qoption,link,/INCREMENTAL /Qoption,link,/subsystem:console src\fortran_stdlib.lib _deps\test-drive-build\test-drive.lib user32.lib /link /out:test\hash_functions\test_hash_functions.exe /implib:test\hash_functions\test_hash_functions.lib /pdb:test\hash_functions\test_hash_functions.pdb /version:0.0 /MANIFEST:EMBED,ID=1" failed (exit code 1120) with the following output:
LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4217: symbol 'fclose' defined in 'libucrt.lib(fclose.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"public: class std::basic_filebuf<char,struct std::char_traits<char> > * __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::close(void)" (?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ)'
LINK : warning LNK4217: symbol '_lock_file' defined in 'libucrt.lib(_file.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"public: virtual void __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAAXXZ)'
LINK : warning LNK4217: symbol '_unlock_file' defined in 'libucrt.lib(_file.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"public: virtual void __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAAXXZ)'
LINK : warning LNK4217: symbol 'fwrite' defined in 'libucrt.lib(fwrite.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"protected: virtual int __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::overflow(int)" (?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z)'
LINK : warning LNK4217: symbol 'fgetc' defined in 'libucrt.lib(fgetc.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"protected: virtual int __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::uflow(void)" (?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ)'
LINK : warning LNK4217: symbol 'ungetc' defined in 'libucrt.lib(ungetc.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"protected: virtual int __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::uflow(void)" (?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ)'
LINK : warning LNK4217: symbol 'setvbuf' defined in 'libucrt.lib(setvbuf.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"protected: virtual class std::basic_streambuf<char,struct std::char_traits<char> > * __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::setbuf(char *,__int64)" (?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z)'
LINK : warning LNK4217: symbol 'fflush' defined in 'libucrt.lib(fflush.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"protected: virtual int __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::sync(void)" (?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ)'
LINK : warning LNK4217: symbol '_get_stream_buffer_pointers' defined in 'libucrt.lib(_file.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"protected: void __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::_Init(struct _iobuf *,enum std::basic_filebuf<char,struct std::char_traits<char> >::_Initfl)" (?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z)'
LINK : warning LNK4217: symbol 'fputc' defined in 'libucrt.lib(fputc.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"bool __cdecl std::_Fputc<char>(char,struct _iobuf *)" (??$_Fputc@D@std@@YA_NDPEAU_iobuf@@@Z)'
LINK : warning LNK4217: symbol '_invalid_parameter' defined in 'libucrt.lib(invalid_parameter.obj)' is imported by 'generate_hash_arrays.cpp.obj' in function '"public: char & __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::front(void)" (?front@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEADXZ)'
generate_hash_arrays.cpp.obj : error LNK2019: unresolved external symbol __imp_fread referenced in function "protected: virtual __int64 __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::xsgetn(char *,__int64)" (?xsgetn@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z)
generate_hash_arrays.cpp.obj : error LNK2019: unresolved external symbol __imp__fseeki64 referenced in function "protected: virtual class std::fpos<struct _Mbstatet> __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::seekoff(__int64,int,int)" (?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@U_Mbstatet@@@2@_JHH@Z)
generate_hash_arrays.cpp.obj : error LNK2019: unresolved external symbol __imp_fgetpos referenced in function "protected: virtual class std::fpos<struct _Mbstatet> __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::seekoff(__int64,int,int)" (?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@U_Mbstatet@@@2@_JHH@Z)
generate_hash_arrays.cpp.obj : error LNK2019: unresolved external symbol __imp_fsetpos referenced in function "protected: virtual class std::fpos<struct _Mbstatet> __cdecl std::basic_filebuf<char,struct std::char_traits<char> >::seekpos(class std::fpos<struct _Mbstatet>,int)" (?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@U_Mbstatet@@@2@V32@H@Z)
generate_hash_arrays.cpp.obj : error LNK2019: unresolved external symbol __imp__CrtDbgReport referenced in function "public: char & __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::front(void)" (?front@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEADXZ)
msvcprtd.lib(locale0_implib.obj) : error LNK2019: unresolved external symbol __imp__free_dbg referenced in function "public: static void __cdecl std::_Fac_node::operator delete(void *)" (??3_Fac_node@std@@SAXPEAX@Z)
msvcprtd.lib(locale0_implib.obj) : error LNK2019: unresolved external symbol __imp__malloc_dbg referenced in function "public: static void * __cdecl std::_Fac_node::operator new(unsigned __int64)" (??2_Fac_node@std@@SAPEAX_K@Z)
test\hash_functions\test_hash_functions.exe : fatal error LNK1120: 7 unresolved externals
This means that the hash test is not built. Other than that, running the build ignoring this error, the build completes. However, there are test failures.
The following tests did not run:
121 - check4 (Skipped)
The following tests FAILED:
9 - hash_functions (Not Run)
12 - chaining_maps (Failed)
13 - open_maps (Failed)
14 - maps (Failed)
The errors encountered:
2/4 Test #12: chaining_maps ....................***Failed 0.12 sec
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
test_chaining_map 00007FF7650D6807 Unknown Unknown Unknown
test_chaining_map 00007FF76503A7CB Unknown Unknown Unknown
test_chaining_map 00007FF76506D91B Unknown Unknown Unknown
test_chaining_map 00007FF7650D6A74 Unknown Unknown Unknown
KERNEL32.DLL 00007FFF27A5E8D7 Unknown Unknown Unknown
ntdll.dll 00007FFF2839C5DC Unknown Unknown Unknown
Start 13: open_maps
3/4 Test #13: open_maps ........................***Failed 0.11 sec
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
test_open_maps.ex 00007FF6E97167A7 Unknown Unknown Unknown
test_open_maps.ex 00007FF6E967A7FB Unknown Unknown Unknown
test_open_maps.ex 00007FF6E96AD66B Unknown Unknown Unknown
test_open_maps.ex 00007FF6E9716A14 Unknown Unknown Unknown
KERNEL32.DLL 00007FFF27A5E8D7 Unknown Unknown Unknown
ntdll.dll 00007FFF2839C5DC Unknown Unknown Unknown
Start 14: maps
4/4 Test #14: maps .............................***Failed 0.13 sec
# Testing: stdlib-open-maps
Starting open-maps-fnv_1_hasher-16-byte-words ... (1/12)
forrtl: severe (170): Program Exception - stack overflow
Image PC Routine Line Source
test_maps.exe 00007FF757C4D217 Unknown Unknown Unknown
test_maps.exe 00007FF757B9776D Unknown Unknown Unknown
test_maps.exe 00007FF757B94BF9 Unknown Unknown Unknown
test_maps.exe 00007FF757BB2733 Unknown Unknown Unknown
test_maps.exe 00007FF757BB2218 Unknown Unknown Unknown
test_maps.exe 00007FF757B9CD2A Unknown Unknown Unknown
test_maps.exe 00007FF757BD5BBB Unknown Unknown Unknown
test_maps.exe 00007FF757C4D484 Unknown Unknown Unknown
KERNEL32.DLL 00007FFF27A5E8D7 Unknown Unknown Unknown
ntdll.dll 00007FFF2839C5DC Unknown Unknown Unknown
Funny... I had similar issues here with gnu compilers on windows #976 and here #971 🤔
@R-Goc would you mind testing the following:
In the CMake stdlib\test\hash_functions\CMakeLists.txt add within the if for intel compilers the if(WIN32... block :
if(CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
# Set the C++ standard to prevent icpc breakage
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set_target_properties(test_hash_functions PROPERTIES LINKER_LANGUAGE Fortran)
if(WIN32)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
target_compile_options(
test_hash_functions
PRIVATE
$<$<COMPILE_LANGUAGE:Fortran>:/libs:dll>
)
endif()
endif()
I tested with oneAPI25 on Windows and managed to build everything
Actually still fails with that. The output now:
LINK : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib 'libcmt' conflicts with use of other libs; use /NODEFAULTLIB:library
generate_hash_arrays.cpp.obj : error LNK2019: unresolved external symbol __imp__CrtDbgReport referenced in function "public: char & __cdecl std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::front(void)" (?front@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAAEADXZ)
msvcprtd.lib(locale0_implib.obj) : error LNK2019: unresolved external symbol __imp__free_dbg referenced in function "public: static void __cdecl std::_Fac_node::operator delete(void *)" (??3_Fac_node@std@@SAXPEAX@Z)
msvcprtd.lib(locale0_implib.obj) : error LNK2019: unresolved external symbol __imp__malloc_dbg referenced in function "public: static void * __cdecl std::_Fac_node::operator new(unsigned __int64)" (??2_Fac_node@std@@SAPEAX_K@Z)
test\hash_functions\test_hash_functions.exe : fatal error LNK1120: 3 unresolved externals
it seems like a lot of weirdness around msvc libs is happening.
Builds on release mode
I have a hack that makes it build in debug modes
Is to too hacky? or something we could consider to patch the build?
target_link_options(test_hash_functions
PRIVATE
/Qoption,link,/NODEFAULTLIB:libcmt
/Qoption,link,/NODEFAULTLIB:msvcrt.lib
/Qoption,link,/NODEFAULTLIB:libifcoremt.lib
)
Which should only happen on debug builds. also
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
this should be set to use the debug version on builds with debug info.
This seems to be what I ended up on:
if(WIN32)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL$<$<CONFIG:Debug>:Debug>")
target_compile_options(
test_hash_functions
PRIVATE
$<$<COMPILE_LANGUAGE:Fortran>:/libs:dll>
)
if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR "RelWithDebInfo")
target_link_options(test_hash_functions
PRIVATE
/Qoption,link,/NODEFAULTLIB:libcmt
/Qoption,link,/NODEFAULTLIB:msvcrt.lib
/Qoption,link,/NODEFAULTLIB:libifcoremt.lib
)
endif()
endif()
This is the test output with that:
The following tests did not run:
121 - check4 (Skipped)
The following tests FAILED:
12 - chaining_maps (Failed)
13 - open_maps (Failed)
14 - maps (Failed)
All three failure overflow the stack
A top level: add_link_options(/Qoption,link,/STACK:8388608) fixes the issue. Not sure if it should stay top level or not. Quite typical on windows, as the stack size default is lower. All test then pass
So it seems like having everything working and building on native windows is very much possible. Still not sure why that c/c++ library weirdness is happening.
Yes it is possible, I tested also with GNU and the segfaults I saw were comming also from the stack issue on Windows. I'll open a PR on this.
Stdlib does not perform CI tests on ifx on Windows. Can we set up tests for ifx with the help of setup-fortran and msys2 environment?
Install cmake, ninja, fypp with msys2, set intel fortran and C compiler with setup-fortran?
Looking at setup fortran it seems possible for IFX at least. I don't use msys so I won't comment on that. Not sure if msys makes any modifications to cmake. But it should be possible to install the other dependcies using pip. I don't have experience with setting up ci containers though. The way I tested it for Intel was fully on windows. But I do have binutils in path so not sure if it would work without those. Both compilers are useful for different things as Intel is for msvc ABI while msys gfortran is for the mingw ABI. To build with the Intel compiler you either need to run in the oneapi command prompt, or run the setvars.bat script under Intel\oneapi.
For windows, the easiest way to install intel oneapi for a CI would be using conda (from Miniforge3):
conda install anaconda::cmake
conda install conda-forge::ninja
conda install -c http://software.repos.intel.com/python/conda/ -c conda-forge dpcpp-cpp-rt dpcpp_win-64
conda install -c http://software.repos.intel.com/python/conda/ -c conda-forge intel-fortran-rt ifx_win-64
On windows this will install the required mvsc libraries within the conda base environement.
examples of miniforge actions https://github.com/marketplace/actions/setup-miniconda#example-10-miniforge