[PATCH] D68452: [llvm] [ocaml] Support linking against dylib

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 4 02:25:00 PDT 2019


mgorny created this revision.
mgorny added reviewers: aaron.ballman, whitequark, jpdeplaix.
Herald added a project: LLVM.

Support linking OCaml modules against LLVM dylib when requested,
rather than against static libs that might not be installed at all.


https://reviews.llvm.org/D68452

Files:
  llvm/cmake/modules/AddOCaml.cmake


Index: llvm/cmake/modules/AddOCaml.cmake
===================================================================
--- llvm/cmake/modules/AddOCaml.cmake
+++ llvm/cmake/modules/AddOCaml.cmake
@@ -66,21 +66,25 @@
     list(APPEND ocaml_flags "-custom")
   endif()
 
-  explicit_map_components_to_libraries(llvm_libs ${ARG_LLVM})
-  foreach( llvm_lib ${llvm_libs} )
-    list(APPEND ocaml_flags "-l${llvm_lib}" )
-  endforeach()
+  if(LLVM_LINK_LLVM_DYLIB)
+    list(APPEND ocaml_flags "-lLLVM")
+  else()
+    explicit_map_components_to_libraries(llvm_libs ${ARG_LLVM})
+    foreach( llvm_lib ${llvm_libs} )
+      list(APPEND ocaml_flags "-l${llvm_lib}" )
+    endforeach()
 
-  get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
-  foreach(system_lib ${system_libs})
-    if (system_lib MATCHES "^-")
-      # If it's an option, pass it without changes.
-      list(APPEND ocaml_flags "${system_lib}" )
-    else()
-      # Otherwise assume it's a library name we need to link with.
-      list(APPEND ocaml_flags "-l${system_lib}" )
-    endif()
-  endforeach()
+    get_property(system_libs TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
+    foreach(system_lib ${system_libs})
+      if (system_lib MATCHES "^-")
+        # If it's an option, pass it without changes.
+        list(APPEND ocaml_flags "${system_lib}" )
+      else()
+        # Otherwise assume it's a library name we need to link with.
+        list(APPEND ocaml_flags "-l${system_lib}" )
+      endif()
+    endforeach()
+  endif()
 
   string(REPLACE ";" " " ARG_CFLAGS "${ARG_CFLAGS}")
   set(c_flags "${ARG_CFLAGS} ${LLVM_DEFINITIONS}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68452.223176.patch
Type: text/x-patch
Size: 1624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191004/66211351/attachment.bin>


More information about the llvm-commits mailing list