Skip to content

Commit

Permalink
Merge branch 'main' into compnerd/composite
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdesaulniers authored Dec 12, 2023
2 parents 4ec7473 + 2687211 commit 96c81f6
Show file tree
Hide file tree
Showing 19 changed files with 269 additions and 94 deletions.
9 changes: 9 additions & 0 deletions .github/actions/build-test-llvm-project/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ name: Build and test llvm-project
description: Build and test an llvm-project container

inputs:
arch:
description: Architecture to build containers for
required: true
build-args:
description: List of build arguments to pass along to Docker
required: false
default: NONE=none
file:
description: Dockerfile to build the container from
required: true
Expand All @@ -21,6 +28,7 @@ runs:
- name: Build llvm-project
uses: docker/build-push-action@v3
with:
build-args: ${{ inputs.build-args }}
context: ./llvm-project
file: ./llvm-project/${{ inputs.file }}
load: true
Expand All @@ -36,4 +44,5 @@ runs:
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: artifact-${{ inputs.arch }}
path: toolchain.tar.zst
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
image: [qemu]
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
Expand All @@ -37,7 +37,7 @@ jobs:

- name: Set variables
id: variables
run: echo "::set-output name=date::$(date +'%Y-%m-%d-%H-%M')"
run: echo "date=$(date +'%Y-%m-%d-%H-%M')" >> $GITHUB_OUTPUT

- name: Build
uses: docker/build-push-action@v3
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
# Runs several checks
# * shellcheck for shell script correctness
# * shfmt for shell script formatting consistency
# * yapf for Python formatting consistency
# * several linters for Python consistency and correctness

name: Lint checks
on: [push, pull_request]
jobs:
python:
strategy:
fail-fast: false
matrix:
version: ['3.11', '3.10', '3.9', '3.8']
uses: ClangBuiltLinux/actions-workflows/.github/workflows/python_lint.yml@main
with:
python_version: ${{ matrix.version }}
shellcheck:
uses: ClangBuiltLinux/actions-workflows/.github/workflows/shellcheck.yml@main
shfmt:
uses: ClangBuiltLinux/actions-workflows/.github/workflows/shfmt.yml@main
yapf:
uses: ClangBuiltLinux/actions-workflows/.github/workflows/yapf.yml@main
21 changes: 15 additions & 6 deletions .github/workflows/llvm-project-epoch-one.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@ on: workflow_dispatch
jobs:
epoch1:
name: stage 1 and 2
runs-on: [self-hosted, x64]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- arch: aarch64
os: [self-hosted, arm64]
platforms: linux/arm64
- arch: x86_64
os: [self-hosted, x64]
platforms: linux/amd64
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and test llvm-project
uses: ./.github/actions/build-test-llvm-project
with:
arch: ${{ matrix.arch }}
file: Dockerfile.epoch1
platforms: linux/amd64
tags: ghcr.io/clangbuiltlinux/llvm-project:stage2
platforms: ${{ matrix.platforms }}
tags: ghcr.io/clangbuiltlinux/llvm-project:stage2-${{ matrix.arch }}

- name: Push image to ghcr.io
uses: ./.github/actions/push-container
Expand All @@ -26,4 +35,4 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: clangbuiltlinux/llvm-project
tag: stage2
tag: stage2
22 changes: 16 additions & 6 deletions .github/workflows/llvm-project-epoch-three.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@ on: workflow_dispatch
jobs:
epoch3:
name: stage 3
runs-on: [self-hosted, x64]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- arch: aarch64
os: [self-hosted, arm64]
platforms: linux/arm64
- arch: x86_64
os: [self-hosted, x64]
platforms: linux/amd64
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and test llvm-project
uses: ./.github/actions/build-test-llvm-project
with:
arch: ${{ matrix.arch }}
build-args: BASE=ghcr.io/clangbuiltlinux/llvm-project:stage2-${{ matrix.arch }}
file: Dockerfile.epoch3
platforms: linux/amd64
tags: ghcr.io/clangbuiltlinux/llvm-project:stage3
platforms: ${{ matrix.platforms }}
tags: ghcr.io/clangbuiltlinux/llvm-project:stage3-${{ matrix.arch }}

- name: Push image to ghcr.io
uses: ./.github/actions/push-container
Expand All @@ -26,4 +36,4 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: clangbuiltlinux/llvm-project
tag: stage3
tag: stage3
22 changes: 16 additions & 6 deletions .github/workflows/llvm-project-epoch-two.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@ on: workflow_dispatch
jobs:
epoch2:
name: stage 2
runs-on: [self-hosted, x64]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
include:
- arch: aarch64
os: [self-hosted, arm64]
platforms: linux/arm64
- arch: x86_64
os: [self-hosted, x64]
platforms: linux/amd64
steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build and test llvm-project
uses: ./.github/actions/build-test-llvm-project
with:
arch: ${{ matrix.arch }}
build-args: BASE=ghcr.io/clangbuiltlinux/llvm-project:stage2-${{ matrix.arch }}
file: Dockerfile.epoch2
platforms: linux/amd64
tags: ghcr.io/clangbuiltlinux/llvm-project:stage2
platforms: ${{ matrix.platforms }}
tags: ghcr.io/clangbuiltlinux/llvm-project:stage2-${{ matrix.arch }}

