Skip to content

Commit caee3e8

Browse files
committed
[LDC] Set up CI / package generation with Azure Pipelines and Travis
Azure: Windows x86 & x64, macOS x64 & ARM64, Linux x64, Android ARMv7-A & AArch64 Travis: Linux AArch64 2 packages per platform (enabled/disabled assertions), except for cross- compiled Android and macOS ARM64. Tagged builds are uploaded to the corresponding GitHub release, untagged builds to the GitHub 'CI' release.
1 parent c1e52c7 commit caee3e8

File tree

4 files changed

+495
-0
lines changed

4 files changed

+495
-0
lines changed

.azure-pipelines/posix.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Each step starts in the checked-out source directory,
2+
# environment variables aren't persisted across steps.
3+
4+
steps:
5+
- script: |
6+
set -ex
7+
cd ..
8+
if [ "$CI_OS" = "osx" ]; then export PATH="$PWD/ninja:$PATH"; fi
9+
cmake --version
10+
ninja --version
11+
mkdir build
12+
cd build
13+
cmake -G Ninja $BUILD_SOURCESDIRECTORY/llvm \
14+
-DCMAKE_BUILD_TYPE=Release \
15+
-DCMAKE_INSTALL_PREFIX=$PWD/../install \
16+
-DLLVM_ENABLE_PROJECTS="$LLVM_PROJECTS_TO_ENABLE" \
17+
-DLLVM_TARGETS_TO_BUILD="$LLVM_TARGETS_TO_BUILD" \
18+
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="$LLVM_EXPERIMENTAL_TARGETS_TO_BUILD" \
19+
-DLLVM_ENABLE_ASSERTIONS=$LLVM_ENABLE_ASSERTIONS \
20+
$BASE_CMAKE_FLAGS $EXTRA_CMAKE_FLAGS $EXTRA_CMAKE_FLAGS_CROSS
21+
ninja install
22+
displayName: Build & install LLVM incl. LLD, compiler-rt, MLIR, BOLT and the Khronos SPIRV-LLVM-Translator
23+
- script: |
24+
set -ex
25+
cd ..
26+
if [ "${BUILD_SOURCEBRANCH:0:10}" = "refs/tags/" ]; then
27+
ARTIFACT_ID=${BUILD_SOURCEBRANCH:15}
28+
else
29+
ARTIFACT_ID=${BUILD_SOURCEVERSION:0:8}
30+
fi
31+
ASSERTS_SUFFIX=""
32+
if [ "$LLVM_ENABLE_ASSERTIONS" = "ON" ]; then
33+
ASSERTS_SUFFIX="-withAsserts"
34+
fi
35+
artifactName=llvm-$ARTIFACT_ID-$CI_OS-$ARCH$ASSERTS_SUFFIX
36+
mv install $artifactName
37+
mkdir artifacts
38+
chmod -R go=rX $artifactName
39+
if [ "$CI_OS" = "osx" ]; then
40+
sudo chown -R root:wheel $artifactName
41+
tar -cJf artifacts/$artifactName.tar.xz --options='compression-level=9' $artifactName
42+
else
43+
tar -cf - --owner=0 --group=0 $artifactName | 7za a artifacts/$artifactName.tar.xz -si -txz -mx9
44+
fi
45+
# Persist the ARTIFACT_ID and ASSERTS_SUFFIX variables for future steps
46+
set +x
47+
echo "##vso[task.setvariable variable=ARTIFACT_ID]$ARTIFACT_ID"
48+
echo "##vso[task.setvariable variable=ASSERTS_SUFFIX]$ASSERTS_SUFFIX"
49+
displayName: Pack installation dir
50+
- script: |
51+
set -ex
52+
artifactName=llvm-$ARTIFACT_ID.src
53+
# just the LLVM src dir (already incl. LLVM-SPIRV-Translator) + compiler-rt + lld + mlir
54+
mv compiler-rt mlir llvm/projects
55+
mv lld llvm/tools
56+
chmod -R go=rX llvm
57+
tar -cf - --exclude-vcs --owner=0 --group=0 --transform=s,${BUILD_SOURCESDIRECTORY:1}/llvm,$artifactName, $BUILD_SOURCESDIRECTORY/llvm | 7za a ../artifacts/$artifactName.tar.xz -si -txz -mx9
58+
displayName: Pack source dir
59+
condition: and(succeeded(), and(eq(variables['CI_OS'], 'linux'), eq(variables['LLVM_ENABLE_ASSERTIONS'], 'OFF')))
60+
- publish: ../artifacts
61+
artifact: $(CI_OS)-$(ARCH)$(ASSERTS_SUFFIX)

