Building 20.1.6 on Ubuntu 24.04

Hi all,

I’ve been trying to build 20.1.6 on Ubuntu 24.04, but I’m having problems getting the self-tests to run.

I am checking out the source with:

cd ~/Downloads/                                                                                     \
&& git clone --branch llvmorg-20.1.6 --depth=1 https://github.com/llvm/llvm-project.git llvm-20.1.6

and building with:

cd ~/Downloads/llvm-20.1.6/                                                                       \
&& cmake -S llvm -B Build -G Ninja                                                                \
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/External/llvm-20.1.6                    \
  -DLLVM_ENABLE_PROJECTS=all -DLLVM_ENABLE_RUNTIMES=all -DLLVM_TARGETS_TO_BUILD="WebAssembly;X86" \
&& ninja -C Build -j 8 check-llvm

The cmake and ninja steps both run with some warnings, but the regression tests fail.

The error for the two failing tests are

FAIL: LLVM :: Bindings/OCaml/executionengine.ml (1 of 56180)
******************** TEST 'LLVM :: Bindings/OCaml/executionengine.ml' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: rm -rf /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp && mkdir -p /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp && cp /home/andy/Downloads/llvm-20.1.6/llvm/test/Bindings/OCaml/executionengine.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp/executionengine.ml
+ rm -rf /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp
+ mkdir -p /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp
+ cp /home/andy/Downloads/llvm-20.1.6/llvm/test/Bindings/OCaml/executionengine.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp/executionengine.ml
RUN: at line 2: /usr/bin/ocamlfind ocamlc -cclib -L/home/andy/Downloads/llvm-20.1.6/Build/lib  -g -w +A -thread -package ctypes.foreign,llvm.executionengine -linkpkg /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp/executionengine.ml -o /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp/executable
+ /usr/bin/ocamlfind ocamlc -cclib -L/home/andy/Downloads/llvm-20.1.6/Build/lib -g -w +A -thread -package ctypes.foreign,llvm.executionengine -linkpkg /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp/executionengine.ml -o /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/executionengine.ml.tmp/executable
ocamlfind: Package `ctypes-foreign' not found - required by `ctypes.foreign'

--

and

FAIL: LLVM :: Bindings/OCaml/debuginfo.ml (2 of 56180)
******************** TEST 'LLVM :: Bindings/OCaml/debuginfo.ml' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: rm -rf /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp && mkdir -p /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp && cp /home/andy/Downloads/llvm-20.1.6/llvm/test/Bindings/OCaml/debuginfo.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml && cp /home/andy/Downloads/llvm-20.1.6/llvm/test/Bindings/OCaml/Utils/Testsuite.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml
+ rm -rf /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp
+ mkdir -p /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp
+ cp /home/andy/Downloads/llvm-20.1.6/llvm/test/Bindings/OCaml/debuginfo.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml
+ cp /home/andy/Downloads/llvm-20.1.6/llvm/test/Bindings/OCaml/Utils/Testsuite.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml
RUN: at line 2: /usr/bin/ocamlfind ocamlc -cclib -L/home/andy/Downloads/llvm-20.1.6/Build/lib  -g -w +A -package llvm.all_backends -package llvm.target -package llvm.analysis -package llvm.debuginfo -I /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/ -linkpkg /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml -o /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/executable
+ /usr/bin/ocamlfind ocamlc -cclib -L/home/andy/Downloads/llvm-20.1.6/Build/lib -g -w +A -package llvm.all_backends -package llvm.target -package llvm.analysis -package llvm.debuginfo -I /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/ -linkpkg /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml -o /home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/executable
findlib: [WARNING] Package llvm has multiple definitions in /home/andy/Downloads/llvm-20.1.6/Build/lib/ocaml/META.llvm, /usr/lib/ocaml/META.llvm
File "/home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/Testsuite.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "/home/andy/Downloads/llvm-20.1.6/Build/test/Bindings/OCaml/Output/debuginfo.ml.tmp/debuginfo.ml", line 19, characters 20-50:
19 | let null_metadata = Llvm_debuginfo.llmetadata_null ()
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module Llvm_debuginfo

--

I guess I can turn the bindings off to get past this, but I’d like to understand what’s up with my configuration, is there anything else I need to install/configure for ocaml on my machine to get this to run?

Cheers,
Andy.

After a bit of gooling, it seems that ctypes.foreign is a OCAML library. You can try apt install libctypes-ocaml or apt install libctypes-ocaml-dev to install the library. No idea for the second error. (I never build the OCAML bindings myself.)

Kind regards,
Kai