From 6c28067357300beb02da9ae437e122dedaa8e820 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Tue, 14 Oct 2025 15:57:39 +0000 Subject: [PATCH 1/5] feature: make cpp-sysroot image slimmer --- .env | 4 ++-- .github/workflows/tests.yml | 2 +- VERSION | 2 +- docker/cpp-sysroot.dockerfile | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.env b/.env index 97bd499..fb0179c 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -SYSROOT_VERSION=0.7.0 -SYSROOT_CLI_IMAGE=ghcr.io/faasm/cpp-sysroot:0.7.0 +SYSROOT_VERSION=0.8.0 +SYSROOT_CLI_IMAGE=ghcr.io/faasm/cpp-sysroot:0.8.0 COMPOSE_PROJECT_NAME=cpp-dev diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 204bf88..aa964be 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,7 +17,7 @@ jobs: if: github.event.pull_request.draft == false runs-on: ubuntu-latest container: - image: ghcr.io/faasm/cpp-sysroot:0.7.0 + image: ghcr.io/faasm/cpp-sysroot:0.8.0 steps: # --- Update code --- - name: "Checkout code" diff --git a/VERSION b/VERSION index faef31a..a3df0a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.7.0 +0.8.0 diff --git a/docker/cpp-sysroot.dockerfile b/docker/cpp-sysroot.dockerfile index f6c9b6c..0e0814d 100644 --- a/docker/cpp-sysroot.dockerfile +++ b/docker/cpp-sysroot.dockerfile @@ -2,13 +2,13 @@ FROM ghcr.io/faasm/llvm:0.7.0 AS llvm # faabric-base image is not re-built often, so tag may be behind -FROM ghcr.io/faasm/faabric-base:0.21.0 +FROM ghcr.io/faasm/faabric-base:0.22.0 SHELL ["/bin/bash", "-c"] ENV CPP_DOCKER="on" # Copy the toolchain and LLVM sources from the LLVM container COPY --from=llvm /usr/local/faasm /usr/local/faasm -COPY --from=llvm /opt/llvm-project /opt/llvm-project +# COPY --from=llvm /opt/llvm-project /opt/llvm-project # Update APT dependencies RUN apt update && apt install -y autotools-dev From 44b63176bbc890f1a7f57aed13e53251383db493 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Tue, 14 Oct 2025 16:44:44 +0000 Subject: [PATCH 2/5] feat(docker): base from ubuntu 24.04 --- docker/cpp-sysroot.dockerfile | 47 +++++++++++++++++++++++++++-------- libfaasmp/CMakeLists.txt | 1 - 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/docker/cpp-sysroot.dockerfile b/docker/cpp-sysroot.dockerfile index 0e0814d..900f24e 100644 --- a/docker/cpp-sysroot.dockerfile +++ b/docker/cpp-sysroot.dockerfile @@ -1,17 +1,41 @@ # llvm image is not re-built often, so the tag may be behind FROM ghcr.io/faasm/llvm:0.7.0 AS llvm -# faabric-base image is not re-built often, so tag may be behind -FROM ghcr.io/faasm/faabric-base:0.22.0 +# Start from a fresh ubuntu image, cpp-sysroot has little built deps. +FROM ubuntu:24.04 + +RUN set -eux; \ + apt update; \ + apt install -y --no-install-recommends \ + autoconf \ + automake \ + autopoint \ + autotools-dev \ + clang-17 \ + cmake \ + gettext \ + libtool \ + llvm-17 \ + m4 \ + ninja-build \ + make \ + pkg-config \ + python3-pip \ + python3-venv \ + git \ + vim-tiny; \ + apt autoremove -y; \ + apt clean; rm -rf /var/lib/apt/lists/* + SHELL ["/bin/bash", "-c"] ENV CPP_DOCKER="on" -# Copy the toolchain and LLVM sources from the LLVM container +# Copy the toolchain and LLVM OpenMP sources necessary to build libfaasmp COPY --from=llvm /usr/local/faasm /usr/local/faasm -# COPY --from=llvm /opt/llvm-project /opt/llvm-project +COPY --from=llvm \ + /opt/llvm-project/build/llvm/projects/openmp/runtime/src \ + /opt/llvm-project/build/llvm/projects/openmp/runtime/src -# Update APT dependencies -RUN apt update && apt install -y autotools-dev # Get the code and submodules ARG SYSROOT_VERSION RUN mkdir -p /code \ @@ -42,9 +66,6 @@ RUN cd /code/cpp \ libfaasmpi --native --shared \ # Install toolchain files && inv install \ - # Build wasi-libc and reset the sysroot. The second call to LLVM just - # installs some headers that are purged - && inv llvm.libc --purge llvm \ # Build Faasm WASM libraries for wasm32-wasi target && inv \ libfaasm \ @@ -55,12 +76,16 @@ RUN cd /code/cpp \ libfaasm --threads \ libemscripten --threads \ libfaasmp \ - # Lastly, build the libraries that populate the sysroot + # Lastly, build the libraries that populate the sysroot. For some reason + # we need to re-run apt update for libtool to work properly. + && apt update \ && inv \ libffi \ libffi --threads \ zlib \ - zlib --threads + zlib --threads \ + && apt autoremove -y \ + && apt clean; rm -rf /var/lib/apt/lists/* # CLI setup WORKDIR /code/cpp diff --git a/libfaasmp/CMakeLists.txt b/libfaasmp/CMakeLists.txt index 3b251b1..239a03b 100644 --- a/libfaasmp/CMakeLists.txt +++ b/libfaasmp/CMakeLists.txt @@ -16,7 +16,6 @@ set(LIB_FILES if (CMAKE_SYSTEM_NAME STREQUAL "WASI") message(STATUS "Libfaasmp WebAssembly build") - set(LLVM_OMP_SRC_DIR "/opt/llvm-project/openmp/runtime/src") set(LLVM_OMP_BUILD_SRC_DIR "/opt/llvm-project/build/llvm/projects/openmp/runtime/src") set(LIBOMP_ASMFILES "z_Linux_asm.S") set(LIBOMP_HEADERS "${LLVM_OMP_BUILD_SRC_DIR}/omp.h") From 0aa1e96873095303e968aed39a7850926867f800 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Wed, 15 Oct 2025 08:25:44 +0000 Subject: [PATCH 3/5] fix(ci): add apt update before libffi --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa964be..ac32d8f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,7 +37,10 @@ jobs: - name: "Build libfaasmpi" run: ./bin/inv_wrapper.sh libfaasmpi - name: "Build libffi" - run: ./bin/inv_wrapper.sh libffi + run: | + # For some reason, libffi necessitates running apt update. + apt update + ./bin/inv_wrapper.sh libffi - name: "Build libfake" run: ./bin/inv_wrapper.sh libfake - name: "Build libemscripten" From 91a49c2a36cad39ffa91d875dd9b7a2be6281c94 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Wed, 15 Oct 2025 09:54:50 +0000 Subject: [PATCH 4/5] fix(ffi): install missing package --- .github/workflows/tests.yml | 5 +---- docker/cpp-sysroot.dockerfile | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ac32d8f..aa964be 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,10 +37,7 @@ jobs: - name: "Build libfaasmpi" run: ./bin/inv_wrapper.sh libfaasmpi - name: "Build libffi" - run: | - # For some reason, libffi necessitates running apt update. - apt update - ./bin/inv_wrapper.sh libffi + run: ./bin/inv_wrapper.sh libffi - name: "Build libfake" run: ./bin/inv_wrapper.sh libfake - name: "Build libemscripten" diff --git a/docker/cpp-sysroot.dockerfile b/docker/cpp-sysroot.dockerfile index 900f24e..daa5308 100644 --- a/docker/cpp-sysroot.dockerfile +++ b/docker/cpp-sysroot.dockerfile @@ -4,28 +4,30 @@ FROM ghcr.io/faasm/llvm:0.7.0 AS llvm # Start from a fresh ubuntu image, cpp-sysroot has little built deps. FROM ubuntu:24.04 -RUN set -eux; \ - apt update; \ - apt install -y --no-install-recommends \ +RUN apt update \ + && apt install -y --no-install-recommends \ autoconf \ automake \ autopoint \ autotools-dev \ clang-17 \ cmake \ + dpkg-dev \ + gawk \ gettext \ + git \ + libltdl-dev \ libtool \ llvm-17 \ + make \ m4 \ ninja-build \ - make \ pkg-config \ python3-pip \ python3-venv \ - git \ - vim-tiny; \ - apt autoremove -y; \ - apt clean; rm -rf /var/lib/apt/lists/* + vim-tiny \ + && apt autoremove \ + && rm -rf /var/lib/apt/lists/* SHELL ["/bin/bash", "-c"] ENV CPP_DOCKER="on" @@ -76,16 +78,12 @@ RUN cd /code/cpp \ libfaasm --threads \ libemscripten --threads \ libfaasmp \ - # Lastly, build the libraries that populate the sysroot. For some reason - # we need to re-run apt update for libtool to work properly. - && apt update \ + # Lastly, build the libraries that populate the sysroot && inv \ libffi \ libffi --threads \ zlib \ - zlib --threads \ - && apt autoremove -y \ - && apt clean; rm -rf /var/lib/apt/lists/* + zlib --threads # CLI setup WORKDIR /code/cpp From dc299efdf7aceef2339a2758277edb89e93a5f13 Mon Sep 17 00:00:00 2001 From: Carlos Segarra Date: Wed, 15 Oct 2025 10:08:22 +0000 Subject: [PATCH 5/5] fix(docker): add clang-format-17 --- docker/cpp-sysroot.dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/cpp-sysroot.dockerfile b/docker/cpp-sysroot.dockerfile index daa5308..7298909 100644 --- a/docker/cpp-sysroot.dockerfile +++ b/docker/cpp-sysroot.dockerfile @@ -11,6 +11,7 @@ RUN apt update \ autopoint \ autotools-dev \ clang-17 \ + clang-format-17 \ cmake \ dpkg-dev \ gawk \