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

Explicitly select linker for some mixed language libraries. #853

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

mmuetzel
Copy link
Contributor

@mmuetzel mmuetzel commented Jul 11, 2024

If no linker preference is set for a shared library, CMake is choosing the executable that is used for linking based on the highest linker preference value. If a library consists of C and Fortran sources, the Fortran compiler frontend has the higher linker preference value and it is chosen by default.

For the Intel oneAPI compiler with MSVC-like syntax icx-cl as the C and C++ compiler and the Intel oneAPI Fortran compilers ifort or ifx, this leads to the following situation in combination with WINDOWS_EXPORT_ALL_SYMBOLS:

  • The symbols that are to be exported from the library are collected from the C objects and written to a .def file.
  • Flags are generated that pass that .def file to the linker. However, the syntax for these flags match the C compiler icx-cl.
  • The Fortran compiler is used for linking (higher linker preference value). But .def files need to be passed differently for ifx or ifort than for icx-cl.

That leads to the linked libraries being empty or only exporting the Fortran symbols.

This is probably an issue that should be fixed in CMake. (However, that doesn't seem to be solvable easily.)
To work around the issue, explicitly specify to use the C compiler frontend as the linker for the AMD and CHOLMOD libraries.

Fixes #799.

If no linker preference is set for a shared library, CMake is choosing
the executable that is used for linking based on the highest linker
preference value. If a library consists of C and Fortran sources, the
Fortran compiler frontend has the higher linker preference value and it
is chosen by default.

For the Intel oneAPI compiler with MSVC-like syntax `icx-cl` as
the C and C++ compiler and the Intel oneAPI Fortran compilers `ifort`
or `ifx`, this leads to the following situation in combination with
`WINDOWS_EXPORT_ALL_SYMBOLS`:
* The symbols that are to be exported from the library are collected from
the C objects and written to a `.def` file.
* Flags are generated that pass that `.def` file to the linker. However,
the syntax for these flags match the C compiler `icx-cl`.
* The Fortran compiler is used for linking (higher linker preference
value). But `.def` files need to be passed differently for `ifx` or
`ifort` than for `icx-cl`.
* That leads to the linked libraries being empty or only exporting the
Fortran symbols.

Explicitly specify to use the C compiler frontend as the linker for the
AMD and CHOLMOD libraries to work around that issue.

Fixes DrTimothyAldenDavis#799.
@DrTimothyAldenDavis DrTimothyAldenDavis merged commit ae3cce8 into DrTimothyAldenDavis:dev2 Aug 1, 2024
27 checks passed
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

Successfully merging this pull request may close these issues.

2 participants