[llvm] [CMake][OCaml] Make OCaml bindings suitable for out-of-tree install (PR #123478)
John Ericson via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 26 10:34:23 PST 2025
================
@@ -38,12 +38,27 @@ function(add_ocaml_library name)
set(ocaml_inputs)
set(ocaml_outputs "${bin}/${name}.cma")
+
+ # The -custom flag causes bytecode executables to fail upon creating the
+ # runtime when installing the bindings for an out-of-tree build.
+ #
+ # However, the -custom flag is necessary when running the in-tree
+ # test suite, otherwise multiple libraries will link to the same libLLVM and
+ # runtime errors of the form
+ # "CommandLine Error: Option *opt* registered more than once!" will occur.
+ if (NOT LLVM_OCAML_OUT_OF_TREE AND NOT BUILD_SHARED_LIBS)
+ set(ocaml_custom TRUE)
+ else()
+ set(ocaml_custom FALSE)
+ endif()
+
if( ARG_C )
+ # ocamlmklib outputs .a and .so
list(APPEND ocaml_outputs
- "${bin}/lib${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
- if ( BUILD_SHARED_LIBS )
+ "${bin}/lib${name}.a")
+ if ( NOT ocaml_custom )
list(APPEND ocaml_outputs
- "${bin}/dll${name}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ "${bin}/dll${name}.so")
----------------
Ericson2314 wrote:
Oh I see past talk on this, I still don't like this solution, however.
https://github.com/llvm/llvm-project/pull/123478
More information about the llvm-commits
mailing list