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

Compiling with LLVM Flang on windows -> missing intrinsic functions SIZEOF or STORAGE_SIZE #4419

Open
Krande opened this issue Apr 18, 2024 · 10 comments
Assignees
Labels
Component - Fortran Fortran wrappers Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Improvement Improvements that don't add a new feature or functionality

Comments

@Krande
Copy link

Krande commented Apr 18, 2024

When attempting to compile HDF5 on windows with fortran enabled using LLVM FLang (v18.1.3 from conda-forge) I get

-- The Fortran compiler identification is LLVMFlang 18.1.3
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: D:/bld/hdf5_1713270629406/_build_env/Library/bin/flang-new.exe - skipped
-- Detecting Fortran/C Interface
-- Detecting Fortran/C Interface - Found GLOBAL and MODULE mangling
-- Verifying Fortran/C Compiler Compatibility
-- Verifying Fortran/C Compiler Compatibility - Success
-- Performing Test H5_FORTRAN_HAVE_SIZEOF
-- Performing Test H5_FORTRAN_HAVE_SIZEOF - Failed
-- Performing Test H5_FORTRAN_HAVE_C_SIZEOF
-- Performing Test H5_FORTRAN_HAVE_C_SIZEOF - Failed
-- Performing Test H5_FORTRAN_HAVE_STORAGE_SIZE
-- Performing Test H5_FORTRAN_HAVE_STORAGE_SIZE - Failed
-- Performing Test H5_FORTRAN_HAVE_ISO_C_BINDING
-- Performing Test H5_FORTRAN_HAVE_ISO_C_BINDING - Failed
-- Performing Test FORTRAN_HAVE_C_LONG_DOUBLE
-- Performing Test FORTRAN_HAVE_C_LONG_DOUBLE - Failed
-- Performing Test FORTRAN_C_LONG_DOUBLE_IS_UNIQUE
-- Performing Test FORTRAN_C_LONG_DOUBLE_IS_UNIQUE - Failed
-- Performing Test FORTRAN_C_BOOL_IS_UNIQUE
-- Performing Test FORTRAN_C_BOOL_IS_UNIQUE - Failed
-- Performing Test HAVE_ISO_FORTRAN_ENV
-- Performing Test HAVE_ISO_FORTRAN_ENV - Failed
CMake Error at config/cmake/HDF5UseFortran.cmake:128 (message):
  Fortran compiler requires either intrinsic functions SIZEOF or STORAGE_SIZE
Call Stack (most recent call first):
  CMakeLists.txt:1076 (include)

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 versions v1.14.4.2 and v1.14.3 (both versions results in same error)
  • Windows 11
  • cl (MSVC 14.38) and Flang 18.1.3 (from conda-forge)
  • CMake=3.29.2
  • See HDF5 build config below
  • Not using mpi

HDF5 build config

mkdir build
cd build

:: Set environment variables.
set HDF5_EXT_ZLIB=zlib.lib

set "CXXFLAGS=%CXXFLAGS% -LTCG"
set FC=flang-new

:: Configure step.
cmake -G "Ninja" ^
      -D CMAKE_BUILD_TYPE:STRING=RELEASE ^
      -D CMAKE_PREFIX_PATH:PATH=%LIBRARY_PREFIX% ^
      -D CMAKE_INSTALL_PREFIX:PATH=%LIBRARY_PREFIX% ^
      -D HDF5_BUILD_CPP_LIB:BOOL=ON ^
      -D CMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON ^
      -D BUILD_SHARED_LIBS:BOOL=ON ^
      -D BUILD_STATIC_LIBS:BOOL=OFF ^
      -D ONLY_SHARED_LIBS:BOOL=ON ^
      -D HDF5_BUILD_HL_LIB:BOOL=ON ^
      -D HDF5_BUILD_TOOLS:BOOL=ON ^
      -D HDF5_BUILD_FORTRAN:BOOL=ON ^
      -D HDF5_BUILD_HL_GIF_TOOLS:BOOL=ON ^
      -D HDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON ^
      -D HDF5_ENABLE_THREADSAFE:BOOL=ON ^
      -D HDF5_ENABLE_ROS3_VFD:BOOL=ON ^
      -D HDF5_ENABLE_SZIP_SUPPORT=ON ^
      -D ALLOW_UNSUPPORTED:BOOL=ON ^
      %SRC_DIR%
