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

CMake with "RelWithDebInfo" build type links to debug libraries #332

Open
nickanthony-dgl opened this issue Jun 14, 2023 · 2 comments
Open
Labels
accepted The issue/feature is confirmed and going to be implemented

Comments

@nickanthony-dgl
Copy link

Summary

The MKLConfig.cmake file included with MKL causes debug libraries to be linked when the "RelWithDebInfo" build type is used. This results in linker errors. This happens due to lines like this:

if(WIN32 AND CMAKE_BUILD_TYPE MATCHES "Debug|DebInfo")

Version

I have experienced this on version 2023.0 but looking at the current "Develop" branch it looks like the same behavior should still be present.

Environment

  • TBB 2021.8.0 (installed with vcpkg)
  • Windows 10
  • MSVC 17.6.3

Steps to reproduce

The "Broken-RelWithDebInfo" configuration of this example project reproduces the issue. If you have vcpkg installed and a "VCPKG_ROOT" environment variable set then the project should automatically install TBB. Since MKL has MKL_THREADING set to "tbb_thread" it will link to "mkl_tbb_threadd.lib" which will cause linker errors like this:

...\MSVC-Release\mkl_tbb_threadd.lib(_mdd_tbb_driver.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MD_DynamicRelease' in myProject.cpp.obj
  
...\MSVC-Release\LINK : fatal error LNK1104: cannot open file 'tbb12_debug.lib'

Observed behavior

When "CMAKE_BUILD_TYPE" is "RelWithDebInfo" the MKL CMake config file will cause the "MKL::MKL" target to link with debug libraries. This causes a number of linker errors to appear since the rest of the project will be using release builds.

Expected behavior

When using a build type of "RelWithDebInfo" MKL should behave the same as when the build type is "Release

@hgunalan hgunalan added the accepted The issue/feature is confirmed and going to be implemented label Jun 21, 2023
@nickanthony-dgl
Copy link
Author

I have updated to MKL 2024.0 and while the MKLConfig.cmake file has been moved to oneAPI\mkl\2024.0\lib\cmake\mkl and its contents have been changed this problem is still there. I am able to fix the file for my purposes by replacing all instances of "Debug|DebInfo" with "Debug"

@mkrainiuk
Copy link
Contributor

Hi @nickanthony-dgl thanks for reporting this issue! We've just merged the, it will be available in oneMKL 2024.2 release. Let me know if you need it sooner, we can update the copy of MKLConfig.cmake in this opensource project as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted The issue/feature is confirmed and going to be implemented
Projects
None yet
Development

No branches or pull requests

3 participants