From cf5f2cea4d17a8d93d8d6a2084431ebc315ae904 Mon Sep 17 00:00:00 2001 From: Jonas Meeuws Date: Wed, 7 Aug 2024 21:46:29 +0200 Subject: [PATCH] Add llvm-xtensa and ldc-xtensa images --- definitions/containerfiles.ini | 10 ++++ .../ldc-xtensa/ldc-xtensa-image.containerfile | 57 +++++++++++++++++++ .../download-llvm-xtensa-source.containerfile | 7 +++ .../llvm-xtensa-image.containerfile | 29 ++++++++++ templates/llvm/build-llvm.containerfile | 3 + 5 files changed, 106 insertions(+) create mode 100644 templates/ldc-xtensa/ldc-xtensa-image.containerfile create mode 100644 templates/llvm-xtensa/download-llvm-xtensa-source.containerfile create mode 100644 templates/llvm-xtensa/llvm-xtensa-image.containerfile diff --git a/definitions/containerfiles.ini b/definitions/containerfiles.ini index 9e00e12..afa3d73 100644 --- a/definitions/containerfiles.ini +++ b/definitions/containerfiles.ini @@ -528,3 +528,13 @@ level = false [llvm:18.1.8] level = false + +[ldc-xtensa:1.39.0] +level = 2.109.1 +dependencies[] = llvm-xtensa:16.0 +dependencies[] = ldc:1.20 +extras[dub] = 1.38.0 + +[llvm-xtensa:16.0.4] +level = false +env[GIT_TAG] = esp-16.0.4-20231113 diff --git a/templates/ldc-xtensa/ldc-xtensa-image.containerfile b/templates/ldc-xtensa/ldc-xtensa-image.containerfile new file mode 100644 index 0000000..4037ffb --- /dev/null +++ b/templates/ldc-xtensa/ldc-xtensa-image.containerfile @@ -0,0 +1,57 @@ +{{< ldc/ldc-variables.php }} +################### +# imported images # +################### + +FROM {{ $container_namespace }}/llvm-xtensa:{{ $dependencies['llvm-xtensa'] }}-{{ $base_image_alias }} AS llvm-imported +{{# if ($isBootstrappedByLDC): }} + FROM {{ $container_namespace }}/ldc:{{ $dependencies['ldc'] }}-{{ $base_image_alias }} AS ldc-bootstrap-imported +{{# endif }} + +############### +# build stage # +############### + +{{< ldc/ldc-image-build-stage.containerfile }} + +{{# if ($isBootstrappedByLDC): }} + + ################## + # self bootstrap # + ################## + + {{< ldc/ldc-image-build-stage.containerfile }} +{{# endif }} + +{{< common/make-dub.containerfile }} + +{{< common/make-d-tools.containerfile }} + +################ +# export stage # +################ + +{{# $buildStage = "build-stage-{$buildStageCounter}"; }} +FROM {{ $base_image }} AS export-stage + +{{< common/prepare-runtime-environment.containerfile }} + +COPY --from={{ $buildStage }} /opt/ldc /opt/ldc + +{{< d-tools/install-d-tools.containerfile }} + +# Self-test +COPY ./resources/helloworld.d /opt/helloworld.d +RUN /opt/ldc/bin/ldmd2 -run /opt/helloworld.d +RUN rm /opt/helloworld.d + +{{# if (isset($extras['dub'])): }} + COPY --from={{ $buildStage }} /opt/build/dub/bin/dub /usr/bin/dub +{{# endif }} + +{{< d-tools/install-d-tools.containerfile }} + +COPY ./templates/scripts/entrypoint-ldc.sh /usr/bin/entrypoint + +ENTRYPOINT [ "/usr/bin/entrypoint" ] +CMD [ "/opt/ldc/bin/ldc2" ] diff --git a/templates/llvm-xtensa/download-llvm-xtensa-source.containerfile b/templates/llvm-xtensa/download-llvm-xtensa-source.containerfile new file mode 100644 index 0000000..e6875aa --- /dev/null +++ b/templates/llvm-xtensa/download-llvm-xtensa-source.containerfile @@ -0,0 +1,7 @@ +## Download LLVM source + +{{# if (!isset($GIT_TAG)): }} + !!! Error: $GIT_TAG is not set !!! +{{# else: }} + RUN curl -fLsSo llvm.tar.gz "https://github.com/espressif/llvm-project/archive/refs/tags/{{ $GIT_TAG }}.tar.gz" +{{# endif }} diff --git a/templates/llvm-xtensa/llvm-xtensa-image.containerfile b/templates/llvm-xtensa/llvm-xtensa-image.containerfile new file mode 100644 index 0000000..fe8350f --- /dev/null +++ b/templates/llvm-xtensa/llvm-xtensa-image.containerfile @@ -0,0 +1,29 @@ + + +############### +# build stage # +############### + +FROM {{ $base_image }} AS build-stage + +WORKDIR /opt/build + +# Install dependencies +{{< common/install-common-system-tools.containerfile }} +{{< llvm/install-llvm-build-deps.containerfile }} + +# Download, build and install LLVM +{{< llvm-xtensa/download-llvm-xtensa-source.containerfile }} +{{< llvm/build-llvm.containerfile }} + +################ +# export stage # +################ + +FROM {{ $base_image }} AS export-stage + +COPY --from=build-stage /opt/llvm/ /opt/llvm/ + +CMD ["echo", "This image is not meant to be run. It only provides files located in /opt/llvm."] diff --git a/templates/llvm/build-llvm.containerfile b/templates/llvm/build-llvm.containerfile index 514c81f..4820f81 100755 --- a/templates/llvm/build-llvm.containerfile +++ b/templates/llvm/build-llvm.containerfile @@ -21,6 +21,9 @@ RUN cmake \ {{# if ($semver->major >= 12): }} -DLLVM_ENABLE_RUNTIMES=compiler-rt \ {{# endif }} + {{# if (isset($LLVM_EXPERIMENTAL_TARGETS_TO_BUILD)): }} + -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="{{ $LLVM_EXPERIMENTAL_TARGETS_TO_BUILD }}" \ + {{# endif }} -DCMAKE_INSTALL_PREFIX=/opt/llvm \ -DCMAKE_C_COMPILER=gcc \ -DCMAKE_CXX_COMPILER=g++ \