.azure-pipelines/windows.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Each step starts in the checked-out source directory,
2+
# environment variables aren't persisted across steps.
3+
4+
steps:
5+
- script: |
6+
set
7+
displayName: Print environment variables
8+
- checkout: self
9+
submodules: true
10+
fetchDepth: 50
11+
- script: |
12+
echo on
13+
cd ..
14+
:: Download & extract Ninja
15+
curl -L -o ninja.zip https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip 2>&1
16+
mkdir ninja
17+
cd ninja
18+
7z x ../ninja.zip > nul
19+
cd ..
20+
:: Download & install clang
21+
curl -L -o clang.exe https://github.com/llvm/llvm-project/releases/download/llvmorg-%CLANG_VERSION%/LLVM-%CLANG_VERSION%-win64.exe 2>&1
22+
clang.exe /S
23+
displayName: Install prerequisites
24+
- script: |
25+
echo on
26+
cd ..
27+
set PATH=C:\Program Files\LLVM\bin;%CD%\ninja;%PATH%
28+
call "%VSINSTALLDIR%Common7\Tools\VsDevCmd.bat" -arch=%ARCH%
29+
echo on
30+
cmake --version
31+
ninja --version
32+
clang-cl --version
33+
mkdir build
34+
cd build
35+
cmake -G Ninja %BUILD_SOURCESDIRECTORY%\llvm -DCMAKE_C_COMPILER:PATH=clang-cl.exe -DCMAKE_CXX_COMPILER:PATH=clang-cl.exe -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%CD%/../install -DLLVM_ENABLE_PROJECTS=%LLVM_PROJECTS_TO_ENABLE% -DLLVM_TARGETS_TO_BUILD=%LLVM_TARGETS_TO_BUILD% -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=%LLVM_EXPERIMENTAL_TARGETS_TO_BUILD% -DLLVM_ENABLE_ASSERTIONS=%LLVM_ENABLE_ASSERTIONS% -DLLVM_DEFAULT_TARGET_TRIPLE=%LLVM_DEFAULT_TARGET_TRIPLE% %BASE_CMAKE_FLAGS% %EXTRA_CMAKE_FLAGS%
36+
ninja install
37+
displayName: Build & install LLVM incl. LLD, compiler-rt and the Khronos SPIRV-LLVM-Translator
38+
- script: |
39+
echo on
40+
cd ..
41+
:: On Windows, the lld symlinks are copies
42+
rm install/bin/ld.lld.exe
43+
rm install/bin/ld64.lld*.exe
44+
rm install/bin/lld-link.exe
45+
rm install/bin/wasm-ld.exe
46+
mv install/bin/lld.exe install/bin/lld-link.exe
47+
if "%BUILD_SOURCEBRANCH:~0,10%" == "refs/tags/" (
48+
set ARTIFACT_ID=%BUILD_SOURCEBRANCH:~15%
49+
) else (
50+
set ARTIFACT_ID=%BUILD_SOURCEVERSION:~0,8%
51+
)
52+
set ASSERTS_SUFFIX=
53+
if "%LLVM_ENABLE_ASSERTIONS%" == "ON" (
54+
set ASSERTS_SUFFIX=-withAsserts
55+
)
56+
set ARTIFACT_NAME=llvm-%ARTIFACT_ID%-windows-%ARCH%%ASSERTS_SUFFIX%
57+
mv install %ARTIFACT_NAME%
58+
mkdir artifacts
59+
cd %ARTIFACT_NAME%
60+
7z a -mx=9 ../artifacts/%ARTIFACT_NAME%.7z * > nul
61+
:: Persist the ASSERTS_SUFFIX env variable for future steps
62+
echo off
63+
echo ##vso[task.setvariable variable=ASSERTS_SUFFIX]%ASSERTS_SUFFIX%
64+
displayName: Pack installation dir
65+
- publish: ../artifacts
66+
artifact: windows-$(ARCH)$(ASSERTS_SUFFIX)

