[llvm] [OCaml] Try to fix library dependencies (PR #171470)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 9 08:33:13 PST 2025
https://github.com/nikic created https://github.com/llvm/llvm-project/pull/171470
Whenever I try to change anything in the OCaml bindings, I run into errors like this when running tests:
File "/home/npopov/repos/llvm-project/build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "/home/npopov/repos/llvm-project/build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml", line 1:
Error: The files "/home/npopov/repos/llvm-project/build/lib/ocaml/llvm/llvm.cmi"
and "/home/npopov/repos/llvm-project/build/lib/ocaml/llvm/llvm_debuginfo.cmi"
make inconsistent assumptions over interface "Llvm"
The only reliable way of getting rid of these I have found is to do an `rm -rf build` and just rebuild everything.
This PR tries to fix this issue by adding an additional dependency on the `.cmi` files of dependent modules.
Disclaimer: This solution was suggested by Claude Code, so I'd appreciate a careful look from someone who actually understands what all these different ocaml files mean.
>From d538959434e39db6add18da8bd0af4e1d02ca6ae Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Tue, 9 Dec 2025 17:20:42 +0100
Subject: [PATCH] [OCaml] Try to fix library dependencies
Whenever I try to change anything in the OCaml bindings, I run into
errors like this when running tests:
File "/home/npopov/repos/llvm-project/build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "/home/npopov/repos/llvm-project/build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml", line 1:
Error: The files "/home/npopov/repos/llvm-project/build/lib/ocaml/llvm/llvm.cmi"
and "/home/npopov/repos/llvm-project/build/lib/ocaml/llvm/llvm_debuginfo.cmi"
make inconsistent assumptions over interface "Llvm"
The only reliable way of getting rid of these I have found is to
do an `rm -rf build` and just rebuild everything.
This PR tries to fix this issue by adding an additional dependency
on the `.cmi` files of dependent modules.
Disclaimer: This solution was suggested by Claude Code, so I'd
appreciate a careful look from someone who understands all these
different ocaml files.
---
llvm/cmake/modules/AddOCaml.cmake | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/llvm/cmake/modules/AddOCaml.cmake b/llvm/cmake/modules/AddOCaml.cmake
index 2d9116b08a526..1d6a926bbb21d 100644
--- a/llvm/cmake/modules/AddOCaml.cmake
+++ b/llvm/cmake/modules/AddOCaml.cmake
@@ -57,9 +57,12 @@ function(add_ocaml_library name)
"-ccopt" "-Wl,-rpath,\\$CAMLORIGIN/../.."
${ocaml_pkgs})
+ set(ocaml_dep_outputs)
foreach( ocaml_dep ${ARG_OCAMLDEP} )
get_target_property(dep_ocaml_flags "ocaml_${ocaml_dep}" OCAML_FLAGS)
list(APPEND ocaml_flags ${dep_ocaml_flags})
+ # Add dependency on the dependent module's .cmi file
+ list(APPEND ocaml_dep_outputs "${LLVM_LIBRARY_DIR}/ocaml/llvm/${ocaml_dep}.cmi")
endforeach()
if( NOT BUILD_SHARED_LIBS )
@@ -157,7 +160,7 @@ function(add_ocaml_library name)
OUTPUT ${ocaml_outputs}
COMMAND "${OCAMLFIND}" "ocamlmklib" "-ocamlcflags" "-bin-annot"
"-o" "${name}" ${ocaml_flags} ${ocaml_params}
- DEPENDS ${ocaml_inputs} ${c_outputs}
+ DEPENDS ${ocaml_inputs} ${c_outputs} ${ocaml_dep_outputs}
COMMENT "Building OCaml library ${name}"
VERBATIM)
More information about the llvm-commits
mailing list