From 54d3919278f13dab6ed72c503dc11c2aace5c688 Mon Sep 17 00:00:00 2001 From: Gowtham Suresh Kumar Date: Wed, 19 Jul 2023 22:05:51 +0100 Subject: [PATCH 1/3] Add earliest and latest compilers This commit updates the Ubuntu 16.04 dockerfile to include the earliest versions of GCC (4.7) and Clang (3.5) available in 16.04. For Ubuntu 22.04 the latest compiler versions of GCC (12) and Clang (16) are installed. Also creates couple of symlinks of those compilers for simplified usage in the all.sh. Signed-off-by: Gowtham Suresh Kumar --- resources/docker_files/ubuntu-16.04/Dockerfile | 9 ++++++++- resources/docker_files/ubuntu-22.04/Dockerfile | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/resources/docker_files/ubuntu-16.04/Dockerfile b/resources/docker_files/ubuntu-16.04/Dockerfile index 9ff83d835..29fa35178 100644 --- a/resources/docker_files/ubuntu-16.04/Dockerfile +++ b/resources/docker_files/ubuntu-16.04/Dockerfile @@ -48,10 +48,14 @@ RUN apt-get update -q && apt-get install -yq \ autotools-dev \ # to build Mbed TLS: gcc, binutils, make, etc. build-essential \ + # to build Mbed TLS using earliest gcc version + gcc-4.7 \ # to generate malformed files bsdmainutils \ # to build Mbed TLS clang \ + # to build Mbed TLS using earliest clang version + clang-3.5 \ # to build Mbed TLS cmake \ # to build Mbed TLS's documentation @@ -112,7 +116,10 @@ RUN apt-get update -q && apt-get install -yq \ libstdc++6:armhf \ ;; \ esac && \ - rm -rf /var/lib/apt/lists/ + rm -rf /var/lib/apt/lists/ && \ + # create symbolic links for earliest gcc and clang versions + ln -s /usr/bin/gcc-4.7 /usr/local/bin/gcc-earliest && \ + ln -s /usr/bin/clang-3.5 /usr/local/bin/clang-earliest # Install all the parts of gcc-multilib, which is necessary for 32-bit builds. # gcc-multilib conflicts with cross-compiler packages that we'll install later, diff --git a/resources/docker_files/ubuntu-22.04/Dockerfile b/resources/docker_files/ubuntu-22.04/Dockerfile index 3ed3f47b9..6c0bcbebd 100644 --- a/resources/docker_files/ubuntu-22.04/Dockerfile +++ b/resources/docker_files/ubuntu-22.04/Dockerfile @@ -100,6 +100,10 @@ RUN apt-get update -q && apt-get install -yq \ zlib1g \ # to build Mbed TLS with MBEDTLS_ZILIB_SUPPORT (removed in 3.0) zlib1g-dev \ + # to build Mbed TLS using latest gcc version available from Ubuntu + gcc-12 \ + # provides some useful scripts for adding and removing repositories + software-properties-common \ && case "$(uname -m)" in \ # x86_64 only packages x86_64) apt-get install -yq \ @@ -118,7 +122,18 @@ RUN apt-get update -q && apt-get install -yq \ libstdc++6:armhf \ ;; \ esac && \ - rm -rf /var/lib/apt/lists/ + rm -rf /var/lib/apt/lists/ + +# For installing clang-16, we add the llvm package source and add corresponding key +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 15CF4D18AF4F7421 \ + # add an apt package source from https://apt.llvm.org/ + && add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' -y \ + && apt-get install -yq \ + # to build Mbed TLS using latest clang version at the time of writing + clang-16 && \ + # create symbolic links for latest gcc and clang versions + ln -s /usr/bin/clang-16 /usr/local/bin/clang-latest && \ + ln -s /usr/bin/gcc-12 /usr/local/bin/gcc-latest # Install all the parts of gcc-multilib, which is necessary for 32-bit builds. # gcc-multilib conflicts with cross-compiler packages that we'll install later, From 2c78a195f0e7ddb9b7aef3ce16237162849e12ec Mon Sep 17 00:00:00 2001 From: Gowtham Suresh Kumar Date: Tue, 25 Jul 2023 13:07:44 +0100 Subject: [PATCH 2/3] Update path in README Signed-off-by: Gowtham Suresh Kumar --- resources/docker_files/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/docker_files/README.md b/resources/docker_files/README.md index 63bae0982..af2e6b5a1 100644 --- a/resources/docker_files/README.md +++ b/resources/docker_files/README.md @@ -17,7 +17,7 @@ See the [Quick Start section of the top-level README](../../README.md#quick-star A docker image can be built with following command: ```sh -cd mbedtls-test/dev_envs/docker_files +cd mbedtls-test/resources/docker_files sudo docker build --network=host -t ubuntu-18.04 -f ubuntu-18.04/Dockerfile . ``` This creates an image from the specified file. The built image is maintained by docker in its own workspace on the host. Don't worry where the built image is gone! From this point the built image is referred by its tag name. For example `ubuntu-18.04`. See [Listing images](#listing-images) below. From 5bcad04d54d9efed0aa2fd17f9c845c883bde2bd Mon Sep 17 00:00:00 2001 From: Gowtham Suresh Kumar Date: Thu, 27 Jul 2023 14:36:12 +0100 Subject: [PATCH 3/3] Fix indentation and minor issues Signed-off-by: Gowtham Suresh Kumar --- .../docker_files/ubuntu-22.04/Dockerfile | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/resources/docker_files/ubuntu-22.04/Dockerfile b/resources/docker_files/ubuntu-22.04/Dockerfile index 6c0bcbebd..c1f7b7c44 100644 --- a/resources/docker_files/ubuntu-22.04/Dockerfile +++ b/resources/docker_files/ubuntu-22.04/Dockerfile @@ -66,6 +66,8 @@ RUN apt-get update -q && apt-get install -yq \ faketime \ # to cross-build Mbed TLS gcc-mingw-w64-i686 \ + # to build Mbed TLS using latest gcc version available from Ubuntu + gcc-12 \ # to check out Mbed TLS and others git \ # to build Mbed TLS's documentation @@ -90,6 +92,8 @@ RUN apt-get update -q && apt-get install -yq \ pkg-config \ # to install Python packages python3-pip \ + # provides some useful scripts for adding and removing repositories + software-properties-common \ # for Mbed TLS tests valgrind \ # to download things installed from other places @@ -100,10 +104,6 @@ RUN apt-get update -q && apt-get install -yq \ zlib1g \ # to build Mbed TLS with MBEDTLS_ZILIB_SUPPORT (removed in 3.0) zlib1g-dev \ - # to build Mbed TLS using latest gcc version available from Ubuntu - gcc-12 \ - # provides some useful scripts for adding and removing repositories - software-properties-common \ && case "$(uname -m)" in \ # x86_64 only packages x86_64) apt-get install -yq \ @@ -125,15 +125,15 @@ RUN apt-get update -q && apt-get install -yq \ rm -rf /var/lib/apt/lists/ # For installing clang-16, we add the llvm package source and add corresponding key -RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 15CF4D18AF4F7421 \ - # add an apt package source from https://apt.llvm.org/ - && add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' -y \ - && apt-get install -yq \ +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 15CF4D18AF4F7421 && \ + # add an apt package source from https://apt.llvm.org/ + add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' -y && \ + apt-get install -yq \ # to build Mbed TLS using latest clang version at the time of writing clang-16 && \ - # create symbolic links for latest gcc and clang versions - ln -s /usr/bin/clang-16 /usr/local/bin/clang-latest && \ - ln -s /usr/bin/gcc-12 /usr/local/bin/gcc-latest + # create symbolic links for latest gcc and clang versions + ln -s /usr/bin/clang-16 /usr/local/bin/clang-latest && \ + ln -s /usr/bin/gcc-12 /usr/local/bin/gcc-latest # Install all the parts of gcc-multilib, which is necessary for 32-bit builds. # gcc-multilib conflicts with cross-compiler packages that we'll install later,