if errorlevel 1 exit 1

:: Build C libraries and tools.
ninja
if errorlevel 1 exit 1

:: Install step.
ninja install
if errorlevel 1 exit 1

Let me know if there's anything I can add to help diagnose this issue?

Best Regards
Kristoffer

@Krande
Copy link
Author

Krande commented Apr 18, 2024

On closer inspection of the CMakeConfigureLog.yaml I see that flang fails with the following errors

[1/4] C:\\Windows\\system32\\cmd.exe /C "C:\\Work\\miniforge3\\envs\\msvc-flang\\Library\\bin\\flang-new.exe -cpp -DH5_FORTRAN_HAVE_ISO_C_BINDING -D__STDC_WANT_IEC_60559_TYPES_EXT__  /DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1 -fms-runtime-lib=dll -E C:\\Work\\code\\hdf5\\build\\msvc-flang\\CMakeFiles\\CMakeScratch\\TryCompile-qc2t2u\\src.f90 > CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90 && C:\\Work\\miniforge3\\envs\\msvc-flang\\Library\\bin\\cmake.exe -E cmake_ninja_depends --tdi=CMakeFiles\\cmTC_d646e.dir\\FortranDependInfo.json --lang=Fortran --src=CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90 --out=CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90 --dep=CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90.d --obj=CMakeFiles\\cmTC_d646e.dir\\src.f90.obj --ddi=CMakeFiles\\cmTC_d646e.dir\\src.f90.obj.ddi --src-orig=C:\\Work\\code\\hdf5\\build\\msvc-flang\\CMakeFiles\\CMakeScratch\\TryCompile-qc2t2u\\src.f90"
        FAILED: CMakeFiles/cmTC_d646e.dir/src.f90-pp.f90 CMakeFiles/cmTC_d646e.dir/src.f90.obj.ddi 
        C:\\Windows\\system32\\cmd.exe /C "C:\\Work\\miniforge3\\envs\\msvc-flang\\Library\\bin\\flang-new.exe -cpp -DH5_FORTRAN_HAVE_ISO_C_BINDING -D__STDC_WANT_IEC_60559_TYPES_EXT__  /DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1 -fms-runtime-lib=dll -E C:\\Work\\code\\hdf5\\build\\msvc-flang\\CMakeFiles\\CMakeScratch\\TryCompile-qc2t2u\\src.f90 > CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90 && C:\\Work\\miniforge3\\envs\\msvc-flang\\Library\\bin\\cmake.exe -E cmake_ninja_depends --tdi=CMakeFiles\\cmTC_d646e.dir\\FortranDependInfo.json --lang=Fortran --src=CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90 --out=CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90 --dep=CMakeFiles\\cmTC_d646e.dir\\src.f90-pp.f90.d --obj=CMakeFiles\\cmTC_d646e.dir\\src.f90.obj --ddi=CMakeFiles\\cmTC_d646e.dir\\src.f90.obj.ddi --src-orig=C:\\Work\\code\\hdf5\\build\\msvc-flang\\CMakeFiles\\CMakeScratch\\TryCompile-qc2t2u\\src.f90"
        flang-new: error: no such file or directory: '/DWIN32_LEAN_AND_MEAN=1'\x0d
        flang-new: error: no such file or directory: '/DNOGDI=1'\x0d
        ninja: build stopped: subcommand failed.

This seems to be a CMake config issue.

So I tried the following modification

    if (CMAKE_Fortran_COMPILER MATCHES "flang")
      set (CMAKE_REQUIRED_FLAGS "-DWIN32_LEAN_AND_MEAN=1 -DNOGDI=1")
    else ()
      set (CMAKE_REQUIRED_FLAGS "/DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1")
    endif ()

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)

