Linker error with IntelLLVM when trying to link a Fortran or CUDA library with `WINDOWS_EXPORT_ALL_SYMBOLS`
When using IntelLLVM compilers (-DCMAKE_CXX_COMPILER=icx-cl -DCMAKE_C_COMPILER=icx-cl
) with ifort
as the Fortran compiler, linking a .dll (consisting of C and Fortran objects) for which WINDOWS_EXPORT_ALL_SYMBOLS
is set to ON
leads to no symbols being exported from that library.
Fwiw, that error occurred with the "Ninja Multi-Config" generator.
Afaict, that is because with IntelLLVM compilers CMAKE_LINK_DEF_FILE_FLAG
is set to /Qoption,link,/DEF:
. However, when linking a Fortran library (with ifort
as the Fortran compiler), it looks like link.exe
is called directly, and flags starting with /Qoption,link,
are ignored. If I edit the impl-Release.ninja
file and manually remove that prefix from the LINK_FLAGS
line of that .dll (leaving only /DEF:...
), linking the .dll succeeds and all symbols are exported.
A similar issue occurs when trying to link a .dll consisting of C and CUDA objects when using the IntelLLVM C/C++ compiler. Again, it looks like link.exe
is getting called directly and flags with that prefix are ignored.
That issue was reported downstream to SuiteSparse: https://github.com/DrTimothyAldenDavis/SuiteSparse/issues/799