-
Notifications
You must be signed in to change notification settings - Fork 116
Es0m/add static runtime linking #469
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.25) | |
| project(onnxruntime_extensions LANGUAGES C CXX) | ||
|
|
||
| # set(CMAKE_VERBOSE_MAKEFILE ON) | ||
| if(NOT CMAKE_BUILD_TYPE) | ||
| if(NOT WIN32 AND NOT CMAKE_BUILD_TYPE) | ||
| message(STATUS "Build type not set - using RelWithDebInfo") | ||
| set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose build type: Debug Release RelWithDebInfo." FORCE) | ||
| endif() | ||
|
|
@@ -105,6 +105,11 @@ if(NOT CC_OPTIMIZE) | |
| endif() | ||
|
|
||
| if (MSVC) | ||
| if (OCOS_ENABLE_STATIC_LIB) | ||
| add_compile_options(/MT$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:d>) | ||
| set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:Debug>") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can set the CMAKE_MSVC_RUNTIME_LIBRARY variable from cmake command line. So this change is unnecessary.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OCOS_ENABLE_STATIC_LIB means we want to build this repo's code as a static library. However, it doesn't mean they need to static link to VC Runtime.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @es0m-msft, According to the description, this PR is to enable static linking to VCRuntime, but OCOS_STATIC_LIBRARY flag was created for generating the static library of ort-extensions.lib instead of DLL. Can you try @snnn suggestion to see if it meets your requirements?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OCOS_STATIC_LIBRARY is different from OCOS_ENABLE_STATIC_LIBRARY?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @snnn unfortunately, you can't if you want to respect generator expressions (I tried!)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I searched the code, the only occurrence of "OCOS_ENABLE_STATIC_LIB" is: if(NOT OCOS_ENABLE_STATIC_LIB AND CMAKE_SYSTEM_NAME STREQUAL "Emscripten")So, it has nothing to do with VC Runtime. OCOS_ENABLE_STATIC_LIB has effects only when CMAKE_SYSTEM_NAME equals to "Emscripten", which does not use vc runtime at all. So I don't think the variable is used to control which VC Runtime to use. And we should not give the variable a new meaning(which will surprise the person who created this cmake option).
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ONNX Runtime's build.py has a build option:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And, as
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html#variable:CMAKE_MSVC_RUNTIME_LIBRARY
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. regarding your use of OCOS_ENABLE_STATIC_LIB -- I'd suggest writing some documentation on how to use the flag. It is unclear as you can see by it's usage. It's related to WASM only apparently. |
||
| endif () | ||
|
|
||
| check_cxx_compiler_flag(-sdl HAS_SDL) | ||
| check_cxx_compiler_flag(-Qspectre HAS_QSPECTRE) | ||
| if (HAS_QSPECTRE) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.