-- The Fortran compiler identification is LLVMFlang 18.1.3
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: C:/Work/miniforge3/envs/msvc-flang/Library/bin/flang-new.exe - skipped
-- Detecting Fortran/C Interface
-- Detecting Fortran/C Interface - Found GLOBAL and MODULE mangling
-- Verifying Fortran/C Compiler Compatibility
-- Verifying Fortran/C Compiler Compatibility - Success
-- Performing Test H5_FORTRAN_HAVE_SIZEOF
-- Performing Test H5_FORTRAN_HAVE_SIZEOF - Success
-- Performing Test H5_FORTRAN_HAVE_C_SIZEOF
-- Performing Test H5_FORTRAN_HAVE_C_SIZEOF - Success
-- Performing Test H5_FORTRAN_HAVE_STORAGE_SIZE
-- Performing Test H5_FORTRAN_HAVE_STORAGE_SIZE - Success
-- Performing Test H5_FORTRAN_HAVE_ISO_C_BINDING
-- Performing Test H5_FORTRAN_HAVE_ISO_C_BINDING - Success
-- Performing Test FORTRAN_HAVE_C_LONG_DOUBLE
-- Performing Test FORTRAN_HAVE_C_LONG_DOUBLE - Success
-- Performing Test FORTRAN_C_LONG_DOUBLE_IS_UNIQUE
-- Performing Test FORTRAN_C_LONG_DOUBLE_IS_UNIQUE - Success
-- Performing Test FORTRAN_C_BOOL_IS_UNIQUE
-- Performing Test FORTRAN_C_BOOL_IS_UNIQUE - Success
-- Performing Test HAVE_ISO_FORTRAN_ENV
-- Performing Test HAVE_ISO_FORTRAN_ENV - Success
-- Performing Test FORTRAN_CHAR_ALLOC
-- Performing Test FORTRAN_CHAR_ALLOC - Success
CMake Error at config/cmake/HDF5UseFortran.cmake:171 (list):
  list index: 2 out of range (-2, 1)
Call Stack (most recent call first):
  CMakeLists.txt:1076 (include)


CMake Error at config/cmake/HDF5UseFortran.cmake:178 (message):
  Failed to find available REAL KINDs for Fortran
Call Stack (most recent call first):
  CMakeLists.txt:1076 (include)


-- Configuring incomplete, errors occurred!

When examining the CMakeConfigureLog.yaml

LINK: command "C:\\PROGRA~2\\MICROS~3\\2022\\BUILDT~1\\VC\\Tools\\MSVC\\1438~1.331\\bin\\Hostx64\\x64\\link.exe /nologo CMakeFiles\\cmTC_6dccc.dir\\testFortranCompiler1.f90.obj /out:cmTC_6dccc.exe /implib:cmTC_6dccc.lib /pdb:cmTC_6dccc.exe.dbg /version:0.0 /machine:x64 -stack:10000000 /INCREMENTAL:NO /subsystem:console ws2_32.lib wsock32.lib shlwapi.lib -libpath:C:/Work/miniforge3/envs/msvc-flang/Library/lib -libpath:C:/Work/miniforge3/envs/msvc-flang/Library/lib/clang/18/lib/windows /MANIFEST:EMBED,ID=1" failed (exit code 1120) with the following output:
        testFortranCompiler1.f90.obj : error LNK2019: unresolved external symbol _QMiso_fortran_envECinteger_kinds referenced in function _QQmain
        testFortranCompiler1.f90.obj : error LNK2019: unresolved external symbol _QMiso_fortran_envECreal_kinds referenced in function _QQmain\x0d
        testFortranCompiler1.f90.obj : error LNK2019: unresolved external symbol _QMiso_fortran_envEClogical_kinds referenced in function _QQmain\x0d
        cmTC_6dccc.exe : fatal error LNK1120: 3 unresolved externals\x0d
        ninja: build stopped: subcommand faile

@hyoklee
Copy link
Member

hyoklee commented Apr 18, 2024

Hi, @Krande !

Thank you for your report.
Unfortunately, it's a known issue:

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!

@mjklemm
Copy link

mjklemm commented Apr 18, 2024

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.

@Krande
Copy link
Author

Krande commented Apr 18, 2024

@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.

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.

Was this on windows or linux?

@mjklemm
Copy link

mjklemm commented Apr 18, 2024

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.

Was this on windows or linux?

That was on Linux and the intrinsic in question was SPACING for REAL, kind=2,3,16.

