From 6e08efa6a2c77403c9cb65bb3dc157eced419bbd Mon Sep 17 00:00:00 2001 From: Changming Sun Date: Thu, 5 Dec 2019 14:15:52 -0800 Subject: [PATCH] Fix lto bug for protobuf and ubuntu --- cmake/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 78353bc7b4..ab3dbeb1a9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -279,6 +279,12 @@ else() add_library(protobuf::libprotobuf ALIAS libprotobuf-lite) endif() add_executable(protobuf::protoc ALIAS protoc) + +if(UNIX AND onnxruntime_ENABLE_LTO) + #https://github.com/protocolbuffers/protobuf/issues/5923 + target_link_options(protoc PRIVATE "-Wl,--no-as-needed") +endif() + include(protobuf_function.cmake) if (onnxruntime_DISABLE_CONTRIB_OPS)