From 2e048660ffa8243596aaf3338e60c7c0575458f2 Mon Sep 17 00:00:00 2001 From: Chun-Wei Chen Date: Tue, 12 Oct 2021 07:12:35 -0700 Subject: [PATCH] Use MSVC Runtime as dll for official ONNX Windows release (#3644) * USE_MSVC_STATIC_RUNTIME=OFF for release Signed-off-by: Chun-Wei Chen * Update ONNX_USE_MSVC_STATIC_RUNTIME=0 by default in docs Signed-off-by: Chun-Wei Chen * updated default as 0 Signed-off-by: Chun-Wei Chen --- .azure-pipelines/Windows-CI.yml | 1 - .github/workflows/release_win.yml | 3 +-- README.md | 6 +++--- setup.py | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines/Windows-CI.yml b/.azure-pipelines/Windows-CI.yml index 48af0b3c..38246631 100644 --- a/.azure-pipelines/Windows-CI.yml +++ b/.azure-pipelines/Windows-CI.yml @@ -49,7 +49,6 @@ jobs: set ONNX_BUILD_TESTS=1 set ONNX_ML=$(onnx_ml) set ONNX_VERIFY_PROTO_3=$(onnx_verify_proto) - set USE_MSVC_STATIC_RUNTIME=0 set CMAKE_ARGS=-DONNX_USE_PROTOBUF_SHARED_LIBS=ON -DONNX_USE_LITE_PROTO=ON -DONNX_WERROR=ON python setup.py -q install diff --git a/.github/workflows/release_win.yml b/.github/workflows/release_win.yml index b92545e9..c83aa616 100644 --- a/.github/workflows/release_win.yml +++ b/.github/workflows/release_win.yml @@ -74,7 +74,7 @@ jobs: mkdir protobuf_install cd ./protobuf/cmake - cmake -G "Visual Studio 16 2019" -A $arch -DCMAKE_INSTALL_PREFIX="../../protobuf_install" -Dprotobuf_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF . + cmake -G "Visual Studio 16 2019" -A $arch -DCMAKE_INSTALL_PREFIX="../../protobuf_install" -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF . msbuild protobuf.sln /m /p:Configuration=Release msbuild INSTALL.vcxproj /p:Configuration=Release echo "Protobuf installation complete." @@ -90,7 +90,6 @@ jobs: cd ../../../onnx dir echo "Install ONNX" - $Env:USE_MSVC_STATIC_RUNTIME=1 $Env:ONNX_ML=1 $Env:CMAKE_ARGS="-DONNX_USE_PROTOBUF_SHARED_LIBS=OFF -DONNX_USE_LITE_PROTO=ON" diff --git a/README.md b/README.md index ce97a856..3cff15c0 100644 --- a/README.md +++ b/README.md @@ -107,7 +107,7 @@ git clone https://github.com/protocolbuffers/protobuf.git cd protobuf git checkout v3.16.0 cd cmake -cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX= -Dprotobuf_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF . +cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX= -Dprotobuf_MSVC_STATIC_RUNTIME=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF . msbuild protobuf.sln /m /p:Configuration=Release msbuild INSTALL.vcxproj /p:Configuration=Release ``` @@ -233,14 +233,14 @@ to verify it works. For full list refer to CMakeLists.txt **Environment variables** * `USE_MSVC_STATIC_RUNTIME` should be 1 or 0, not ON or OFF. When set to 1 onnx links statically to runtime library. -**Default**: USE_MSVC_STATIC_RUNTIME=1 +**Default**: USE_MSVC_STATIC_RUNTIME=0 * `DEBUG` should be 0 or 1. When set to 1 onnx is built in debug mode. or debug versions of the dependencies, you need to open the [CMakeLists file][CMakeLists] and append a letter `d` at the end of the package name lines. For example, `NAMES protobuf-lite` would become `NAMES protobuf-lited`. **Default**: Debug=0 **CMake variables** * `ONNX_USE_PROTOBUF_SHARED_LIBS` should be ON or OFF. -**Default**: ONNX_USE_PROTOBUF_SHARED_LIBS=OFF USE_MSVC_STATIC_RUNTIME=1 +**Default**: ONNX_USE_PROTOBUF_SHARED_LIBS=OFF USE_MSVC_STATIC_RUNTIME=0 `ONNX_USE_PROTOBUF_SHARED_LIBS` determines how onnx links to protobuf libraries. - When set to ON - onnx will dynamically link to protobuf shared libs, PROTOBUF_USE_DLLS will be defined as described [here](https://github.com/protocolbuffers/protobuf/blob/master/cmake/README.md#dlls-vs-static-linking), Protobuf_USE_STATIC_LIBS will be set to OFF and `USE_MSVC_STATIC_RUNTIME` must be 0. - When set to OFF - onnx will link statically to protobuf, and Protobuf_USE_STATIC_LIBS will be set to ON (to force the use of the static libraries) and `USE_MSVC_STATIC_RUNTIME` can be 0 or 1. diff --git a/setup.py b/setup.py index 8cf0f5a2..71a446a1 100644 --- a/setup.py +++ b/setup.py @@ -47,15 +47,15 @@ extras_require = {} # Default value is set to TRUE\1 to keep the settings same as the current ones. # However going forward the recomemded way to is to set this to False\0 -USE_MSVC_STATIC_RUNTIME = bool(os.getenv('USE_MSVC_STATIC_RUNTIME', '1') == '1') ONNX_ML = not bool(os.getenv('ONNX_ML') == '0') ONNX_VERIFY_PROTO3 = bool(os.getenv('ONNX_VERIFY_PROTO3') == '1') ONNX_NAMESPACE = os.getenv('ONNX_NAMESPACE', 'onnx') ONNX_BUILD_TESTS = bool(os.getenv('ONNX_BUILD_TESTS') == '1') ONNX_DISABLE_EXCEPTIONS = bool(os.getenv('ONNX_DISABLE_EXCEPTIONS') == '1') -DEBUG = bool(os.getenv('DEBUG')) -COVERAGE = bool(os.getenv('COVERAGE')) +USE_MSVC_STATIC_RUNTIME = bool(os.getenv('USE_MSVC_STATIC_RUNTIME', '0') == '1') +DEBUG = bool(os.getenv('DEBUG', '0') == '1') +COVERAGE = bool(os.getenv('COVERAGE', '0') == '1') ################################################################################ # Version -- GitLab