Skip to content

Commit

Permalink
ci: build clangd in separate job to avoid timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyxogen authored and yuri91 committed Feb 8, 2024
1 parent 0efaba0 commit 2692149
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 17 deletions.
40 changes: 39 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,37 @@ jobs:
paths:
- cheerp-build.tar.bz2
- cheerp-core_*.deb
build-clangd:
executor: cheerp-large
environment:
- NINJA_STATUS: "[%u/%r/%f] "
- THREADS: 6
- CCACHE_DISABLE: 1
- ONLY_CLANGD: 1
steps:
- attach_workspace:
at: ~/project/packages
- run:
name: Set up environment
working_directory: ~/project/cheerp-compiler
command: |
cat ~/project/packages/version >> $BASH_ENV
- run:
name: Extract build
working_directory: ~/project/cheerp-compiler
command: tar -C . -xvf ~/project/packages/cheerp-build.tar.bz2
- run:
name: Build clangd
working_directory: ~/project/cheerp-compiler
command: |
dch -b -v "$VERSION_NO-1" "Internal build" -m
dpkg-buildpackage -d -b
mkdir -p ~/project/packages/with_clangd
mv -v ../cheerp-core_*.deb ~/project/packages/with_clangd
- persist_to_workspace:
root: ~/project/packages/with_clangd
paths:
- cheerp-core_*.deb
llvm-check:
parameters:
rule:
Expand Down Expand Up @@ -287,7 +318,7 @@ jobs:
tar -czvf ~/project/packages/cheerp-core_$VERSION_NO.orig-cheerp-musl.tar.gz cheerp-musl/
tar -czvf ~/project/packages/cheerp-core_$VERSION_NO.orig-cheerp-utils.tar.gz cheerp-utils/
tar -czvf ~/project/packages/cheerp-core_$VERSION_NO.orig.tar.gz clang/ llvm/ cmake/ compiler-rt/ libcxx/ libcxxabi/ \
runtimes/ third-party/ debian/
runtimes/ third-party/ debian/ clang-tools-extra/
- run:
name: Package cheerp toolchain
no_output_timeout: 30m
Expand Down Expand Up @@ -982,6 +1013,12 @@ workflows:
- build-cheerp-toolchain:
requires:
- define-version-no
- build-clangd:
requires:
- build-cheerp-toolchain
filters:
branches:
only: master
- llvm-check:
matrix:
parameters:
Expand Down Expand Up @@ -1019,6 +1056,7 @@ workflows:
requires:
- define-version-no
- test
- build-clangd
- llvm-check
filters:
branches:
Expand Down
51 changes: 35 additions & 16 deletions debian/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ USE_CCACHE=Off
ENABLE_LLVM_ASSERTIONS=Off

BUILD_DIR="$PWD/build"
BUILD_CLANGD=1
mkdir -p "$BUILD_DIR"

if [ -n "$CIRCLECI" ]; then
USE_CCACHE=On
unset BUILD_CLANGD # circleci would timeout if we tried
if [ "$CIRCLE_BRANCH" != "master" ]; then
ENABLE_LLVM_ASSERTIONS=On
else
BUILD_CLANGD=1
fi
FLAGS_RELEASE="-O2"
fi
Expand Down Expand Up @@ -66,18 +66,12 @@ llvm_ninja_command() {
ninja $JOBS_OPT -v -C build_llvm "$1"
}

build_compiler() {
if [ -n "$BUILD_CLANGD" ]; then
LLVM_PROJECTS="clang;clang-tools-extra"
else
LLVM_PROJECTS="clang"
fi

configure_llvm() {
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS_RELEASE="$FLAGS_RELEASE" \
-DCLANG_VENDOR="Cheerp $deb_version" \
-DLLVM_ENABLE_PROJECTS="$LLVM_PROJECTS" \
-DLLVM_ENABLE_PROJECTS="$1" \
llvm/ \
-GNinja \
-DLLVM_ENABLE_ASSERTIONS="$ENABLE_LLVM_ASSERTIONS" \
Expand All @@ -89,14 +83,25 @@ build_compiler() {
-DLLVM_CCACHE_BUILD="$USE_CCACHE" \
-C llvm/CheerpCmakeConf.cmake \
-B build_llvm
}

build_compiler() {
PROJECTS="clang"
if [ -n "$BUILD_CLANGD" ]; then
PROJECTS="$PROJECTS;clang-tools-extra"
fi

configure_llvm clang
export DESTDIR="$BUILD_DIR"
llvm_ninja_command install-distribution

unset LLVM_PROJECTS
unset DESTDIR
}

build_clangd() {
configure_llvm "clang;clang-tools-extra"
llvm_ninja_command install-clangd
}

prepare() {
#This is temporary and will be overwritten after install
cmake -B cheerp-utils/build -DCMAKE_INSTALL_PREFIX="$TMP_INSTALL" -DCHEERP_PREFIX="$CHEERP_DIR" cheerp-utils
Expand Down Expand Up @@ -189,14 +194,18 @@ build_compiler_rt() {
make -C build_compiler_rt install
}

copy_install() {
cp -r "$BUILD_DIR/." "$CHEERP_DEST"
}

install_all() {
# cheerp-utils will install stuff with absolute paths. To fix this, during compilation we'll use a temporary cheerp-utils,
# with the directories pointing to the build dirs, and just before installing, we'll change the paths to the actual install dir
cmake -B cheerp-utils/build -DCMAKE_INSTALL_PREFIX="$TMP_INSTALL" -DCHEERP_PREFIX="$CHEERP_PREFIX" cheerp-utils
make -C cheerp-utils/build install

mkdir -p "$CHEERP_DEST"
cp -r "$BUILD_DIR/." "$CHEERP_DEST"
copy_install
cp cheerp-utils/LICENSE.TXT "$CHEERP_DEST/$CHEERP_PREFIX/"
cp cheerp-utils/README "$CHEERP_DEST/$CHEERP_PREFIX/"
cp cheerp-utils/ChangeLog "$CHEERP_DEST/$CHEERP_PREFIX/"
Expand Down Expand Up @@ -234,10 +243,15 @@ case "$1" in
build_all_libraries
;;
install)
install_all
if [ -n "$ONLY_CLANGD" ]; then
echo "ONLY_CLANGD is only meant as a workaround for circleci, do not rely on this behavior!" >&2
copy_install
else
install_all
fi
;;
tar-compiler)
tar -cvjf "$2" build_llvm debian/build.sh cmake third-party llvm clang clang-tools-extra .git/logs/HEAD
tar -cvjf "$2" build_llvm debian cmake third-party llvm clang clang-tools-extra .git/logs/HEAD
;;
tar-install)
tar -cvjf "$2" "$BUILD_DIR/."
Expand All @@ -246,7 +260,12 @@ case "$1" in
llvm_ninja_command "$2"
;;
all)
build_all
if [ -n "$ONLY_CLANGD" ]; then
echo "ONLY_CLANGD is only meant as a workaround for circleci, do not rely on this behavior!" >&2
build_clangd
else
build_all
fi
;;
*)
echo "Unknown command $1" >&2
Expand Down

0 comments on commit 2692149

Please sign in to comment.