ornladios / ADIOS2

Next generation of ADIOS developed in the Exascale Computing Program
https://adios2.readthedocs.io/en/latest/index.html
Apache License 2.0
268 stars 125 forks source link

2.10.0-RC1: Windows libffi linker issue #4019

Closed ax3l closed 1 month ago

ax3l commented 7 months ago

Describe the bug I am still trying to compile ADIOS2 with C-Blosc2 on Windows in https://github.com/openPMD/openPMD-api/pull/1554. I now try to use ADIOS 2.10.0-rc1.

This does not link on windows with libffi issues.

To Reproduce I am doing an all-static build.

  curl -sLo adios2-2.10.0-rc1.zip ^
    https://github.com/ornladios/ADIOS2/archive/refs/tags/v2.10.0-rc1.zip
  powershell Expand-Archive adios2-2.10.0-rc1.zip -DestinationPath dep-adios2

  cmake -S dep-adios2/ADIOS2-2.10.0-rc1 -B build-adios2 ^
    -DCMAKE_BUILD_TYPE=Release  ^
    -DBUILD_SHARED_LIBS=OFF     ^
    -DBUILD_TESTING=OFF         ^
    -DADIOS2_USE_MPI=OFF        ^
    -DADIOS2_BUILD_EXAMPLES=OFF ^
    -DADIOS2_Blosc2_PREFER_SHARED=OFF ^
    -DADIOS2_USE_Blosc2=ON      ^
    -DADIOS2_USE_BZip2=OFF      ^
    -DADIOS2_USE_Fortran=OFF    ^
    -DADIOS2_USE_HDF5=OFF       ^
    -DADIOS2_USE_MHS=OFF        ^
    -DADIOS2_USE_PNG=OFF        ^
    -DADIOS2_USE_Profiling=OFF  ^
    -DADIOS2_USE_Python=OFF     ^
    -DADIOS2_USE_ZeroMQ=OFF     ^
    -DADIOS2_USE_ZFP=ON         ^
    -DADIOS2_RUN_INSTALL_TEST=OFF

  cmake --build build-adios2 --parallel 2

  cmake --build build-adios2 --target install --config Release

See CI of https://github.com/openPMD/openPMD-api/pull/1554, logs here: adios2-2.10.0-rc1_libffi-link-issue.txt

2024-01-30T18:43:37.2016284Z   adios2_c_variable.cpp
2024-01-30T18:43:37.4167988Z LINK : fatal error LNK1104: cannot open file 'ffi.lib' [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T18:43:37.4954992Z   main.cpp
2024-01-30T18:43:38.2227279Z   Reorganize.cpp
2024-01-30T18:43:38.2323129Z   adios2_c_attribute.cpp
2024-01-30T18:43:38.5659633Z   IO.cpp
2024-01-30T18:43:39.1746622Z   adios2_c_operator.cpp
2024-01-30T18:43:39.4554626Z   Utils.cpp
2024-01-30T18:43:39.6007589Z   Operator.cpp
2024-01-30T18:43:39.9410487Z   Generating Code...
2024-01-30T18:43:40.0518750Z   Generating Code...
2024-01-30T18:43:40.3069063Z LINK : fatal error LNK1104: cannot open file 'ffi.lib' [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]

cc @eisenhauer ?

ax3l commented 7 months ago

Will try -DCMAKE_DISABLE_FIND_PACKAGE_LibFFI=TRUE.

eisenhauer commented 7 months ago

We probably need to see more of the CMake output, particularly the FFS part. It doesn't try to use FFI unless it finds it, but clearly it hasn't really found it.

ax3l commented 7 months ago

@eisenhauer , can you see the linked log file? I downloaded it from CI for full CMake details.

eisenhauer commented 7 months ago

@eisenhauer , can you see the linked log file? I downloaded it from CI for full CMake details.

Sorry, missed that... Looking now.

ax3l commented 7 months ago

I disabled libFFI, but there are other linker issues with FFS left: adios2_more_link_errors.txt

...
2024-01-30T19:11:17.0360224Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FMdump_data referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0551977Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_create_FFSContext_FM referenced in function "public: __cdecl adios2::format::BP5Deserializer::BP5Deserializer(bool,bool,bool)" (??0BP5Deserializer@format@adios2@@QEAA@_N00@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0557986Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_create_fixed_FFSBuffer referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallAttributeData(void *,unsigned __int64,unsigned __int64)" (?InstallAttributeData@BP5Deserializer@format@adios2@@QEAAXPEAX_K1@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0564369Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSdecode_in_place_possible referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0571198Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSTypeHandle_from_encode referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0577483Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_establish_conversion referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0583490Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFShas_conversion referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0589548Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFS_est_decode_length referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0595598Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSdecode_in_place referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0601615Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSdecode_to_buffer referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0607620Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FMFormat_of_original referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0613895Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FMContext_from_FFS referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaMetaData(struct adios2::format::BP5Base::MetaMetaInfoBlock &)" (?InstallMetaMetaData@BP5Deserializer@format@adios2@@QEAAXAEAUMetaMetaInfoBlock@BP5Base@23@@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0619824Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_free_FFSContext referenced in function "public: __cdecl adios2::format::BP5Deserializer::~BP5Deserializer(void)" (??1BP5Deserializer@format@adios2@@QEAA@XZ) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0625332Z adios2_core.lib(BP5Serializer.obj) : error LNK2019: unresolved external symbol __imp_create_FFSBuffer referenced in function "public: struct adios2::format::BP5Serializer::TimestepInfo __cdecl adios2::format::BP5Serializer::CloseTimestep(int,bool)" (?CloseTimestep@BP5Serializer@format@adios2@@QEAA?AUTimestepInfo@123@H_N@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0631522Z adios2_core.lib(BP5Serializer.obj) : error LNK2019: unresolved external symbol __imp_FFSencode referenced in function "public: struct adios2::format::BP5Serializer::TimestepInfo __cdecl adios2::format::BP5Serializer::CloseTimestep(int,bool)" (?CloseTimestep@BP5Serializer@format@adios2@@QEAA?AUTimestepInfo@123@H_N@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.0636804Z adios2_core.lib(BufferFFS.obj) : error LNK2019: unresolved external symbol __imp_free_FFSBuffer referenced in function "public: virtual __cdecl adios2::format::BufferFFS::~BufferFFS(void)" (??1BufferFFS@format@adios2@@UEAA@XZ) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
2024-01-30T19:11:17.1809351Z D:\a\openPMD-api\openPMD-api\src\build-adios2\bin\Debug\bpls.exe : fatal error LNK1120: 16 unresolved externals [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\bpls.vcxproj]
eisenhauer commented 7 months ago

Odd. From the looks of it things are going wrong with the MSVC linker import, but this stuff works fine in ADIOS CI with MSVC 19. I don't have a great first guess at the moment, but I'm wondering if the problem with FFI might be related. We're probably going to have to go through and compare the ADIOS CI logs for MSVC to see where things might have gone differently.

Actually, I can't look at the moment, but one possible thing. I suspect that we're not disabling DLLs in MSVC CI. Do you need a static build? (That might explain both things. If the FFI module contained only a dynamic library, the static version might not be found, and things might be going wrong on the linker end with ADIOS as it's being used.)

ax3l commented 7 months ago

Yes, I need an all static build.

ax3l commented 6 months ago

When turning off libFFI, I get issues statically with building ADIOS2 of the form:

2024-01-30T19:11:20.6613858Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FMdump_data referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6810980Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_create_FFSContext_FM referenced in function "public: __cdecl adios2::format::BP5Deserializer::BP5Deserializer(bool,bool,bool)" (??0BP5Deserializer@format@adios2@@QEAA@_N00@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6818372Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_create_fixed_FFSBuffer referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallAttributeData(void *,unsigned __int64,unsigned __int64)" (?InstallAttributeData@BP5Deserializer@format@adios2@@QEAAXPEAX_K1@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6825559Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSdecode_in_place_possible referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6831767Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSTypeHandle_from_encode referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6837864Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_establish_conversion referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6843948Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFShas_conversion referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6850163Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFS_est_decode_length referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6857539Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSdecode_in_place referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6863542Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FFSdecode_to_buffer referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6869302Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FMFormat_of_original referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaData(void *,unsigned __int64,unsigned __int64,unsigned __int64)" (?InstallMetaData@BP5Deserializer@format@adios2@@QEAAXPEAX_K11@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6876500Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_FMContext_from_FFS referenced in function "public: void __cdecl adios2::format::BP5Deserializer::InstallMetaMetaData(struct adios2::format::BP5Base::MetaMetaInfoBlock &)" (?InstallMetaMetaData@BP5Deserializer@format@adios2@@QEAAXAEAUMetaMetaInfoBlock@BP5Base@23@@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6880270Z adios2_core.lib(BP5Deserializer.obj) : error LNK2019: unresolved external symbol __imp_free_FFSContext referenced in function "public: __cdecl adios2::format::BP5Deserializer::~BP5Deserializer(void)" (??1BP5Deserializer@format@adios2@@QEAA@XZ) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6883316Z adios2_core.lib(BP5Serializer.obj) : error LNK2019: unresolved external symbol __imp_create_FFSBuffer referenced in function "public: struct adios2::format::BP5Serializer::TimestepInfo __cdecl adios2::format::BP5Serializer::CloseTimestep(int,bool)" (?CloseTimestep@BP5Serializer@format@adios2@@QEAA?AUTimestepInfo@123@H_N@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6886617Z adios2_core.lib(BP5Serializer.obj) : error LNK2019: unresolved external symbol __imp_FFSencode referenced in function "public: struct adios2::format::BP5Serializer::TimestepInfo __cdecl adios2::format::BP5Serializer::CloseTimestep(int,bool)" (?CloseTimestep@BP5Serializer@format@adios2@@QEAA?AUTimestepInfo@123@H_N@Z) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6889497Z adios2_core.lib(BufferFFS.obj) : error LNK2019: unresolved external symbol __imp_free_FFSBuffer referenced in function "public: virtual __cdecl adios2::format::BufferFFS::~BufferFFS(void)" (??1BufferFFS@format@adios2@@UEAA@XZ) [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.6891697Z D:\a\openPMD-api\openPMD-api\src\build-adios2\bin\Debug\adios2_reorganize.exe : fatal error LNK1120: 16 unresolved externals [D:\a\openPMD-api\openPMD-api\src\build-adios2\source\utils\adios_reorganize.vcxproj]
2024-01-30T19:11:20.8561606Z   Variable.cpp

full log: adios2_link_ffs.txt

eisenhauer commented 6 months ago

It appears that the thirdparty packages we need for BP5 have not been setup to compile statically on Windows. The errors above I think are the result of having the declspec(dllimport) turn on those symbols unconditionally. (Those declspecs are leftover from a non-CMake build system, and while a lot of work was put in to make those libraries build and install statically and dynamically on non-windows systems, the windows work only included dynamic builds.). I've been doing some digging looking for a package that might do this the "right" way in CMake, but haven't had luck so far. I believe that one needs to employ the GENERATE_EXPORT_HEADER cmake command, but that's my only lead at this point.

ax3l commented 6 months ago

Yes, WINDOWS_EXPORT_ALL_SYMBOLS ON for CMake will work as well - will make symbols default visible as they are on Linux.

eisenhauer commented 6 months ago

WINDOWS_EXPORT_ALL_SYMBOLS is done in the thirdparty libs, but it doesn't handle the declspec()s in the headers. I've tried just turning those off for the static build, but whatever the fix is, it seems to require more than that.

franzpoeschel commented 6 months ago

@ax3l @eisenhauer I think I found the problem and it looks like it could be a CMake bug. I was able to reproduce the same issue with CMake 3.23 on Windows (install Blosc2 and ADIOS2 statically --> try configuring openPMD-api with these dependencies). I checked the CMake scripts and they looked fine, so instead I upgraded to CMake 3.28, and that seems to work now.

eisenhauer commented 6 months ago

Well, that's potentially good news. @vicentebolea Plausible?

franzpoeschel commented 6 months ago

What convinced me of a CMake bug was that the target was not found even if a added a FindPackage(BLOSC2 REQUIRED) directly one line before that

franzpoeschel commented 6 months ago

I responded to the wrong issue, this addresses the issue reported in #3903. Might still be worth checking if it's the same cause for this one.

vicentebolea commented 1 month ago

I believe that this was resolved with the 2.10.1 release. Please re-open if this is still an issue