From 738303ba43dc29b82c9877acaa587ed1d55ce251 Mon Sep 17 00:00:00 2001 From: Pavel Belevich Date: Wed, 4 Sep 2019 13:38:08 -0700 Subject: [PATCH] Add set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,--no-as-needed") to CMakeLists.txt (#25445) Summary: This is a fix for a rare build issue on Ubuntu: `symbol lookup error: miniconda3/envs/pytorch-py3.7/lib/libmkl_intel_lp64.so: undefined symbol: mkl_blas_dsyrk` https://software.intel.com/en-us/articles/symbol-lookup-error-when-linking-intel-mkl-with-gcc-on-ubuntu Pull Request resolved: https://github.com/pytorch/pytorch/pull/25445 Differential Revision: D17151458 Pulled By: pbelevich fbshipit-source-id: a0f3e86a05ac408b95446560f42fc16fbff2d7af --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6faab67f29..34ed1c6206d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,6 +191,13 @@ cmake_dependent_option( set(ONNX_NAMESPACE "onnx_torch" CACHE STRING "A namespace for ONNX; needed to build with other frameworks that share ONNX.") +# This is a fix for a rare build issue on Ubuntu: +# symbol lookup error: miniconda3/envs/pytorch-py3.7/lib/libmkl_intel_lp64.so: undefined symbol: mkl_blas_dsyrk +# https://software.intel.com/en-us/articles/symbol-lookup-error-when-linking-intel-mkl-with-gcc-on-ubuntu +if(LINUX) + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed") +endif() + if (MSVC) foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE