Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Es0m/add static runtime linking #469
base: main
Are you sure you want to change the base?
Es0m/add static runtime linking #469
Changes from all commits
e9ee52c
6f2ef40
d777b5b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OCOS_STATIC_LIBRARY is different from OCOS_ENABLE_STATIC_LIBRARY?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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!)
Would you like a different OPTION for this usecase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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:
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ONNX Runtime's build.py has a build option:
--enable_msvc_static_runtime
. It works by settingCMAKE_MSVC_RUNTIME_LIBRARY
cmake variable toMultiThreaded$<$<CONFIG:Debug>:Debug
. If you build this repo with the main ONNX Runtime repo, you can use that build option. Otherwise you can do the same thing when you invoke cmake. Therefore I think there is no need to introduce a new cmake variable to control this. Every cmake project should respect theCMAKE_MSVC_RUNTIME_LIBRARY
cmake variable's value.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, as
CMAKE_MSVC_RUNTIME_LIBRARY
means "the default value of MSVC_RUNTIME_LIBRARY". In cmake files, we should not setCMAKE_MSVC_RUNTIME_LIBRARY
as it will change thedefault
value instead of theactual
value:MSVC_RUNTIME_LIBRARY
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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
If you follow the docs, you're supposed to set CMAKE_MSVC_RUNTIME_LIBRARY not MSVC_RUNTIME_LIBRARY.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.
Also, instead of having some command line collection parameters assembled as per build.py, having a clear option to enable the required functionality might be better.