Files
llvm-mingw/.github/workflows/build.yml
T
Martin Storsjö 5d778657c2 github: Include libcxxabi and libunwind tests in the test-libcxx job too
These test suites now pass in the latest git main.

This target isn't run automatically anywhere, but in case the
target is enabled to run the tests, include the libcxxabi and libunwind
test suites too.
2023-04-20 10:36:19 +03:00

498 lines
18 KiB
YAML

name: Builds
on:
push:
branches:
- '**'
schedule:
- cron: '0 0 * * *'
jobs:
# For scheduled builds, get the commit ids of the latest versions to build.
#
# Doing this as one single job, which then propagates the information further
# to the other jobs, so that all build jobs in one workflow builds the exact
# same version. This allows trusting builds without assertions enabled
# slightly more, when we know a separate build of the same version but with
# assertions enabled, has passed some amount of tests.
get-versions:
if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw')
runs-on: ubuntu-latest
steps:
- name: Touch file
run: |
touch versions
- name: Check latest version
if: github.event_name == 'schedule'
run: |
echo LLVM_VERSION=$(git ls-remote https://github.com/llvm/llvm-project.git | grep 'refs/heads/main$' | awk '{print $1}') >> versions
echo MINGW_W64_VERSION=$(git ls-remote https://github.com/mingw-w64/mingw-w64.git | grep 'refs/heads/master$' | awk '{print $1}') >> versions
echo PYTHON_VERSION_MINGW=$(git ls-remote https://github.com/msys2-contrib/cpython-mingw.git | grep 'refs/heads/mingw-v3.10.5$' | awk '{print $1}') >> versions
cat versions
- uses: actions/upload-artifact@v3
with:
name: versions
path: |
versions
retention-days: 7
# Build a cross compiler for Linux, targeting Windows.
linux:
if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw')
needs: [get-versions]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
if: github.event_name == 'schedule'
with:
name: versions
- name: Set build env vars
if: github.event_name == 'schedule'
run: |
. versions
echo Building llvm-project $LLVM_VERSION mingw-w64 $MINGW_W64_VERSION
cat versions >> $GITHUB_ENV
mkdir -p install/llvm-mingw
cp versions install/llvm-mingw
- name: Build
run: |
sudo apt-get update && sudo apt-get install ninja-build
./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb
cd install
tar -Jcf ../llvm-mingw-linux.tar.xz llvm-mingw
- uses: actions/upload-artifact@v3
with:
name: linux-toolchain
path: |
llvm-mingw-linux.tar.xz
retention-days: 7
# Build a cross compiler for Linux, targeting Windows, with assertions enabled.
#
# The scheduled builds are made with the latest git version of llvm-project
# and mingw-w64. When using random git snapshot builds of llvm, there's
# always a risk for bugs - thus build such versions with assertions enabled,
# to better catch such bugs early. This makes the first-stage toolchain built
# here in scheduled builds somewhat slower.
linux-asserts:
if: (github.event_name == 'schedule') && (github.repository == 'mstorsjo/llvm-mingw')
needs: [get-versions]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
if: github.event_name == 'schedule'
with:
name: versions
- name: Set build env vars
if: github.event_name == 'schedule'
run: |
. versions
echo Building llvm-project $LLVM_VERSION mingw-w64 $MINGW_W64_VERSION, with assertions enabled
cat versions >> $GITHUB_ENV
mkdir -p install/llvm-mingw
cp versions install/llvm-mingw
- name: Build
run: |
sudo apt-get update && sudo apt-get install ninja-build
./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb --enable-asserts
cd install
tar -Jcf ../llvm-mingw-linux.tar.xz llvm-mingw
- uses: actions/upload-artifact@v3
with:
name: linux-asserts-toolchain
path: |
llvm-mingw-linux.tar.xz
retention-days: 7
# Build a cross compiler for macOS, targeting Windows.
macos:
if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw')
needs: [get-versions]
runs-on: macos-latest
steps:
- uses: actions/download-artifact@v3
if: github.event_name == 'schedule'
with:
name: versions
- name: Set build env vars
if: github.event_name == 'schedule'
run: |
. versions
echo Building llvm-project $LLVM_VERSION mingw-w64 $MINGW_W64_VERSION
cat versions >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Build
run: |
brew install ninja
# Building with MACOS_REDIST=1 (building universal binaries) without
# --disable-lldb fails in Github Actions, because python is available
# (and gets picked up), but only exists in native form.
# Disable use of zstd too - it's also available, but only in native
# form.
MACOS_REDIST=1 LLVM_CMAKEFLAGS="-DLLVM_ENABLE_ZSTD=OFF" ./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb
cd install
tar -Jcf ../llvm-mingw-macos.tar.xz llvm-mingw
- uses: actions/upload-artifact@v3
with:
name: macos-toolchain
path: |
llvm-mingw-macos.tar.xz
retention-days: 7
# Test building the toolchain on msys2 (in the mingw64 and clang64
# environments). The binaries built here rely on the runtime libraries from
# the host environment (libstdc++ or libc++). No artifacts are stored from
# these builds, but llvm-mingw's tests are run.
msys2:
if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw')
needs: [get-versions]
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
sys:
- mingw64
- clang64
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.sys}}
install: >-
git
make
diffutils
pacboy: >-
toolchain:p
cmake:p
ninja:p
- uses: actions/download-artifact@v3
if: github.event_name == 'schedule'
with:
name: versions
- name: Set build env vars
if: github.event_name == 'schedule'
run: |
. versions
echo Building llvm-project $LLVM_VERSION mingw-w64 $MINGW_W64_VERSION
cat versions >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Build
run: |
./build-all.sh $(pwd)/install/llvm-mingw --disable-clang-tools-extra --disable-lldb
./run-tests.sh $(pwd)/install/llvm-mingw
# Use the Linux cross compilers built in the first step to cross compile
# llvm and make a proper standalone toolchain for Windows (for all 4
# architectures). The binaries built here match actual releases quite closely.
linux-cross:
if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw')
needs: [linux]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- i686
- x86_64
- armv7
- aarch64
steps:
- uses: actions/download-artifact@v3
with:
name: linux-toolchain
- name: Unpack cross toolchain
run: |
tar -Jxf llvm-mingw-linux.tar.xz
rm llvm-mingw-linux.tar.xz
sudo mv llvm-mingw /opt/llvm-mingw
echo /opt/llvm-mingw/bin >> $GITHUB_PATH
- uses: actions/checkout@v3
- name: Fetch version
if: github.event_name == 'schedule'
run: |
. /opt/llvm-mingw/versions
echo Building llvm-project $LLVM_VERSION mingw-w64 $MINGW_W64_VERSION cpython-mingw $PYTHON_VERSION_MINGW
cat /opt/llvm-mingw/versions >> $GITHUB_ENV
mkdir -p install/llvm-mingw-${{matrix.arch}}
cp /opt/llvm-mingw/versions install/llvm-mingw-${{matrix.arch}}
- name: Build
run: |
sudo apt-get update && sudo apt-get install autoconf-archive ninja-build
./build-cross-tools.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw-${{matrix.arch}} ${{matrix.arch}} --with-python
cd install
zip -9rq ../llvm-mingw-${{matrix.arch}}.zip llvm-mingw-${{matrix.arch}}
- uses: actions/upload-artifact@v3
with:
name: windows-${{matrix.arch}}-toolchain
path: |
llvm-mingw-${{matrix.arch}}.zip
retention-days: 7
# Run llvm-mingw's tests on x86_64 (and i686) with the cross-built x86_64
# toolchain from above.
test-toolchain:
if: (github.event_name != 'schedule') || (github.repository == 'mstorsjo/llvm-mingw')
needs: [linux-cross]
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- i686
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: mingw64
install: >-
unzip
make
- uses: actions/download-artifact@v3
with:
name: windows-${{matrix.arch}}-toolchain
- name: Unpack toolchain
run: |
unzip -q llvm-mingw-*.zip
rm llvm-mingw-*.zip
mv llvm-mingw-* /llvm-mingw
echo /llvm-mingw/bin >> $GITHUB_PATH
- uses: actions/checkout@v3
- name: Run tests
run: |
./run-tests.sh /llvm-mingw
./run-lldb-tests.sh /llvm-mingw
# Run libcxx's tests with the cross-built i686/x86_64 toolchains from above.
# (This builds its own copy of libcxx, but it should be pretty much
# identical to the one shipped - and tests that the toolchain works
# for running the libcxx tests.)
# This also forces testing the bundled python executables.
test-libcxx:
# This test is kinda slow, and kinda redundant (libcxx does contain
# llvm-mingw configurations in its own CI, so the only difference with
# testing here is different runners with different OS setups, and
# testing with the latest compiler instead of an older release).
# Therefore, keep the test disabled by default; it's easy to enable
# temporarily on a branch for testing.
# The libcxxabi and libunwind tests don't pass on the pinned 16.x branch,
# only on git main.
if: false
needs: [linux-cross]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch:
- x86_64
- i686
steps:
- uses: actions/download-artifact@v3
with:
name: windows-${{matrix.arch}}-toolchain
- name: Unpack toolchain
run: |
Expand-Archive llvm-mingw-*.zip -DestinationPath .
del llvm-mingw-*.zip
mv llvm-mingw-* c:\llvm-mingw
echo "c:\llvm-mingw\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
echo "c:\llvm-mingw\python\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
echo "PYTHON_EXE=c:/llvm-mingw/python/bin/python3.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Fetch version
if: github.event_name == 'schedule'
run: |
cat c:\llvm-mingw\versions | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- uses: actions/checkout@v3
- name: Checkout llvm-project
run: |
bash -c "CHECKOUT_ONLY=1 ./build-llvm.sh"
- name: Build and test libcxx
run: |
cd llvm-project
mkdir build
cd build
cmake ../runtimes `
-G Ninja `
-DCMAKE_BUILD_TYPE=Release `
-DPython3_EXECUTABLE="$Env:PYTHON_EXE" `
-DLIBCXX_ENABLE_WERROR=YES `
-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" `
-DLIBCXX_CXX_ABI=libcxxabi `
-DCMAKE_C_COMPILER=clang `
-DCMAKE_CXX_COMPILER=clang++ `
-DLIBCXXABI_ENABLE_SHARED=NO `
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=YES `
-DLIBCXX_USE_COMPILER_RT=YES `
-DLIBCXXABI_USE_COMPILER_RT=YES `
-DLIBUNWIND_USE_COMPILER_RT=YES `
-DLIBCXXABI_USE_LLVM_UNWINDER=YES `
-DLIBCXX_EXTRA_SITE_DEFINES="__USE_MINGW_ANSI_STDIO=1;TEST_IS_EXECUTED_IN_A_SLOW_ENVIRONMENT"
ninja
ninja check-cxx check-cxxabi check-unwind
# Run the OpenMP tests with the cross-built i686/x86_64 toolchains from above.
# This also forces testing the bundled python executables.
test-openmp:
# Only running these tests in scheduled builds.
if: (github.event_name == 'schedule') && (github.repository == 'mstorsjo/llvm-mingw')
needs: [linux-cross]
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include:
- { arch: i686, asmflag: }
- { arch: x86_64, asmflag: -m64 }
steps:
- uses: actions/download-artifact@v3
with:
name: windows-${{matrix.arch}}-toolchain
- name: Unpack toolchain
run: |
Expand-Archive llvm-mingw-*.zip -DestinationPath .
del llvm-mingw-*.zip
mv llvm-mingw-* c:\llvm-mingw
echo "c:\llvm-mingw\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
echo "c:\llvm-mingw\python\bin" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf8 -Append
echo "PYTHON_EXE=c:/llvm-mingw/python/bin/python3.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Fetch version
if: github.event_name == 'schedule'
run: |
cat c:\llvm-mingw\versions | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- uses: actions/checkout@v3
- name: Checkout llvm-project
run: |
bash -c "CHECKOUT_ONLY=1 ./build-llvm.sh"
- name: Build test executables
run: |
cd llvm-project
mkdir build-tools
cd build-tools
cmake ../llvm `
-G Ninja `
-DCMAKE_BUILD_TYPE=Release `
-DLLVM_TARGETS_TO_BUILD=X86 `
-DCMAKE_C_COMPILER=clang `
-DCMAKE_CXX_COMPILER=clang++
ninja not FileCheck
echo "TOOLS=$PWD\bin" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Build and test OpenMP
run: |
cd llvm-project
mkdir build-openmp
cd build-openmp
cmake ../openmp `
-G Ninja `
-DCMAKE_BUILD_TYPE=Release `
-DPython3_EXECUTABLE="$Env:PYTHON_EXE" `
-DOPENMP_LLVM_TOOLS_DIR="$Env:TOOLS" `
-DCMAKE_C_COMPILER=clang `
-DCMAKE_CXX_COMPILER=clang++ `
-DCMAKE_ASM_MASM_COMPILER=llvm-ml `
-DLIBOMP_ASMFLAGS=${{matrix.asmflag}}
ninja
ninja check-openmp
# Test cross-building ffmpeg for all 4 targeted architectures from linux.
# This is done only on scheduled builds, with a toolchain with assertions
# enabled, to catch code generation bugs that might trigger asserts, to
# find such regressions early.
linux-test-cross-build-ffmpeg:
if: (github.event_name == 'schedule') && (github.repository == 'mstorsjo/llvm-mingw')
needs: [linux-asserts]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch:
- i686
- x86_64
- armv7
- aarch64
steps:
- uses: actions/download-artifact@v3
with:
name: linux-asserts-toolchain
- name: Unpack cross toolchain
run: |
tar -Jxf llvm-mingw-*.tar.xz
rm llvm-mingw-*.tar.xz
sudo mv llvm-mingw* /opt/llvm-mingw
echo /opt/llvm-mingw/bin >> $GITHUB_PATH
- name: Checkout ffmpeg
uses: actions/checkout@v3
with:
repository: ffmpeg/ffmpeg
ref: n6.0
path: ffmpeg
- name: Build ffmpeg
run: |
sudo apt-get update && sudo apt-get install nasm
mkdir ffmpeg-build
cd ffmpeg-build
# Set a limit of 3 minutes per process/object file; with unproven
# versions from latest git, the compiler may occasionally hang.
# Make sure we exit in a reasonable time instead of waiting for
# the whole github actions timeout of 6h before exiting.
ulimit -t 180
../ffmpeg/configure --arch=${{matrix.arch}} --target-os=mingw32 --cross-prefix=${{matrix.arch}}-w64-mingw32- --enable-gpl
make -j$(nproc)
# Test building ffmpeg for natively on x86_64 Windows and run its tests,
# to find cases of compiler bugs don't show up as failed asserts in the
# compiler itself, but that only show up at runtime. This is only done
# for scheduled builds.
test-ffmpeg:
if: (github.event_name == 'schedule') && (github.repository == 'mstorsjo/llvm-mingw')
needs: [linux-cross]
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Avoid git checking out files with CRLF
shell: cmd
run: |
git config --global core.autocrlf false
- uses: msys2/setup-msys2@v2
with:
msystem: mingw64
update: false
install: >-
unzip
make
rsync
diffutils
pacboy: >-
nasm:p
- uses: actions/download-artifact@v3
with:
name: windows-x86_64-toolchain
- name: Unpack toolchain
run: |
unzip -q llvm-mingw-*.zip
rm llvm-mingw-*.zip
mv llvm-mingw-* /llvm-mingw
echo /llvm-mingw/bin >> $GITHUB_PATH
- name: Checkout ffmpeg
uses: actions/checkout@v3
with:
repository: ffmpeg/ffmpeg
ref: n6.0
path: ffmpeg
- name: Build & test ffmpeg
run: |
export PATH=/llvm-mingw/bin:$PATH
mkdir ffmpeg-build
cd ffmpeg-build
../ffmpeg/configure --samples=../fate-samples --enable-gpl
make -j$(nproc)
make fate-rsync
make -j$(nproc) fate