@fortnern
Copy link
Member

This is a problem with the compiler, but we'll leave this issue open until the compiler is fixed.

@hyoklee
Copy link
Member

hyoklee commented Apr 18, 2024

@mjklemm , I see failure on mac: https://github.com/hyoklee/hdf5/blob/develop/WATCHME.md#compilers

@mjklemm
Copy link

mjklemm commented Apr 18, 2024

I was able to confirm the problem also for Linux. I'm working on a fix.

@mjklemm
Copy link

mjklemm commented Apr 19, 2024

This is the issue at LLVM llvm/llvm-project#89403 that tracks the issue with integer_kinds et al.

@Krande
Copy link
Author

Krande commented Oct 29, 2024

Hey, just to provide an update to this. I can confirm that the original reported error is fixed with the work by @mjklemm.
(see conda-forge/hdf5-feedstock#217 for more information about what we've tried wrt. flang support).

The original error which is fixed

LINK: command "C:\\PROGRA~2\\MICROS~3\\2022\\BUILDT~1\\VC\\Tools\\MSVC\\1438~1.331\\bin\\Hostx64\\x64\\link.exe /nologo CMakeFiles\\cmTC_6dccc.dir\\testFortranCompiler1.f90.obj /out:cmTC_6dccc.exe /implib:cmTC_6dccc.lib /pdb:cmTC_6dccc.exe.dbg /version:0.0 /machine:x64 -stack:10000000 /INCREMENTAL:NO /subsystem:console ws2_32.lib wsock32.lib shlwapi.lib -libpath:C:/Work/miniforge3/envs/msvc-flang/Library/lib -libpath:C:/Work/miniforge3/envs/msvc-flang/Library/lib/clang/18/lib/windows /MANIFEST:EMBED,ID=1" failed (exit code 1120) with the following output:
        testFortranCompiler1.f90.obj : error LNK2019: unresolved external symbol _QMiso_fortran_envECinteger_kinds referenced in function _QQmain
        testFortranCompiler1.f90.obj : error LNK2019: unresolved external symbol _QMiso_fortran_envECreal_kinds referenced in function _QQmain\x0d
        testFortranCompiler1.f90.obj : error LNK2019: unresolved external symbol _QMiso_fortran_envEClogical_kinds referenced in function _QQmain\x0d
        cmTC_6dccc.exe : fatal error LNK1120: 3 unresolved externals\x0d
        ninja: build stopped: subcommand faile

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 config/cmake/HDF5UseFortran.cmake we successfully completed the configuration step, and got to the compilation stage.

if (CMAKE_Fortran_COMPILER MATCHES "flang")
    message(STATUS "PROG_OUTPUT=${PROG_OUTPUT}. Force override with \"1,4,8;4,8,16;33;3;3;4;1,4,8;\"")
    set(PROG_OUTPUT "1,4,8;4,8,16;33;3;3;4;1,4,8;")
else ()
    # Convert the string to a list of strings by replacing the carriage return with a semicolon
    string (REGEX REPLACE "[\r\n]+" ";" PROG_OUTPUT "${PROG_OUTPUT}")
endif ()

During the compilation stage we initially ran into a failure due to error: use of undeclared identifier 'real_C_LONG_DOUBLE_f'.

[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.

from https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=1065872&view=logs&j=0ad3a718-cdde-5a77-9020-8beac94f6974&t=eda7a7f8-f584-55f5-338d-6077df40dfcc&l=2005

To get past the error message we added the following to H5f90.h which seems to do the trick.

#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.

C:\bld\flang-split_1725521580766\work\flang\lib\Optimizer\CodeGen\Target.cpp:102: not yet implemented: passing VALUE BIND(C) derived type for this target
LLVM ERROR: aborting

from https://dev.azure.com/conda-forge/feedstock-builds/_build/results?buildId=1065902&view=logs&j=0ad3a718-cdde-5a77-9020-8beac94f6974&t=eda7a7f8-f584-55f5-338d-6077df40dfcc&l=2058

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Fortran Fortran wrappers Priority - 2. Medium ⏹ It would be nice to have this in the next release Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

No branches or pull requests

6 participants