.travis.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
os: linux
2+
dist: bionic
3+
arch: arm64
4+
language: cpp
5+
6+
env:
7+
global:
8+
- CLANG_VERSION: 14.0.0
9+
# no MLIR, it increases compile times dangerously for 50 min timeout
10+
- LLVM_PROJECTS_TO_ENABLE: '"bolt;compiler-rt;lld"'
11+
# keep these in sync with azure-pipelines.yml for Linux x64:
12+
- LLVM_TARGETS_TO_BUILD: all
13+
- BASE_CMAKE_FLAGS: '"-DLLVM_ENABLE_UNWIND_TABLES=OFF -DLLVM_ENABLE_TERMINFO=OFF -DLLVM_ENABLE_LIBEDIT=OFF -DCOMPILER_RT_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_TESTS=OFF -DCOMPILER_RT_USE_LIBCXX=OFF"'
14+
- EXTRA_CMAKE_FLAGS: '"-DLLVM_BINUTILS_INCDIR=/usr/include -DLLVM_STATIC_LINK_CXX_STDLIB=ON"'
15+
- secure: "OdbRvOLlVNsk0mciOrZzCGE8bBpQ+7pQXKmGCcVzMD3ixg/P92byy14slYRiPUvRLukznal0sXRTN/0j9pDMjACY7cLXLgvZQWxDNZ2pHUewyqGbkSZ5A/Nt3H5R8XknRk6W6T+19Cf6uhx5elciTU48BKXvwDXdPfMc1Q2XWo5bY7n1BfKW1llM//dX/zF13WOia9PDIu3KqcAZ6Ea764LN4BV48k3NzE8ss9ZBvvIJCZ9DgDx71TFd1c9dQQF8ZTKyeQ8Sv5dunFJbVlTPyIsRJw+D7/BUuqUMfSVjK9QG5t/QmuZaB3MrlM1+ZYZnowG2l7H4hOIainxUmvheMlKYQdfyypoD7rhy5/0WXdHGo8ga8Eue9w0vvmxqoq0AMFuxBejrHNQlDl9bXcznLUKD52M5ROLBBmG/3UYK9ar6nvufU0ERQ/xpo1nA9pmgpQ6NJD1ZV3ExdZINj2hOMil/Tyn5RuMSgwx55H9vo/7NwHt6vYKA7B1fzz/gK38tKJtPfE841QxgYkfsNc0d5r2x4ZCLCol/hJgRw/mTO4ISLPnyFnYIfHjLeheGVzMaQpRFAtwWFDPJl/v4Rhrv1BMxgS3QjgtOxGjLGMyok3qk0q+pN+oJHFpfSMJ3I/LbEunEFJiuziJRNQDPJTMAfR94uLisec0dcJPyxPQL6uc="
16+
17+
git:
18+
depth: 50
19+
20+
addons:
21+
apt:
22+
packages:
23+
- ninja-build
24+
- binutils-dev
25+
- p7zip-full
26+
27+
jobs:
28+
include:
29+
- env: LLVM_ENABLE_ASSERTIONS=ON
30+
- env: LLVM_ENABLE_ASSERTIONS=OFF
31+
32+
script:
33+
- nproc
34+
- free
35+
# Install a more recent version of CMake
36+
- curl --max-time 300 --retry 3 -L -o cmake.tar.gz https://github.com/Kitware/CMake/releases/download/v3.21.3/cmake-3.21.3-linux-aarch64.tar.gz
37+
- mkdir cmake_bin
38+
- tar -xf cmake.tar.gz --strip 1 -C cmake_bin
39+
- export PATH="$PWD/cmake_bin/bin:$PATH"
40+
# Download & extract clang
41+
- curl --max-time 300 --retry 3 -L -o clang.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-$CLANG_VERSION/clang+llvm-$CLANG_VERSION-aarch64-linux-gnu.tar.xz
42+
- mkdir clang_bin
43+
- tar -xf clang.tar.xz --strip 1 -C clang_bin
44+
- rm clang.tar.xz
45+
- export CC="$PWD/clang_bin/bin/clang"
46+
- export CXX="$PWD/clang_bin/bin/clang++"
47+
# Build & install LLVM incl. LLD, compiler-rt, BOLT and the Khronos SPIRV-LLVM-Translator
48+
- cmake --version
49+
- ninja --version
50+
- mkdir build
51+
- cd build
52+
- |
53+
cmake -G Ninja ../llvm \
54+
-DCMAKE_BUILD_TYPE=Release \
55+
-DCMAKE_INSTALL_PREFIX=$PWD/../install \
56+
-DLLVM_ENABLE_PROJECTS="$LLVM_PROJECTS_TO_ENABLE" \
57+
-DLLVM_TARGETS_TO_BUILD="$LLVM_TARGETS_TO_BUILD" \
58+
-DLLVM_ENABLE_ASSERTIONS=$LLVM_ENABLE_ASSERTIONS \
59+
$BASE_CMAKE_FLAGS $EXTRA_CMAKE_FLAGS
60+
- |
61+
# work around out-of-memory kills
62+
for N in 16 8 4 2; do
63+
ninja -j$N -k0 && break
64+
done
65+
- ninja -j1 install
66+
- cd ..
67+
# Pack installation dir
68+
- |
69+
set -eo pipefail
70+
if [ "$TRAVIS_TAG" != "" ]; then
71+
artifactID=${TRAVIS_TAG:5}
72+
else
73+
artifactID=${TRAVIS_COMMIT:0:8}
74+
fi
75+
assertsSuffix=""
76+
if [ "$LLVM_ENABLE_ASSERTIONS" = "ON" ]; then
77+
assertsSuffix="-withAsserts"
78+
fi
79+
artifactName=llvm-$artifactID-linux-aarch64$assertsSuffix
80+
mv install $artifactName
81+
chmod -R go=rX $artifactName
82+
artifact=$artifactName.tar.xz
83+
echo "Packing $artifact..."
84+
tar -cf - --owner=0 --group=0 $artifactName | 7za a $artifact -si -txz -mx9 -mmt8
85+
ls -lh $artifact
86+
export artifact
87+
88+
after_success:
89+
# Upload to GitHub release (only for branches and tags, no PRs)
90+
- |
91+
set -e
92+
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
93+
echo 'Skipping deployment'
94+
else
95+
if [ "$TRAVIS_TAG" = "" ]; then
96+
releaseTag=CI
97+
else
98+
releaseTag=$TRAVIS_TAG
99+
fi
100+
releaseID="$(bash -c "curl -s https://api.github.com/repos/ldc-developers/llvm-project/releases/tags/$releaseTag | grep -m 1 '^ \"id\":'")"
101+
releaseID=${releaseID:8:-1}
102+
echo "Uploading $artifact to GitHub release $releaseTag ($releaseID)..."
103+
curl -s \
104+
-H "Authorization: token $GITHUB_TOKEN" \
105+
-H "Content-Type: application/octet-stream" \
106+
--data-binary @$artifact \
107+
https://uploads.github.com/repos/ldc-developers/llvm-project/releases/$releaseID/assets?name=$artifact
108+
fi
109+
110+
notifications:
111+
email: false

0 commit comments

Comments
 (0)