Option to link MIGraphX to MSVC Runtime Library statically or dynamically#4839
Option to link MIGraphX to MSVC Runtime Library statically or dynamically#4839apwojcik wants to merge 30 commits into
Conversation
|
I think you are doing something wrong. The dependencies in requirements.txt build with rbuild using clang-cl, and it doesnt need |
I dont think we even use the |
We use clang to compile, and the change is for the clang compiler (not clang-cl). With clang-cl, the MIGraphX compiles with no warnings. We will perform additional testing on binaries built with clang-cl and consider switching the compiler. |
Either way this change should go into protobuf. MIGraphX shouldn't be monkey patching it. |
| set_target_properties(${target} PROPERTIES | ||
| MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>${__suffix}") | ||
| unset(__suffix) | ||
| endfunction() No newline at end of file |
There was a problem hiding this comment.
Are you trying to build migraphx with clang-cl as well?
I dont think we need to do this in here. These seem like toochain variables and can be set with -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>DLL -DCMAKE_CXX_FLAGS_DEBUG=/D _DEBUG /D _ITERATOR_DEBUG_LEVEL=2
There was a problem hiding this comment.
Are you trying to build migraphx with clang-cl as well?
I dont think we need to do this in here. These seem like toochain variables and can be set with
-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>DLL -DCMAKE_CXX_FLAGS_DEBUG=/D _DEBUG /D _ITERATOR_DEBUG_LEVEL=2
Yes, we switch the compiler to clang-cl. After upgrading to protobuf v30, we need to set that information manually. Otherwise, there are mismatches between the runtime libraries used by MIGraphX and the protobuf-generated libraries. For some reason, the new protoc is not propagating the runtime library and setting _DEBUG and the iterator level correctly.
We do not use a toolchain file for the compiler. As I mentioned in the updated description, we need to switch the entire MIGraphX to the statically linked MSVC runtime soon. We want to change the runtime library linking with a single CMake option. We don't want to set it globally, only for the targets that require it. The function does what we require.
There was a problem hiding this comment.
For some reason, the new protoc is not propagating the runtime library
It should propagate the runtime library fine. I set something like this in the toolchain: -Dprotobuf_MSVC_STATIC_RUNTIME=Off -DABSL_MSVC_STATIC_RUNTIME=Off -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL. I dont know if all those flags are needed but I was able to build and run the tests for onnx and tf on windows with thos defined in the toolchain.
and setting _DEBUG and the iterator level correctly.
Are you saying the protoc doesnt have these flags set? That seems like a toolchain mismatch, but maybe protobuf edits the CMAKE_CXX_FLAGS(thats the reason for CMP0091).
We do not use a toolchain file for the compiler.
If you are using cget(or rbuild) you are using a toolchain file. And you can set flags in it with cget init -Dprotobuf_MSVC_STATIC_RUNTIME=Off -DABSL_MSVC_STATIC_RUNTIME=Off -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL.(I do see cget being used on the windows CI). You can also set those in rbuild session with global_defines.
We want to change the runtime library linking with a single CMake option.
Yes thats what the CMAKE_MSVC_RUNTIME_LIBRARY option does in cmake. We should use the standard options provided by cmake.
We don't want to set it globally
Why? Wont that cause issues with some targets built with different runtimes? Everything should be built with the same runtime.
There was a problem hiding this comment.
I used the wrong depend folder for testing. When I switched to the correct one, I no longer needed the recent changes I had made. I reverted them. Thanks for noticing!
| file(GLOB TESTS CONFIGURE_DEPENDS *.cpp) | ||
| list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/register_target.cpp) | ||
| if(NOT MIGRAPHX_USE_MIOPEN) | ||
| list(REMOVE_ITEM TESTS ${CMAKE_CURRENT_SOURCE_DIR}/sqlite.cpp) |
There was a problem hiding this comment.
This will remove the sqlite tests on the linux runners. They should not be removed.
Co-authored-by: Paul Fultz II <paul.fultz@amd.com>
|
Providing |
| verify_args.cpp | ||
| ) | ||
|
|
||
| if(MIGRAPHX_USE_MIOPEN) |
There was a problem hiding this comment.
We shouldn't be conditionally adding sqlite based on miopen. MIOpen is specific to the migraphx_gpu target and this is the core migraphx library used by all targets.
|
|
||
| include(CMakeDependentOption) | ||
|
|
||
| cmake_dependent_option(MIGRAPHX_MSVC_STATIC_RUNTIME "" OFF "WIN32" OFF) |
There was a problem hiding this comment.
Could you add the description, like "Link MSVC runtime library statically instead of dynamically" instead of leaving blank?
The content of the PR changed from the original submission. Now the PR only adds an option to MIGraphX to enable linking to the MSVC Runtime Library either statically or dynamically. I left the original description below.
Original description: