Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ FROM ${DIST}

# Image / OCI metadata
LABEL maintainer="AnHeuermann"
LABEL description="Cross-compile C FMUs for Linux and Windows"
LABEL description="Cross-compile C and Rust FMUs for Linux and Windows"
LABEL organization="OpenModelica"

LABEL org.opencontainers.image.vendor="OpenModelica"
LABEL org.opencontainers.image.authors="AnHeuermann"
LABEL org.opencontainers.image.description="Cross-compile C FMUs for Linux and Windows"
LABEL org.opencontainers.image.description="Cross-compile C and Rust FMUs for Linux and Windows"
LABEL org.opencontainers.image.source="https://github.com/OpenModelica/openmodelica-crossbuild/"
LABEL org.opencontainers.image.license="AGPL VERSION 3 OR OSMC-PL VERSION 1.8"

# Copy toolchain files
COPY toolchain/ /opt/cmake/toolchain/

# enable universe if needed (on official Ubuntu bases)
RUN apt-get update && \
apt-get install -y --no-install-recommends software-properties-common && \
Expand All @@ -41,3 +38,33 @@ RUN apt-get update && \
unzip \
zip \
&& rm -rf /var/lib/apt/lists/*

# Rust toolchain for FMUs whose simulation runtime is Rust. World-writable like
# the official rust image, since the image is run with --user.
ENV RUSTUP_HOME=/opt/rust/rustup \
CARGO_HOME=/opt/rust/cargo \
PATH=/opt/rust/cargo/bin:$PATH \
RUST_VERSION=1.98.1 \
RUSTUP_VERSION=1.29.1 \
RUSTUP_SHA256=dda7234360b7f578ca8b0ddcb80145646fa61a67c1720a5abc7051b35c9fcb71

RUN curl -sSfL -o /tmp/rustup-init \
"https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/x86_64-unknown-linux-gnu/rustup-init" && \
echo "${RUSTUP_SHA256} */tmp/rustup-init" | sha256sum -c - && \
chmod +x /tmp/rustup-init && \
/tmp/rustup-init -y --no-modify-path --profile minimal \
--default-toolchain ${RUST_VERSION} --default-host x86_64-unknown-linux-gnu \
--target i686-unknown-linux-gnu,aarch64-unknown-linux-gnu,armv5te-unknown-linux-gnueabi,armv7-unknown-linux-gnueabihf,i686-pc-windows-gnu,x86_64-pc-windows-gnu && \
rm /tmp/rustup-init && \
chmod -R a+w ${RUSTUP_HOME} ${CARGO_HOME} && \
cargo --version && rustc --version

ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CARGO_TARGET_ARMV5TE_UNKNOWN_LINUX_GNUEABI_LINKER=arm-linux-gnueabi-gcc \
CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
CARGO_TARGET_I686_PC_WINDOWS_GNU_LINKER=i686-w64-mingw32-gcc \
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc

# Copy toolchain files
COPY toolchain/ /opt/cmake/toolchain/
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ platforms and create multi-platform FMUs.

## Toolchains

| Toolchain file | OS | C | Note |
|--------------------------------------------|-----------------------|-------------------------|------------|
| [i686-linux-gnu][i686-linux-gnu] | x86-64 Linux 32-bit | i686-linux-gnu-gcc | |
| [x86_64-linux-gnu][x86_64-linux-gnu] | x86-64 Linux 64-bit | gcc -m64 | |
| [aarch64-linux-gnu][aarch64-linux-gnu] | AArch64 Linux 64-bit | aarch64-linux-gnu-gcc | |
| [arm-linux-gnueabi][arm-linux-gnueabi] | ARM Linux 32-bit | arm-linux-gnueabi-gcc | |
| [arm-linux-gnueabihf][arm-linux-gnueabihf] | ARM Linux 32-bit | arm-linux-gnueabihf-gcc | hard-float |
| [i686-w64-mingw32][i686-w64-mingw32] | x86-64 Windows 32-bit | i686-w64-mingw32-gcc | MINGW |
| [x86_64-w64-mingw32][x86_64-w64-mingw32] | x86-64 Windows 64-bit | x86_64-w64-mingw32-gcc | MINGW |
| Toolchain file | OS | C | Rust | Note |
|--------------------------------------------|-----------------------|-------------------------|-------------------------------|------------|
| [i686-linux-gnu][i686-linux-gnu] | x86-64 Linux 32-bit | i686-linux-gnu-gcc | i686-unknown-linux-gnu | |
| [x86_64-linux-gnu][x86_64-linux-gnu] | x86-64 Linux 64-bit | gcc -m64 | x86_64-unknown-linux-gnu | |
| [aarch64-linux-gnu][aarch64-linux-gnu] | AArch64 Linux 64-bit | aarch64-linux-gnu-gcc | aarch64-unknown-linux-gnu | |
| [arm-linux-gnueabi][arm-linux-gnueabi] | ARM Linux 32-bit | arm-linux-gnueabi-gcc | armv5te-unknown-linux-gnueabi | |
| [arm-linux-gnueabihf][arm-linux-gnueabihf] | ARM Linux 32-bit | arm-linux-gnueabihf-gcc | armv7-unknown-linux-gnueabihf | hard-float |
| [i686-w64-mingw32][i686-w64-mingw32] | x86-64 Windows 32-bit | i686-w64-mingw32-gcc | i686-pc-windows-gnu | MINGW |
| [x86_64-w64-mingw32][x86_64-w64-mingw32] | x86-64 Windows 64-bit | x86_64-w64-mingw32-gcc | x86_64-pc-windows-gnu | MINGW |

