From 4b8a5f90048421c245e6fc3e46182d5b3ee37e6f Mon Sep 17 00:00:00 2001 From: michalpasztamobica Date: Thu, 6 May 2021 10:19:41 +0200 Subject: [PATCH 1/2] Prepare llvm and clang for ARM64 build of Flang Run a Dockerfile on a self-hosted ARM64 runner to prepare a docker image with llvm and clang built and installed for Flang ARM64 to use when testing code. --- .github/workflows/Ubuntu20Dockerfile | 64 +++++++++++++++++++ .../build_push_docker_image_Ubuntu20.yml | 58 +++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 .github/workflows/Ubuntu20Dockerfile create mode 100644 .github/workflows/build_push_docker_image_Ubuntu20.yml diff --git a/.github/workflows/Ubuntu20Dockerfile b/.github/workflows/Ubuntu20Dockerfile new file mode 100644 index 000000000000..7f3508ff8515 --- /dev/null +++ b/.github/workflows/Ubuntu20Dockerfile @@ -0,0 +1,64 @@ +FROM ubuntu:20.04 + +ARG DEBIAN_FRONTEND=noninteractive +ENV TZ=Europe/London +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y \ + curl \ + gcc \ + g++ \ + make \ + htop \ + jq \ + ninja-build \ + tmux \ + git \ + wget \ + patch \ + python3-minimal \ + python-is-python3 \ + libdata-dumper-simple-perl \ + unzip + +RUN apt-get install -y software-properties-common && \ + apt-get update && \ + add-apt-repository ppa:ubuntu-toolchain-r/test && \ + apt-get install -f -y gcc-9 g++-9 && \ + apt-get install -f -y gcc-10 g++-10 && \ + echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | tee -a /etc/apt/sources.list.d/llvm.list && \ + echo 'deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | tee -a /etc/apt/sources.list.d/llvm.list && \ + wget -q -O - http://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \ + apt-get update && \ + apt-get install -f -y llvm-9 clang-9 && \ + apt-get install -f -y llvm-10 clang-10 && \ + apt-get install -f -y llvm-11 clang-11 + +RUN cd /opt && \ + wget https://github.com/Kitware/CMake/releases/download/v3.20.0/cmake-3.20.0-linux-aarch64.sh && \ + /bin/sh cmake-3.20.0-linux-aarch64.sh --skip-license --include-subdir && \ + ln -s /opt/cmake-3.20.0-linux-aarch64/bin/* /usr/local/bin + +RUN ln -s /usr/bin/ninja-build /usr/local/bin/ninja + +RUN mkdir /home/github/ + +RUN mkdir /home/root && cd home/root && \ + git clone --depth 1 --single-branch --branch release_11x https://github.com/flang-compiler/classic-flang-llvm-project.git classic-flang-llvm-project && \ + cd classic-flang-llvm-project && \ + mkdir -p build && cd build && \ + cmake -DLLVM_TARGETS_TO_BUILD=AArch64 \ + -DCMAKE_INSTALL_PREFIX=/home/github/usr/local \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=/usr/bin/gcc-10 \ + -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \ + -DLLVM_ENABLE_PROJECTS="clang;openmp" \ + -DLLVM_ENABLE_CLASSIC_FLANG=ON \ + ../llvm && \ + make -j`nproc --ignore=1` && \ + make install && \ + make clean + +RUN useradd github && \ + chown -R github:github /home/github +USER github diff --git a/.github/workflows/build_push_docker_image_Ubuntu20.yml b/.github/workflows/build_push_docker_image_Ubuntu20.yml new file mode 100644 index 000000000000..0066ed74cde0 --- /dev/null +++ b/.github/workflows/build_push_docker_image_Ubuntu20.yml @@ -0,0 +1,58 @@ +name: Ubuntu20 Dockerfile image + +on: + push: + branches: [ release_11x, release_12x ] + paths-include: + - '**/.github/workflows/build_push_docker_image_Ubuntu20.yml' + - '**/.github/workflows/Ubuntu20Dockerfile.yml' + +jobs: + docker: + runs-on: self-hosted + steps: + - name: Extract branch name + run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}" + id: extract_branch + + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Log in + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v2 + with: + file: .github/workflows/Ubuntu20Dockerfile + push: true + context: .github/workflows + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + tags: ghcr.io/${{ github.repository_owner }}/ubuntu20-flang-${{ steps.extract_branch.outputs.branch }}:latest + platforms: linux/arm64 + + # This ugly bit is necessary if you don't want your cache to grow forever + # till it hits GitHub's limit of 5GB. + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache From 9bc55986e2f11936d6aaecc36e5a94efca93714f Mon Sep 17 00:00:00 2001 From: michalpasztamobica Date: Tue, 18 May 2021 17:22:13 +0200 Subject: [PATCH 2/2] [CI] apt update -y to accept new gpg keys. --- .github/workflows/flang-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/flang-tests.yml b/.github/workflows/flang-tests.yml index ebab7b63a95e..f0dd2a6462d0 100644 --- a/.github/workflows/flang-tests.yml +++ b/.github/workflows/flang-tests.yml @@ -31,7 +31,7 @@ jobs: echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | sudo tee -a /etc/apt/sources.list.d/llvm.list echo 'deb-src http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main' | sudo tee -a /etc/apt/sources.list.d/llvm.list wget -q -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - - sudo apt update + sudo apt update -y sudo apt install -f -y llvm-${{ matrix.version }} clang-${{ matrix.version}} - if: matrix.cc == 'gcc' && matrix.version == '10'