- name: Push image to ghcr.io
uses: ./.github/actions/push-container
Expand All @@ -26,4 +36,4 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
image: clangbuiltlinux/llvm-project
tag: stage2
tag: stage2
15 changes: 6 additions & 9 deletions ci/install-vm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python3 # pylint: disable=invalid-name

import argparse
import os
Expand All @@ -10,8 +10,7 @@

def parse_parameters():
parser = argparse.ArgumentParser(
description=
"Install a Fedora virtual machine using libvirt and virt-install.",
description="Install a Fedora virtual machine using virt-install.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument("-c",
Expand Down Expand Up @@ -42,8 +41,7 @@ def check_requirements():
for command in ["virsh", "virt-install"]:
if not shutil.which(command):
raise RuntimeError(
"{} could not be found! Install and set up libvirt?".format(
command))
f"{command} could not be found! Install and set up libvirt?")

if not Path("/dev/kvm").exists():
raise RuntimeError(
Expand All @@ -63,20 +61,19 @@ def main():
cpu = "host"
console = "console=ttyS0"
else:
raise RuntimeError("This script does not support {}".format(host_arch))
raise RuntimeError(f"This script does not support {host_arch}")

virt_install = ["virt-install"]
virt_install += ["--boot", "uefi"]
virt_install += ["--connect", "qemu:///system"]
virt_install += ["--console", "pty,target_type=serial"]
virt_install += ["--cpu", cpu]
virt_install += ["--disk", "size={},format=qcow2".format(args.size)]
virt_install += ["--disk", f"size{args.size},format=qcow2"]
virt_install += ["--extra-args", console]
virt_install += ["--graphics", "none"]
virt_install += [
"--location",
"https://download.fedoraproject.org/pub/fedora/linux/releases/36/Server/{}/os"
.format(host_arch)
f"https://download.fedoraproject.org/pub/fedora/linux/releases/36/Server/{host_arch}/os"
]
# libvirt expects MiB; str cast here and '--vcpus' is to avoid:
# TypeError: expected str, bytes or os.PathLike object, not int
Expand Down
35 changes: 19 additions & 16 deletions ci/test-clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ toolchain=$rootdir/toolchain

# Pull toolchain out of container
echo "[+] Downloading toolchain from container"
docker create --name llvm-project "$1"
"${DOCKER:=docker}" create --name llvm-project "$1"
mkdir "$toolchain"
docker cp llvm-project:/usr/local/bin "$toolchain"
docker cp llvm-project:/usr/local/include "$toolchain"
docker cp llvm-project:/usr/local/lib "$toolchain"
"$DOCKER" cp llvm-project:/usr/local/bin "$toolchain"
"$DOCKER" cp llvm-project:/usr/local/include "$toolchain"
"$DOCKER" cp llvm-project:/usr/local/lib "$toolchain"
echo "[+] Cleaning up container"
docker rm llvm-project
"$DOCKER" rm llvm-project

# Test toolchain in Docker images so that the environment is consistent,
# regardless of runners.
Expand All @@ -27,21 +27,24 @@ docker_images=(
[[ $(uname -m) = "x86_64" ]] && docker_images+=(docker.io/archlinux:latest)
for docker_image in "${docker_images[@]}"; do
echo "[+] Updating '$docker_image'"
docker pull "$docker_image"
"$DOCKER" pull "$docker_image"
echo "[+] Testing clang in '$docker_image' container"
docker run \
"$DOCKER" run \
--rm \
--volume "$rootdir":/repo:ro \
--security-opt seccomp=unconfined \
--volume "$rootdir":/repo:ro,z \
"$docker_image" \
bash /repo/ci/test-clang-docker.sh
done

# Tar up the toolchain so it can be uploaded via GitHub Actions
echo "[+] Creating toolchain archive"
tar \
--create \
--directory "$toolchain" \
--file "$rootdir"/toolchain.tar.zst \
--verbose \
--zstd \
bin include lib
if [[ -n ${GITHUB_ACTIONS:-} ]]; then
echo "[+] Creating toolchain archive"
tar \
--create \
--directory "$toolchain" \
--file "$rootdir"/toolchain.tar.zst \
--verbose \
--zstd \
bin include lib
fi
49 changes: 49 additions & 0 deletions llvm-project/0001-libc-Fix-build-when-__FE_DENORM-is-defined.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 122da690b39a67cd6e6bce4b9ad3ac1470cc1ed5 Mon Sep 17 00:00:00 2001
From: Alex Brachet <[email protected]>
Date: Wed, 8 Jun 2022 16:21:53 +0000
Subject: [PATCH] [libc] Fix build when __FE_DENORM is defined

[nd: drop hunk that doesn't apply to 14.0.1 due to missing
commit 805899e68a83 ("[libc] Change FEnv to use MXCSR as source of truth")]

Differential revision: https://reviews.llvm.org/D127222
---
libc/src/__support/FPUtil/x86_64/FEnvImpl.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
index 846996ec93af..6bac3e9e6a0f 100644
--- a/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/x86_64/FEnvImpl.h
@@ -73,7 +73,7 @@ static inline uint16_t get_status_value_for_except(int excepts) {
// bit flags in the control registers.
return (excepts & FE_INVALID ? ExceptionFlags::INVALID : 0) |
#ifdef __FE_DENORM
- (excepts & __FE_DENORM ? ExceptionFlags::Denormal : 0) |
+ (excepts & __FE_DENORM ? ExceptionFlags::DENORMAL : 0) |
#endif // __FE_DENORM
(excepts & FE_DIVBYZERO ? ExceptionFlags::DIV_BY_ZERO : 0) |
(excepts & FE_OVERFLOW ? ExceptionFlags::OVERFLOW : 0) |
@@ -84,7 +84,7 @@ static inline uint16_t get_status_value_for_except(int excepts) {
static inline int exception_status_to_macro(uint16_t status) {
return (status & ExceptionFlags::INVALID ? FE_INVALID : 0) |
#ifdef __FE_DENORM
- (status & ExceptionFlags::Denormal ? __FE_DENORM : 0) |
+ (status & ExceptionFlags::DENORMAL ? __FE_DENORM : 0) |
#endif // __FE_DENORM
(status & ExceptionFlags::DIV_BY_ZERO ? FE_DIVBYZERO : 0) |
(status & ExceptionFlags::OVERFLOW ? FE_OVERFLOW : 0) |
@@ -273,8 +273,8 @@ static inline int raise_except(int excepts) {
if (status_value & internal::ExceptionFlags::INEXACT)
raise_helper(internal::ExceptionFlags::INEXACT);
#ifdef __FE_DENORM
- if (statusValue & internal::ExceptionFlags::Denormal) {
- raiseHelper(internal::ExceptionFlags::Denormal);
+ if (status_value & internal::ExceptionFlags::DENORMAL) {
+ raise_helper(internal::ExceptionFlags::DENORMAL);
}
#endif // __FE_DENORM

--
2.37.0.144.g8ac04bfd2-goog

10 changes: 6 additions & 4 deletions llvm-project/Dockerfile.epoch1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM alpine:edge AS source
FROM docker.io/alpine:edge AS source
RUN wget --no-clobber \
https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.1/llvm-project-14.0.1.src.tar.xz

# Stage one
FROM alpine:edge AS stage_one
FROM docker.io/alpine:edge AS stage_one

COPY --from=source llvm-project-14.0.1.src.tar.xz /
RUN tar xf llvm-project-14.0.1.src.tar.xz && \
Expand Down Expand Up @@ -43,6 +43,7 @@ ARG LLVM_BUILD_DIR=llvm-project/llvm/build
RUN cmake \
-B ${LLVM_BUILD_DIR} \
-C llvm-project/stage1.cmake \
-D LLVM_DEFAULT_TARGET_TRIPLE=$(clang -print-target-triple) \
-S llvm-project/llvm \
-G Ninja

Expand All @@ -65,7 +66,7 @@ RUN ninja -C ${LLVM_BUILD_DIR} install-llvm-ar
### START STAGE2

# STAGE2 goal, build WITHOUT apk add
FROM alpine:edge as stage_two
FROM docker.io/alpine:edge as stage_two
COPY --from=stage_one /usr/local/bin /usr/local/bin
COPY --from=stage_one /usr/local/lib /usr/local/lib
COPY --from=stage_one /usr/local/include /usr/local/include
Expand All @@ -76,7 +77,7 @@ COPY hello.c hello.cpp /
# symlinking nonsense at the start of other builds.
RUN cd /usr/lib/ && \
for library in libc++abi.so.1 libc++.a libc++abi.a libc++.so.1 libunwind.so.1 libunwind.a; \
do ln -s "/usr/local/lib/x86_64-alpine-linux-musl/${library}" . ; \
do ln -sv /usr/local/lib/$(uname -m)-alpine-linux-musl/${library} .; \
done

# The stage 1 build of clang/lld/other binaries still depends on libstdc++.
Expand Down Expand Up @@ -118,6 +119,7 @@ ARG LLVM_BUILD_DIR=llvm-project/llvm/build
RUN cmake \
-B ${LLVM_BUILD_DIR} \
-C llvm-project/stage2.cmake \
-D LLVM_DEFAULT_TARGET_TRIPLE=$(clang -print-target-triple) \
-S llvm-project/llvm \
-G Ninja

Expand Down
Loading

0 comments on commit 96c81f6

Please sign in to comment.