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

Why override for static runtime library with MSVC? #200

Closed
fzimmermann89 opened this issue Oct 12, 2017 · 5 comments
Closed

Why override for static runtime library with MSVC? #200

fzimmermann89 opened this issue Oct 12, 2017 · 5 comments

Comments

@fzimmermann89
Copy link

Hey,
I am trying to get arrayfire to compile using clBLast and stumbled upon linker errors because clblast is compiled with a static runtime library (MT) and arrayfire with a dynamic runtime (MD)
What is the reasoning for the override of the CXX flags?
Did you test this change with your build_clblast.cmake over at arrayfire?
Do you know how I can "override the override"? ;)

@CNugteren
Copy link
Owner

Sorry, I'm not too familiar with building for Windows, so I'm not 100% sure what you mean. I also don't know what this build_clblast.cmake is that you refer to? But note that there is a CMake option in CLBlast named BUILD_SHARED_LIBS. Default is ON, but perhaps you've set it to OFF?

@fzimmermann89
Copy link
Author

fzimmermann89 commented Oct 13, 2017

I was refering to https://github.com/arrayfire/arrayfire/blame/master/CMakeModules/build_CLBlast.cmake

The problem is caused by dynamic vs. static linking of the MSVC runtime. This behavior is not affected by BUILD_SHARED_LIBS but by the added "/MT" in https://github.com/CNugteren/CLBlast/blob/master/cmake/cxx_flag_overrides.cmake.

The problem is if one is static linking against ClBlast from e.g. arrayfire, both have to use the same type of runtime-linking (either MT or MD). Arrayfire is currently using MD/dynamic linking so one has to do same ugly overwriting of the overwritten CXX_Flags like

string(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" cxx_flags_name)
[...]
"-D${cxx_flags_name}:STRING=${${cxx_flags_name}} -w -fPIC"

to undo what https://github.com/CNugteren/CLBlast/blob/master/cmake/cxx_flag_overrides.cmake does. It would be nice if there was a way to disable the cxx_flags-overwrite. For example there could be an additional option MSVC_LINK_MD that is checked before the overwrite

@CNugteren
Copy link
Owner

CNugteren commented Oct 13, 2017

Hmmm, yes, that piece of code. It got in by request of a user in #59. It is a bit of a strange bit of code, as it has to go all the way at the start of the CMakeLists.txt, but apparently this is what the recommended way is according to the CMake documentation

What I can do is indeed add a CMake option to disable these overrides. Would that solve it for you?

(slightly related perhaps is also #115 from another ArrayFire contributor)

@fzimmermann89
Copy link
Author

Thanks, that would definitively solve the issue for me, it seems like there is no more elegant way (quite surprising)

@CNugteren
Copy link
Owner

I've added the OVERRIDE_MSVC_FLAGS_TO_MT option, which is default to ON. Could you test with the latest master and set this option to OFF?

fzimmermann89 added a commit to fzimmermann89/arrayfire that referenced this issue Oct 14, 2017
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see arrayfire#1956
fzimmermann89 added a commit to fzimmermann89/arrayfire that referenced this issue Oct 15, 2017
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see arrayfire#1956
umar456 pushed a commit to arrayfire/arrayfire that referenced this issue Oct 17, 2017
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see #1956
umar456 pushed a commit to umar456/arrayfire that referenced this issue Nov 15, 2017
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see arrayfire#1956
umar456 pushed a commit to umar456/arrayfire that referenced this issue Dec 2, 2017
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see arrayfire#1956
umar456 pushed a commit to umar456/arrayfire that referenced this issue Dec 17, 2017
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see arrayfire#1956
9prady9 pushed a commit to arrayfire/arrayfire that referenced this issue Dec 30, 2017
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see #1956
fzimmermann89 added a commit to fzimmermann89/arrayfire that referenced this issue Mar 16, 2018
*Fix link error  on windows, see CNugteren/CLBlast#200
*Fix name of CLBlas library on windows
*Fix include, see arrayfire#1956
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants