From 50d816cbc55ac2fb5e2f9dfadb669553fd4e2525 Mon Sep 17 00:00:00 2001 From: Erik Smistad Date: Sat, 6 May 2017 05:46:12 +0200 Subject: [PATCH] Link to gcc_s and gcc if compiler is GCC version 5. Fixes issue #9593 (#9642) --- tensorflow/contrib/cmake/tf_shared_lib.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tensorflow/contrib/cmake/tf_shared_lib.cmake b/tensorflow/contrib/cmake/tf_shared_lib.cmake index 47289fd9d24..9385ac52e90 100644 --- a/tensorflow/contrib/cmake/tf_shared_lib.cmake +++ b/tensorflow/contrib/cmake/tf_shared_lib.cmake @@ -82,6 +82,13 @@ target_link_libraries(tensorflow PRIVATE tf_protos_cc ) +# There is a bug in GCC 5 resulting in undefined reference to a __cpu_model function when +# linking to the tensorflow library. Adding the following libraries fixes it. +# See issue on github: https://github.com/tensorflow/tensorflow/issues/9593 +if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.0) + target_link_libraries(tensorflow PRIVATE gcc_s gcc) +endif() + if(WIN32) add_dependencies(tensorflow tensorflow_static) endif(WIN32)