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

Link VC++ runtime statically #27134

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/job_build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
ARTIFACTS_SHARE: "C:\\mount\\build-artifacts"
MANIFEST_PATH: "${{ github.workspace }}\\manifest.yml"
PRODUCT_TYPE: 'public_windows_vs2019_${{ inputs.build-type }}'
CMAKE_TOOLCHAIN_FILE: "${{ github.workspace }}\\openvino\\cmake\\toolchains\\mt.runtime.win32.toolchain.cmake"
steps:
- name: Clone OpenVINO
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows_conditional_compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
BUILD_DIR: "${{ github.workspace }}\\openvino_build"
MODELS_PATH: "${{ github.workspace }}\\testdata"
SELECTIVE_BUILD_STAT_DIR: "${{ github.workspace }}\\selective_build_stat"
CMAKE_TOOLCHAIN_FILE: "${{ github.workspace }}\\openvino\\cmake\\toolchains\\mt.runtime.win32.toolchain.cmake"
# TODO: specify version of compiler here
if: ${{ !needs.smart_ci.outputs.skip_workflow && github.event_name != 'merge_group' }}

Expand Down
12 changes: 8 additions & 4 deletions cmake/toolchains/mt.runtime.win32.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ if(use_static_runtime)
foreach(lang C CXX)
foreach(build_type "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
set(flag_var "CMAKE_${lang}_FLAGS${build_type}_INIT")
set(flag_var_noninit "CMAKE_${lang}_FLAGS${build_type}")
string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endforeach()
endforeach()
foreach(type EXE SHARED MODULE)
foreach(build_type "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
set(flag_var "CMAKE_${type}_LINKER_FLAGS${build_type}_INIT")
if (build_type STREQUAL "_DEBUG")
set(${flag_var_noninit} "${${flag_var_noninit}} /MTd")
string(APPEND ${flag_var} " /NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we linking components with deferent versions of CRT? (linker #pragmas)
Please document why is that needed.

Copy link
Contributor

@lmielick lmielick Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linking with /verbose:lib might help

else()
set(${flag_var_noninit} "${${flag_var_noninit}} /MT")
string(APPEND ${flag_var} " /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
endif()
endforeach()
endforeach()
endforeach()
endif()

macro(ov_set_msvc_runtime var value)
Expand Down
Loading