The image ships a stable Rust toolchain with these targets, since the FMUs of
OpenModelica 1.28.0 and later link a Rust simulation runtime. Each toolchain
file sets `OM_RUST_TARGET_TRIPLE`, which the FMU's CMake passes on to
`cargo --target`, and the image sets the matching `CARGO_TARGET_<triple>_LINKER`.

## Versioning

Expand All @@ -27,7 +32,7 @@ OpenModelica. So OpenModelica `v1.26.0` expects to use this image with tag
## Build

```bash
export TAG=v1.26.0
export TAG=v1.28.0
docker build --pull --no-cache --tag crossbuild:$TAG .
```

Expand Down Expand Up @@ -97,7 +102,7 @@ You can use `cosign` to verify the keyless signature from
branch images such as `main` are not.

```bash
export TAG=v1.27.0
export TAG=v1.28.0
cosign verify ghcr.io/openmodelica/crossbuild:$TAG \
--certificate-identity=https://github.com/OpenModelica/openmodelica-crossbuild/.github/workflows/publish.yml@refs/tags/$TAG \
--certificate-oidc-issuer=https://token.actions.githubusercontent.com
Expand Down
2 changes: 2 additions & 0 deletions toolchain/aarch64-linux-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ set(CMAKE_FIND_ROOT_PATH /usr /usr/aarch64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(OM_RUST_TARGET_TRIPLE aarch64-unknown-linux-gnu CACHE STRING "Rust target triple")
2 changes: 2 additions & 0 deletions toolchain/arm-linux-gnueabi.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ set(CMAKE_FIND_ROOT_PATH /usr /usr/arm-linux-gnueabi)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(OM_RUST_TARGET_TRIPLE armv5te-unknown-linux-gnueabi CACHE STRING "Rust target triple")
2 changes: 2 additions & 0 deletions toolchain/arm-linux-gnueabihf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ set(CMAKE_FIND_ROOT_PATH /usr /usr/arm-linux-gnueabihf)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(OM_RUST_TARGET_TRIPLE armv7-unknown-linux-gnueabihf CACHE STRING "Rust target triple")
2 changes: 2 additions & 0 deletions toolchain/i686-linux-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ set(CMAKE_FIND_ROOT_PATH /usr /usr/lib/i386-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(OM_RUST_TARGET_TRIPLE i686-unknown-linux-gnu CACHE STRING "Rust target triple")
2 changes: 2 additions & 0 deletions toolchain/i686-w64-mingw32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(OM_RUST_TARGET_TRIPLE i686-pc-windows-gnu CACHE STRING "Rust target triple")
2 changes: 2 additions & 0 deletions toolchain/x86_64-linux-gnu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ set(CMAKE_FIND_ROOT_PATH /usr /usr/lib/x86_64-linux-gnu)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(OM_RUST_TARGET_TRIPLE x86_64-unknown-linux-gnu CACHE STRING "Rust target triple")
2 changes: 2 additions & 0 deletions toolchain/x86_64-w64-mingw32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

set(OM_RUST_TARGET_TRIPLE x86_64-pc-windows-gnu CACHE STRING "Rust target triple")
Loading