-
-
Notifications
You must be signed in to change notification settings - Fork 260
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
Compiling with LLVM Flang on windows -> missing intrinsic functions SIZEOF or STORAGE_SIZE #4419
Comments
On closer inspection of the
This seems to be a CMake config issue. So I tried the following modification
in https://github.com/HDFGroup/hdf5/blob/develop/config/cmake/ConfigureChecks.cmake#L64 and suddenly I am passing the failed tests (and a new failure appears)
When examining the
|
Hi, @Krande ! Thank you for your report. https://github.com/HDFGroup/hdf5/wiki/Known-Issues#flang-and-lfortran If you know how to fix it, it will be awesome for HDF community! |
I was able to compile HDF5 1.14.3 with Fortran support on Linux. So, is this just something about Windows? The only issue I found was that LLVM/Flang(-new) would fail compiling the HDF5 tests due to some missing intrinsics for some REAL kinds. I patched that and HDF5 passed the tests then. |
@mjklemm Yes, as far as I can tell this is a Windows-specific error. I also managed to successfully compile HDF5 (both 1.14.3 and 1.14.4.2) on linux using LLVM Flang v18.1.3.
Was this on windows or linux? |
That was on Linux and the intrinsic in question was SPACING for REAL, kind=2,3,16. |
This is a problem with the compiler, but we'll leave this issue open until the compiler is fixed. |
@mjklemm , I see failure on mac: https://github.com/hyoklee/hdf5/blob/develop/WATCHME.md#compilers |
I was able to confirm the problem also for Linux. I'm working on a fix. |
This is the issue at LLVM llvm/llvm-project#89403 that tracks the issue with |
Hey, just to provide an update to this. I can confirm that the original reported error is fixed with the work by @mjklemm. The original error which is fixed
However, a different error occurs on the same configuration check: -
kind: "try_run-v1"
backtrace:
- "config/cmake/HDF5UseFortran.cmake:46 (TRY_RUN)"
- "config/cmake/HDF5UseFortran.cmake:149 (FORTRAN_RUN)"
- "CMakeLists.txt:1076 (include)"
directories:
source: "D:/bld/hdf5_1722438888865/work/build/CMakeFiles/CMakeTmp"
binary: "D:/bld/hdf5_1722438888865/work/build/CMakeFiles/CMakeTmp"
cmakeVariables:
CMAKE_EXE_LINKER_FLAGS: "/machine:x64 -stack:10000000"
CMAKE_Fortran_FLAGS: ""
CMAKE_Fortran_FLAGS_RELEASE: ""
CMAKE_MODULE_PATH: "D:/bld/hdf5_1722438888865/work/config/cmake"
CMAKE_POSITION_INDEPENDENT_CODE: "ON"
buildResult:
variable: "COMPILE_RESULT_VAR"
cached: true
stdout: |
Change Dir: 'D:/bld/hdf5_1722438888865/work/build/CMakeFiles/CMakeTmp'
Run Build Command(s): D:/bld/hdf5_1722438888865/_build_env/Library/bin/ninja.exe -v cmTC_3969e
[1/4] C:\\Windows\\system32\\cmd.exe /C "D:\\bld\\hdf5_1722438888865\\_build_env\\Library\\bin\\flang-new.exe -cpp -fms-runtime-lib=dll -E D:\\bld\\hdf5_1722438888865\\work\\build\\CMakeFiles\\CMakeTmp\\testFortranCompiler1.f90 > CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90-pp.f90 && D:\\bld\\hdf5_1722438888865\\_build_env\\Library\\bin\\cmake.exe -E cmake_ninja_depends --tdi=CMakeFiles\\cmTC_3969e.dir\\FortranDependInfo.json --lang=Fortran --src=CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90-pp.f90 --out=CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90-pp.f90 --dep=CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90-pp.f90.d --obj=CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90.obj --ddi=CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90.obj.ddi --src-orig=D:\\bld\\hdf5_1722438888865\\work\\build\\CMakeFiles\\CMakeTmp\\testFortranCompiler1.f90"
[2/4] D:\\bld\\hdf5_1722438888865\\_build_env\\Library\\bin\\cmake.exe -E cmake_ninja_dyndep --tdi=CMakeFiles\\cmTC_3969e.dir\\FortranDependInfo.json --lang=Fortran --dd=CMakeFiles\\cmTC_3969e.dir\\Fortran.dd @CMakeFiles\\cmTC_3969e.dir\\Fortran.dd.rsp
[3/4] D:\\bld\\hdf5_1722438888865\\_build_env\\Library\\bin\\flang-new.exe -ID:\\bld\\hdf5_1722438888865\\work\\build\\CMakeFiles\\CMakeTmp -fms-runtime-lib=dll -ffixed-line-length-72 -o CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90.obj -c CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90-pp.f90
[4/4] C:\\Windows\\system32\\cmd.exe /C "cd . && D:\\bld\\hdf5_1722438888865\\_build_env\\Library\\bin\\cmake.exe -E vs_link_exe --intdir=CMakeFiles\\cmTC_3969e.dir --rc=C:\\PROGRA~2\\WI3CF2~1\\10\\bin\\100226~1.0\\x64\\rc.exe --mt="" --manifests -- C:\\PROGRA~1\\MICROS~2\\2022\\ENTERP~1\\VC\\Tools\\MSVC\\1429~1.301\\bin\\HostX64\\x64\\link.exe /nologo CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90.obj /out:cmTC_3969e.exe /implib:cmTC_3969e.lib /pdb:cmTC_3969e.exe.dbg /version:0.0 /machine:x64 -stack:10000000 /INCREMENTAL:NO /subsystem:console ws2_32.lib wsock32.lib shlwapi.lib -libpath:"D:/bld/hdf5_1722438888865/_build_env/Library/lib" -libpath:"D:/bld/hdf5_1722438888865/_build_env/Library/lib/clang/19/lib/windows" && cd ."
FAILED: cmTC_3969e.exe
C:\\Windows\\system32\\cmd.exe /C "cd . && D:\\bld\\hdf5_1722438888865\\_build_env\\Library\\bin\\cmake.exe -E vs_link_exe --intdir=CMakeFiles\\cmTC_3969e.dir --rc=C:\\PROGRA~2\\WI3CF2~1\\10\\bin\\100226~1.0\\x64\\rc.exe --mt="" --manifests -- C:\\PROGRA~1\\MICROS~2\\2022\\ENTERP~1\\VC\\Tools\\MSVC\\1429~1.301\\bin\\HostX64\\x64\\link.exe /nologo CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90.obj /out:cmTC_3969e.exe /implib:cmTC_3969e.lib /pdb:cmTC_3969e.exe.dbg /version:0.0 /machine:x64 -stack:10000000 /INCREMENTAL:NO /subsystem:console ws2_32.lib wsock32.lib shlwapi.lib -libpath:"D:/bld/hdf5_1722438888865/_build_env/Library/lib" -libpath:"D:/bld/hdf5_1722438888865/_build_env/Library/lib/clang/19/lib/windows" && cd ."
LINK: command "C:\\PROGRA~1\\MICROS~2\\2022\\ENTERP~1\\VC\\Tools\\MSVC\\1429~1.301\\bin\\HostX64\\x64\\link.exe /nologo CMakeFiles\\cmTC_3969e.dir\\testFortranCompiler1.f90.obj /out:cmTC_3969e.exe /implib:cmTC_3969e.lib /pdb:cmTC_3969e.exe.dbg /version:0.0 /machine:x64 -stack:10000000 /INCREMENTAL:NO /subsystem:console ws2_32.lib wsock32.lib shlwapi.lib -libpath:D:/bld/hdf5_1722438888865/_build_env/Library/lib -libpath:D:/bld/hdf5_1722438888865/_build_env/Library/lib/clang/19/lib/windows /MANIFEST:EMBED,ID=1" failed (exit code 1104) with the following output:
LINK : fatal error LNK1104: cannot open file 'clang_rt.builtins.lib'\x0d
ninja: build stopped: subcommand failed.
exitCode: 1
runResult:
variable: "RUN_RESULT_VAR"
cached: true After having tried a lot of different variations on how we pass in different flags, we tried simply hardcoding the intended real and integer support by flang just to see how well it fares in compiling hdf5. And by adding the following to
During the compilation stage we initially ran into a failure due to [401/3074] Building C object fortran\src\CMakeFiles\hdf5_f90cstub-shared.dir\H5_f.c.obj
FAILED: fortran/src/CMakeFiles/hdf5_f90cstub-shared.dir/H5_f.c.obj
%BUILD_PREFIX%\Library\bin\clang-cl.exe /nologo -DH5_BUILT_AS_DYNAMIC_LIB -D_BIND_TO_CURRENT_VCLIBS_VERSION=1 -D_CONSOLE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -Dhdf5_f90cstub_shared_EXPORTS -I%SRC_DIR%\src -I%SRC_DIR%\src\H5FDsubfiling -I%SRC_DIR%\build\src -I%SRC_DIR%\build\fortran -I%SRC_DIR%\build\fortran\shared -I%PREFIX%\Library\include -w /DWIN32 /D_WINDOWS /O2 /Ob2 /DNDEBUG -MD -Wall -Warray-bounds -Wcast-qual -Wconversion -Wdouble-promotion -Wextra -Wformat=2 -Wframe-larger-than=16384 -Wimplicit-fallthrough -Wnull-dereference -Wunused-const-variable -Wwrite-strings -Wpedantic -Wvolatile-register-var -Wno-c++-compat /W3 /wd4100 /wd4706 /wd4127 /showIncludes /Fofortran\src\CMakeFiles\hdf5_f90cstub-shared.dir\H5_f.c.obj /Fdfortran\src\CMakeFiles\hdf5_f90cstub-shared.dir\ -c -- %SRC_DIR%\fortran\src\H5_f.c
%SRC_DIR%\fortran\src\H5_f.c(187,16): error: use of undeclared identifier 'real_C_LONG_DOUBLE_f'
187 | if (sizeof(real_C_LONG_DOUBLE_f) == sizeof(float)) {
| ^
%SRC_DIR%\fortran\src\H5_f.c(191,21): error: use of undeclared identifier 'real_C_LONG_DOUBLE_f'
191 | else if (sizeof(real_C_LONG_DOUBLE_f) == sizeof(double)) {
| ^
%SRC_DIR%\fortran\src\H5_f.c(196,21): error: use of undeclared identifier 'real_C_LONG_DOUBLE_f'
196 | else if (sizeof(real_C_LONG_DOUBLE_f) == sizeof(long double)) {
| ^
3 errors generated.
[402/3074] Building C object fortran\src\CMakeFiles\hdf5_f90cstub-shared.dir\H5Af.c.obj
[403/3074] Building C object fortran\src\CMakeFiles\hdf5_f90cstub-shared.dir\H5Df.c.obj
ninja: build stopped: subcommand failed.
To get past the error message we added the following to #ifndef real_C_LONG_DOUBLE_f
#define real_C_LONG_DOUBLE_f long double
#endif The next error (and as of now what seems to be the current blocker) is related to BIND(C) statements.
Which is what I guess is related to flang not yet supporting BIND(C) and the use of passing argument by value like so subroutine mysub(x) bind(c)
integer, value :: x ! x is passed by value, not by reference
end subroutine mysub So as of now, I'll raise the issue over at the llvm-project to see if this (hopefully) is on their radar. |
When attempting to compile HDF5 on windows with fortran enabled using LLVM FLang (v18.1.3 from conda-forge) I get
link to build logs
link to conda-forge PR
However, based on
I had hopes that this could work on Windows given that it seems LLVM flang compiles HDF5 on linux.
Platform (please complete the following information)
HDF5 build config
Let me know if there's anything I can add to help diagnose this issue?
Best Regards
Kristoffer
The text was updated successfully, but these errors were encountered: