<p dir="ltr">This probably just works around a layering violation. Can you provide the cmake line that produces a broken build?</p>
<p dir="ltr">Cheers,<br>
Rafael</p>
<div class="gmail_quote">On Jun 18, 2016 7:34 AM, "Nicolai Hähnle" <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
since recently I'm getting linker failures in debug builds. The root cause is that -fvisibility-inlines-hidden causes inline functions in explicit template instantiations to become hidden in certain cases.<br>
<br>
The following hunk works around this...<br>
<br>
--- a/cmake/modules/HandleLLVMOptions.cmake<br>
+++ b/cmake/modules/HandleLLVMOptions.cmake<br>
@@ -159,7 +159,13 @@ endif()<br>
 if(NOT WIN32 AND NOT CYGWIN)<br>
   # MinGW warns if -fvisibility-inlines-hidden is used.<br>
   check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)<br>
-  append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)<br>
+<br>
+  # The flag also hides inlines from explicit template instantiations, which<br>
+  # leads to link failures in debug builds at least with gcc 5.3.1 and<br>
+  # both GNU ld 2.26 or gold 1.11.<br>
+  if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")<br>
+    append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)<br>
+  endif()<br>
 endif()<br>
<br>
 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )<br>
<br>
... but before I just wildly commit something, I'd say this does seem more like a compiler bug to me and so I'd like to poll people about which compilers they're using to see where this appears.<br>
<br>
FWIW, gcc 5.3.1 / ld 2.26 / gold 1.11 is what you get in Ubuntu 16.04.<br>
<br>
Also note: This has surfaced only recently, because of how the symbol types evolve during the different linker stages. PassManager<Function> is not affected, because it is referenced in libLLVMCore.a outside the .o file that contains the explicit instantiation, while PassManager<Loop> *is* affected, because it is referenced in libLLVMAnalysis.a outside the .o file that contains the explicit instantiation, but that .cpp file including the reference does *not* include LoopPassManager.h where the template instantiation is declared extern. This somehow causes the linker to treat the two cases differently.<br>
<br>
Thanks,<br>
Nicolai<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>