Skip to content

fix(docker): build libcimpp from source on ARM64/macOS - #610

Open
AnasBahr wants to merge 1 commit into
sogno-platform:masterfrom
AnasBahr:master
Open

fix(docker): build libcimpp from source on ARM64/macOS#610
AnasBahr wants to merge 1 commit into
sogno-platform:masterfrom
AnasBahr:master

Conversation

@AnasBahr

Copy link
Copy Markdown

Description

Resolves issue regarding Docker build failures on macOS/ARM64 architectures.

The current build process installs a precompiled libcimpp RPM package target built for x86_64 Linux systems. On ARM64 macOS hosts, this binary is architecture-incompatible and breaks the image build.

This PR adds architecture detection inside the Dockerfile to dynamically build libcimpp from source when running on ARM64 / macOS hosts, while preserving the precompiled package installation for standard x86_64 targets.

Changes Made

  • Updated Dockerfile to detect host platform/architecture (x86_64 vs. ARM64).
  • Added conditional build steps to compile libcimpp from source on ARM64 environments.

Related Issue'

Closes #609

Signed-off-by: Anas Bahr <anas.bahr@rwth-aachen.de>
@AnasBahr
AnasBahr requested a review from stv0g as a code owner July 30, 2026 17:59
@leonardocarreras leonardocarreras added the bug Something isn't working label Jul 31, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

DPsim LLM review

Claim vs. code: matches the description.

TL;DR: One medium documentation-only concern was raised about the new ARM64/macOS libcimpp source-build path not being reflected in Docker docs; no code correctness, scheduling, or stamping issues were reported in this pass.

Found 1 medium (0 anchored to lines below).

🔵 Optional / low-confidence (1)
  • Add documentation for libcimpp build behavior change in Dockerfile [medium · 30% confidence · unconfirmed] in packaging/Docker/Dockerfile.dev:75
Claim vs. implementation
  • Claimed: Build libcimpp from source on ARM64/macOS while keeping prebuilt RPM installation for x86_64 Docker builds.
  • Done: Dockerfile.dev now installs the prebuilt libcimpp RPM only on x86_64 and otherwise clones libcimpp v${LIBCIMPP_VERSION} from source, builds it with cmake/make, and installs it.
  • Difference: none
How this review was produced

13 specialized finder passes raised 16 findings over the diff and the full changed sources. After de-duplication, 16 were re-checked against the current file and the base-class / interface headers it inherits (code as truth), escalating survivors to a stronger model: 15 refuted as unsupported, 1 kept (1 tentative).

Refuted by verification:

  • Use robust curl options for package download (packaging/Docker/Dockerfile.dev): The curl already uses --max-time 300, --retry 3, and --retry-delay 5 on line 86.
  • Pin git clone depth for libcimpp source build (packaging/Docker/Dockerfile.dev): The source path already pins libcimpp to the exact tag v${LIBCIMPP_VERSION} and uses --depth 1 on line 92.
  • Add retry and timeout to RPM download to avoid indefinite blocking (packaging/Docker/Dockerfile.dev): The RPM download curl includes a 300-second timeout and retry policy on line 86.
  • Remove redundant comment line (packaging/Docker/Dockerfile.dev): The comment on line 75 is the updated single-line description of both prebuilt and source-build behavior.
  • Inconsistent quoting style in URL construction (packaging/Docker/Dockerfile.dev): The URL-encoded release path and the RPM filename serve different purposes and are both used as written on line 80.
  • update comment to reflect new conditional logic (packaging/Docker/Dockerfile.dev): The comment explicitly mentions the new conditional source-build path for non-x86_64 platforms.
  • correct misleading error message wording (packaging/Docker/Dockerfile.dev): The error is for unsupported CIM_VERSION values in the case statement, not for host architecture.
  • Use SPDLOG_LOGGER_DEBUG for non-critical download progress (packaging/Docker/Dockerfile.dev): This is a Dockerfile RUN command, not a logging path; the curl progress/error handling is already implemented inline.
  • Avoid stderr echo for unsupported CIM_VERSION (packaging/Docker/Dockerfile.dev): Printing the unsupported-version error to stderr with echo is standard Dockerfile shell error handling.
  • Add retry and timeout to source build download of libcimpp RPM (packaging/Docker/Dockerfile.dev): The source-build branch is a git clone plus cmake/make path, and the finding’s claim about missing robustness is not a concrete defect in the file.
  • Missing cleanup on source-build git clone failure (packaging/Docker/Dockerfile.dev): The source-build branch already removes /tmp/libcimpp after install on line 96.
  • Add retry and timeout to prebuilt libcimpp download to avoid hanging CI builds (packaging/Docker/Dockerfile.dev): The prebuilt libcimpp download already has timeout and retry safeguards on line 86.
  • Add SPDX license header to Dockerfile.dev (packaging/Docker/Dockerfile.dev): the file lacks an SPDX header, but Dockerfile.dev is an existing modified file and the missing header is outside the changed lines
  • Hard‑coded lib64 library directory is non‑portable (packaging/Docker/Dockerfile.dev): the changed install path at line 94 matches the existing LD_LIBRARY_PATH entry /usr/local/lib64 at line 63, so the claimed runtime path mismatch is contradicted
  • CMake install libdir hard‑coded to lib64 breaks ARM64 builds (packaging/Docker/Dockerfile.dev): line 94 installs libcimpp to /usr/local/lib64, and this Dockerfile explicitly adds /usr/local/lib64 to LD_LIBRARY_PATH before the build

Automated, non-blocking review. May be wrong. Models: find mistral-small-4-119b-2603, gpt-oss-120b → verify gpt-5.4-mini → final gpt-5.5.

@sonarqubecloud

Copy link
Copy Markdown

dnf -y install /tmp/libcimpp.rpm; \
rm -f /tmp/libcimpp.rpm; \
if [ "$(uname -m)" = "x86_64" ]; then \
curl -sSL -L --max-time 300 --retry 3 --retry-delay 5 "${libcimpp_url}" -o /tmp/libcimpp.rpm || (echo "Failed to download ${libcimpp_url}" >&2; exit 1); \
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.82%. Comparing base (47b236e) to head (475112b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #610      +/-   ##
==========================================
- Coverage   72.87%   72.82%   -0.05%     
==========================================
  Files         497      497              
  Lines       32305    32305              
  Branches    17470    17470              
==========================================
- Hits        23542    23527      -15     
- Misses       8762     8777      +15     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leonardocarreras leonardocarreras left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi @AnasBahr, i think this does not solve all what you mention in #609 as cases (it solves only for one container), as for many of the containers is done this way (ubuntu, rocky, etc). However, that can be a follow up.
Some comments:

  • tag for v2.2.0 seems to be release/v2.2.0, maybe that is why it does not work, that might be pre-existing (does it work on the branch)
Image
  • when compiling, is important to keep CIM_VERSION to select the CGMES

Comment on lines +89 to +97
else \
echo "Building libcimpp from source for $(uname -m)"; \
dnf -y install graphviz-devel libxml2-devel; \
cd /tmp && git clone --branch "v${LIBCIMPP_VERSION}" --recurse-submodules --depth 1 https://github.com/sogno-platform/libcimpp.git && \
mkdir -p libcimpp/build && cd libcimpp/build && \
cmake ${CMAKE_OPTS} .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=/usr/local/lib64 && \
make ${MAKE_OPTS} install && \
rm -rf /tmp/libcimpp; \
fi; \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
else \
echo "Building libcimpp from source for $(uname -m)"; \
dnf -y install graphviz-devel libxml2-devel; \
cd /tmp && git clone --branch "v${LIBCIMPP_VERSION}" --recurse-submodules --depth 1 https://github.com/sogno-platform/libcimpp.git && \
mkdir -p libcimpp/build && cd libcimpp/build && \
cmake ${CMAKE_OPTS} .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_LIBDIR=/usr/local/lib64 && \
make ${MAKE_OPTS} install && \
rm -rf /tmp/libcimpp; \
fi; \
else \
cd /tmp && git clone --branch "release/v${LIBCIMPP_VERSION}" --recurse-submodules --depth 1 https://github.com/sogno-platform/libcimpp.git && \
mkdir -p libcimpp/build && cd libcimpp/build && \
cmake ${CMAKE_OPTS} .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_LIBDIR=/usr/local/lib64 \
-DUSE_CIM_VERSION=${CIM_VERSION} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_ARABICA_EXAMPLES=OFF \
-DCIMPP_BUILD_DOC=OFF && \
make ${MAKE_OPTS} install && \
cd / && rm -rf /tmp/libcimpp; \
fi; \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need for the dnf line, this is part of the base image already as i understand

libxml2-devel \
graphviz-devel \

dnf -y install /tmp/libcimpp.rpm; \
rm -f /tmp/libcimpp.rpm; \
if [ "$(uname -m)" = "x86_64" ]; then \
curl -sSL -L --max-time 300 --retry 3 --retry-delay 5 "${libcimpp_url}" -o /tmp/libcimpp.rpm || (echo "Failed to download ${libcimpp_url}" >&2; exit 1); \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

sSL never fails

Suggested change
curl -sSL -L --max-time 300 --retry 3 --retry-delay 5 "${libcimpp_url}" -o /tmp/libcimpp.rpm || (echo "Failed to download ${libcimpp_url}" >&2; exit 1); \
curl -fsSL --max-time 300 --retry 3 --retry-delay 5 "${libcimpp_url}" -o /tmp/libcimpp.rpm || (echo "Failed to download ${libcimpp_url}" >&2; exit 1); \

# Install libcimpp from prebuilt RPMs (x86_64 only) or build from source
RUN set -eux; \
case "${CIM_VERSION}" in \
CGMES_2.4.15_16FEB2016|CGMES_2.4.15_27JAN2020|CGMES_2.4.13_18DEC2013) \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

libcimpp_CGMES_3.0.0-2.2.0-Linux.rpm exists, but we have not tested in DPsim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Docker build failure on macOS (ARM64) for libcimpp

3 participants