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

compiled failed on windows #799

Open
DragonPara opened this issue May 9, 2024 · 9 comments
Open

compiled failed on windows #799

DragonPara opened this issue May 9, 2024 · 9 comments
Assignees

Comments

@DragonPara
Copy link
Contributor

Describe the bug
Can't compile CHOLMOD

To Reproduce
mkdir build
cd build
cmake .. -DCMAKE_CXX_COMPILER=icc -DCMAKE_C_COMPILER=icc -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_INSTALL_PREFIX="E:/umfpackCompilerWork/SuiteSparse7.7" -DSUITESPARSE_ENABLE_PROJECTS="umfpack"
the result of cmake stored in config.log
config.log
msbuild SuiteSparse.sln /p:Configuration=Release > compile.log
the result of build stored in compile.log
compile.log

Expected behavior
normal compilation

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11
  • compiler MSVC
  • intel mkl
  • Version 7.7.0

Additional context
I found -DCMAKE_CXX_COMPILER=icc -DCMAKE_C_COMPILER=icc also not work.

@AuroraLHL
Copy link

I meet this error on Mac,how do you fixed it ?

@mmuetzel
Copy link
Contributor

I tried to reproduce the error with the following steps on Windows 11 23H2 (but it built without error for me):

  • Download and install MSVC 2022 (version 17.9.6)
  • Download and install Intel oneAPI 2024.1
  • Open the "Intel oneAPI command prompt for Intel 64 for Visual Studio 2022" shell with the shortcut in the Windows Start menu.
  • Run the following commands (icc or ifort didn't install for me with the steps described above):
cmake -DCMAKE_CXX_COMPILER=icx-cl -DCMAKE_C_COMPILER=icx-cl -DSUITESPARSE_ENABLE_PROJECTS="umfpack" --fresh ..
cmake --build . --config Release    
ctest . -C Release

Could you please describe the exact steps to reproduce the error that you are seeing?

@DragonPara
Copy link
Contributor Author

I meet this error on Mac,how do you fixed it ?

cmake .. DSUITESPARSE_ENABLE_PROJECTS="umfpack" -DSUITESPARSE_USE_CUDA=OFF -DSUITESPARSE_USE_FORTRAN=OFF
I closed CUDA and Fortran, then it worked well.

@DragonPara
Copy link
Contributor Author

I tried to reproduce the error with the following steps on Windows 11 23H2 (but it built without error for me):

  • Download and install MSVC 2022 (version 17.9.6)
  • Download and install Intel oneAPI 2024.1
  • Open the "Intel oneAPI command prompt for Intel 64 for Visual Studio 2022" shell with the shortcut in the Windows Start menu.
  • Run the following commands (icc or ifort didn't install for me with the steps described above):
cmake -DCMAKE_CXX_COMPILER=icx-cl -DCMAKE_C_COMPILER=icx-cl -DSUITESPARSE_ENABLE_PROJECTS="umfpack" --fresh ..
cmake --build . --config Release    
ctest . -C Release

Could you please describe the exact steps to reproduce the error that you are seeing?

Thx, I compiled by your commands, but it gave me same error results.
tools:

  • cmake version 3.29.3
  • icx-cl Version 2024.0.0 Build 20231017
  • Visual C++ 2022 00482-90000-00000-AA745

If I set SUITESPARSE_USE_FORTRAN=OFF, It will compile successfully. Perhaps it's about Fortran?

@mmuetzel
Copy link
Contributor

IIUC, building fails for you when you are trying to use ifort as the Fortran compiler. The installer that I found for Intel oneAPI 2024.1 didn't give me an option to install ifort.
Could you please give instructions for how to install ifort on Windows?

@mmuetzel
Copy link
Contributor

Found a direct download link for the Intel Fortran compilers:
https://www.intel.com/content/www/us/en/developer/articles/tool/oneapi-standalone-components.html#fortran

That installed ifort:

Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.12.0 Build 20240222_000000
Copyright (C) 1985-2024 Intel Corporation.  All rights reserved.

ifort: remark #10448: Intel(R) Fortran Compiler Classic (ifort) is now deprecated and will be discontinued late 2024. Intel recommends that customers transition now to using the LLVM-based Intel(R) Fortran Compiler (ifx) for continued Windows* and Linux* support, new language support, new language features, and optimizations. Use '/Qdiag-disable:10448' to disable this message.

With it, compilation fails for me (but with a different error than what you were showing). I'm using the following commands to configure and build:

cmake -G"Ninja Multi-Config" -DCMAKE_CXX_COMPILER=icx-cl -DCMAKE_C_COMPILER=icx-cl -DCMAKE_Fortran_COMPILER=ifort -DSUITESPARSE_ENABLE_PROJECTS="umfpack" --fresh ..
cmake --build . --config Release

The error is on linking cholmod.dll:

[630/1250] Linking CUDA shared library CHOLMOD\Release\cholmod.dll
FAILED: CHOLMOD/Release/cholmod.dll CHOLMOD/Release/cholmod.lib
C:\WINDOWS\system32\cmd.exe /C "C:\WINDOWS\system32\cmd.exe /C ""C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E __create_def D:\repo\SuiteSparse\SuiteSparse\build-oneAPI\CHOLMOD\CMakeFiles\CHOLMOD.dir\Release\exports.def D:\repo\SuiteSparse\SuiteSparse\build-oneAPI\CHOLMOD\CMakeFiles\CHOLMOD.dir\Release\exports.def.objs && cd D:\repo\SuiteSparse\SuiteSparse\build-oneAPI" && "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_dll --intdir=CHOLMOD\CMakeFiles\CHOLMOD.dir\Release --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\CHOLMOD.Release.rsp  /out:CHOLMOD\Release\cholmod.dll /implib:CHOLMOD\Release\cholmod.lib /pdb:CHOLMOD\Release\cholmod.pdb /dll /version:5.2 /Qoption,link,/machine:x64 /INCREMENTAL:NO  -Qiopenmp /Qoption,link,/DEF:CHOLMOD\CMakeFiles\CHOLMOD.dir\Release\exports.def -LIBPATH:"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64"  && cd ."
LINK: command "C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1439~1.335\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\CHOLMOD.Release.rsp /out:CHOLMOD\Release\cholmod.dll /implib:CHOLMOD\Release\cholmod.lib /pdb:CHOLMOD\Release\cholmod.pdb /dll /version:5.2 /Qoption,link,/machine:x64 /INCREMENTAL:NO -Qiopenmp /Qoption,link,/DEF:CHOLMOD\CMakeFiles\CHOLMOD.dir\Release\exports.def -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.3/lib/x64 /MANIFEST:EMBED,ID=2" failed (exit code 1181) with the following output:
LINK : warning LNK4044: unrecognized option '/Qoption,link,/machine:x64'; ignored
LINK : warning LNK4044: unrecognized option '/Qiopenmp'; ignored
LINK : warning LNK4044: unrecognized option '/Qoption,link,/DEF:CHOLMOD\CMakeFiles\CHOLMOD.dir\Release\exports.def'; ignored
LINK : fatal error LNK1181: cannot open input file 'AMD\Release\amd.lib'

And there is indeed no amd.lib (just amd.dll and amd_static.lib). It looks like that amd.dll doesn't export any symbols...

It correctly exports the symbols from amd.dll using the (modern, LLVM-based) Intel Fortran compiler ifx:

cmake -DCMAKE_CXX_COMPILER=icx-cl -DCMAKE_C_COMPILER=icx-cl -DCMAKE_Fortran_COMPILER=ifx -DSUITESPARSE_ENABLE_PROJECTS="umfpack" --fresh ..
cmake --build . --config Release

However, using ifx still fails a bit later on when linking the CHOLMOD demos. That seems to be caused by cholmod.dll exporting only one single symbol:

>dumpbin /EXPORTS CHOLMOD\Release\cholmod.dll
Microsoft (R) COFF/PE Dumper Version 14.39.33523.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file CHOLMOD\Release\cholmod.dll

File Type: DLL

  Section contains the following exports for cholmod.dll

    00000000 characteristics
    FFFFFFFF time date stamp
        0.00 version
           1 ordinal base
           1 number of functions
           1 number of names

    ordinal hint RVA      name

          1    0 0003FCEC NvOptimusEnablementCuda

  Summary

        9000 .data
        1000 .nvFatBi
        9000 .nv_fatb
        1000 .pdata
       1D000 .rdata
        2000 .reloc
        1000 .rsrc
       1D000 .text
        2000 _RDATA
        1000 __nv_mod
        4000 __nv_rel

Afaict, that is because /Qoption,link,/DEF:CHOLMOD\CMakeFiles\CHOLMOD.dir\Release\exports.def is used in the LINK_FLAGS when linking cholmod.dll as a CUDA library. That should be /DEF:CHOLMOD\CMakeFiles\CHOLMOD.dir\Release\exports.def instead (without the prefix /Qoption,link,).

The same issue with amd.dll and ifort. When linking as a Fortran library with ifort, the LINK_FLAGS shouldn't contain /Qoption,link,/DEF:AMD\CMakeFiles\AMD.dir\Release\exports.def. It should be /DEF:AMD\CMakeFiles\AMD.dir\Release\exports.def instead when using the (non LLVM-based) ifort (which leads to CMake calling link.exe directly like for the CUDA library).

That looks like a CMake issue to me. There is probably nothing that SuiteSparse can do about it.

Disabling CUDA leads to cholmod.dll being linked as a C library. That can be used to work around the issue until this is fixed in CMake.
Similarly, disabling Fortran leads to amd.dll being linked as a C library. That (or using the LLVM-based ifx) can be used to work around the issue with the empty amd.dll.

I didn't find an open ticket for either issue on https://gitlab.kitware.com/cmake/cmake/-/issues.

@mmuetzel
Copy link
Contributor

I opened an issue for CMake: https://gitlab.kitware.com/cmake/cmake/-/issues/26005

@DragonPara
Copy link
Contributor Author

I also found Fortran Source file would not be compiled to .obj file. Looks like Fortran Source file is ignored.

@mmuetzel
Copy link
Contributor

I also found Fortran Source file would not be compiled to .obj file. Looks like Fortran Source file is ignored.

I cannot reproduce that. Using the "Ninja Multi-Config" generator, I find, e.g., AMD\CMakeFiles\AMD.dir\Release\Source\amd.f.obj in the build directory.

The Fortran sources are obviously not built if you configured with -DSUITESPARSE_USE_FORTRAN=OFF or if CMake doesn't detect any working Fortran compiler. In these cases, you won't find object files that would be built from Fortran sources.

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

4 participants