@@ -58,9 +58,35 @@ execute_process (COMMAND ${LLVM_CONFIG} --includedir
5858execute_process (COMMAND ${LLVM_CONFIG} --targets-built
5959 OUTPUT_VARIABLE LLVM_TARGETS
6060 OUTPUT_STRIP_TRAILING_WHITESPACE)
61- execute_process (COMMAND ${LLVM_CONFIG} --system -libs
62- OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
63- OUTPUT_STRIP_TRAILING_WHITESPACE)
61+
62+ ############ HACK ##############
63+ # On OSX, the Homebrew (and maybe any build) of LLVM 10.0 seems to have a
64+ # link conflict with its dependency on the llvm libc++ and the system
65+ # libc++, both can end up dynamically linked and lead to very subtle and
66+ # frustrating behavior failures (in particular, osl's use of libclang will
67+ # botch include file parsing any time LD_LIBRARY_PATH doesn't have the llvm
68+ # libc++ first).
69+ #
70+ # It seems that this is not a problem when linking against the llvm and
71+ # libclang libraries statically. So on apple and when LLVM 10+ are involved,
72+ # just force that choice. Other than larger executables, it seems harmless,
73+ # and in any case a better choice than this beastly bug.
74+ #
75+ # We can periodically revisit this with new version of LLVM, maybe they will
76+ # fix things and we won't require this preemptive static linking.
77+ if (APPLE AND LLVM_VERSION VERSION_GREATER_EQUAL 10.0)
78+ set (LLVM_STATIC ON )
79+ endif ()
80+
81+ if (LLVM_STATIC)
82+ execute_process (COMMAND ${LLVM_CONFIG} --system -libs --link-static
83+ OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
84+ OUTPUT_STRIP_TRAILING_WHITESPACE)
85+ else ()
86+ execute_process (COMMAND ${LLVM_CONFIG} --system -libs
87+ OUTPUT_VARIABLE LLVM_SYSTEM_LIBRARIES
88+ OUTPUT_STRIP_TRAILING_WHITESPACE)
89+ endif ()
6490string (REPLACE " " ";" LLVM_SYSTEM_LIBRARIES "${LLVM_SYSTEM_LIBRARIES} " )
6591
6692find_library ( LLVM_LIBRARY
@@ -105,25 +131,6 @@ foreach (COMPONENT clangFrontend clangDriver clangSerialization
105131endforeach ()
106132
107133
108- ############ HACK ##############
109- # On OSX, the Homebrew (and maybe any build) of LLVM 10.0 seems to have a
110- # link conflict with its dependency on the llvm libc++ and the system
111- # libc++, both can end up dynamically linked and lead to very subtle and
112- # frustrating behavior failures (in particular, osl's use of libclang will
113- # botch include file parsing any time LD_LIBRARY_PATH doesn't have the llvm
114- # libc++ first).
115- #
116- # It seems that this is not a problem when linking against the llvm and
117- # libclang libraries statically. So on apple and when LLVM 10+ are involved,
118- # just force that choice. Other than larger executables, it seems harmless,
119- # and in any case a better choice than this beastly bug.
120- #
121- # We can periodically revisit this with new version of LLVM, maybe they will
122- # fix things and we won't require this preemptive static linking.
123- if (APPLE AND LLVM_VERSION VERSION_GREATER_EQUAL 10.0)
124- set (LLVM_STATIC ON )
125- endif ()
126-
127134# shared llvm library may not be available, this is not an error if we use LLVM_STATIC.
128135if ((LLVM_LIBRARY OR LLVM_LIBRARIES OR LLVM_STATIC) AND LLVM_INCLUDES AND LLVM_DIRECTORY AND LLVM_LIB_DIR)
129136 if (LLVM_STATIC)
0 commit comments