Skip to content

apt: add clang + llvm-dev to the full image for OpenModelica LLVM builds#52

Merged
JKRT merged 2 commits into
OpenModelica:mainfrom
SVAGEN26:add-llvm-dev-packages
Jul 7, 2026
Merged

apt: add clang + llvm-dev to the full image for OpenModelica LLVM builds#52
JKRT merged 2 commits into
OpenModelica:mainfrom
SVAGEN26:add-llvm-dev-packages

Conversation

@SVAGEN26

@SVAGEN26 SVAGEN26 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds clang, llvm, and llvm-dev to COMMON_PKGS in apt/Dockerfile so the published build-deps:*-full images ship the LLVM toolchain out of the box.

Motivation

The OpenModelica revive-llvm-jit PR (#15890) and downstream LLVM work want -DOM_OMC_ENABLE_LLVM=ON to be reachable from CI without further provisioning. Today the full image has neither clang nor llvm-dev, so CMake's find_package(LLVM 18 CONFIG …) fails on the base image and any LLVM-enabled build has to install these itself.

What CMake actually needs

OMCompiler/Compiler/runtime/CMakeLists.txt:147-171 requires:

  • LLVM ≥ 16 (asserted at line 154)
  • LLVMConfig.cmake (provided by llvm-N-dev)
  • Components: core orcjit mcjit executionengine transformutils ipo support irreader bitwriter native nativecodegen
  • clang + llvm-link reachable via LLVM_TOOLS_BINARY_DIR (used by EXT_LLVM.compileModelToBitcode at simulate time to lower model C to bitcode)

The llvm, llvm-dev, clang meta-packages pull in the distro-default LLVM major with all of the above.

Distro coverage

The meta-packages resolve to whatever ships natively; no third-party apt repo is added. Consequences per image in .ci/matrix.yml:

image LLVM major OM_OMC_ENABLE_LLVM=ON usable?
ubuntu 26.04 20 yes
ubuntu 24.04 18 yes
ubuntu 22.04 14 no (CMake refuses at line 154)
debian 13 19 yes
debian 12 14 no (CMake refuses at line 154)

The default OpenModelica build (LLVM off) is unaffected. On the two older distros, an LLVM-on build fails with a clear "needs LLVM >= 16" message rather than being silently degraded, which is the right behavior. If a follow-up wants LLVM ≥ 16 on Jammy or Bookworm, adding apt.llvm.org in a separate conditional RUN is the natural next step; that is out of scope for this PR.

Image size impact

llvm-N-dev and the LLVM shared libs are large (~500 MB on Ubuntu 24.04). The full image already carries Qt6, TeX Live, and the OpenCL stack; the delta is meaningful but not disproportionate for a base image whose purpose is "everything needed to build OpenModelica."

Test plan

  • docker build --target full --build-arg DISTRO=ubuntu --build-arg VERSION=24.04 --tag build-deps:ubuntu-24.04 apt succeeds.
  • Inside that image, dpkg -l | grep -E 'llvm-|clang' shows llvm-18-dev and clang-18 (or the distro-default equivalent).
  • apt list --installed 2>/dev/null | grep -q llvm-18-dev.
  • Inside that image, cloning OpenModelica revive-llvm-jit and configuring with -DOM_OMC_ENABLE_LLVM=ON -DOM_OMC_ENABLE_LLVM_JIT=ON finds LLVM ≥ 16.
  • docker build --target full --build-arg DISTRO=ubuntu --build-arg VERSION=22.04 --tag build-deps:ubuntu-22.04 apt still succeeds (older LLVM installed; no build regression on the default image, only OM_OMC_ENABLE_LLVM=ON would refuse there).

Refs OpenModelica/OpenModelica#15890

Adds the LLVM toolchain (clang meta-package, llvm meta-package, and
llvm-dev headers/libs/LLVMConfig.cmake) to the base image so downstream
OpenModelica builds that pass -DOM_OMC_ENABLE_LLVM=ON can find LLVM
without further provisioning.

Distro version note:
The llvm/llvm-dev/clang meta-packages resolve to the distro-default
major:

  ubuntu 26.04 -> llvm-20 (>= 16, supported)
  ubuntu 24.04 -> llvm-18 (>= 16, supported)
  ubuntu 22.04 -> llvm-14 (< 16, OM_OMC_ENABLE_LLVM will refuse
                           per OMCompiler/Compiler/runtime/CMakeLists.txt:154)
  debian 13    -> llvm-19 (>= 16, supported)
  debian 12    -> llvm-14 (< 16, OM_OMC_ENABLE_LLVM will refuse)

The default OpenModelica build (LLVM off) is unaffected. When LLVM is
enabled and the distro-default is too old, CMake exits with a clear
'needs LLVM >= 16' message, which is the right failure mode; older
distros are not silently degraded.

Co-Authored-By: JKRT_CLAUDE <247156613+SVAGEN26@users.noreply.github.com>

@AnHeuermann AnHeuermann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang is already part of build-deps from OpenModelica.

Do we need llvm and llvm-dev for all builds of OpenModelica or should it be an add-on like debug in https://github.com/OpenModelica/build-deps/blob/main/apt/Dockerfile#L270-L287?

Otherwise looks fine. We can merge it as soon as the build and publish step is fixed in our CI.

Comment thread apt/Dockerfile Outdated
@JKRT JKRT marked this pull request as ready for review July 2, 2026 11:48
@JKRT JKRT enabled auto-merge July 6, 2026 16:17
@JKRT JKRT merged commit f6ef630 into OpenModelica:main Jul 7, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants