Skip to content

Commit 54ac9ed

Browse files
committed
[CI] monolithic-linux improvements
Some improvements to monolithic-linux CI: 1) Add correct configuration and dependencies for LLDB testing which is actually relevant for clang changes. 2) Skip clang installation and separate configuration for runtimes. They will be build with just built clang either way. This helps in avoiding building the runtimes twice in case LLDB is tested. 3) Make sure any generated clang reproducers end up as artifacts. 4) Set up llvm-symbolizer environment variable so that its preferred over any symbolizer just built, as even if it probably works correctly, it can be much slower when built for debugging. 5) Add all projects as dependencies of `.ci`, to make sure everything is tested when it changes.
1 parent 761787d commit 54ac9ed

File tree

2 files changed

+40
-44
lines changed

2 files changed

+40
-44
lines changed

.ci/compute_projects.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
"clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests"},
5353
"clang-tools-extra": {"libc"},
5454
"mlir": {"flang"},
55+
# Test everyything if ci scripts are changed.
56+
".ci": {"llvm", "clang", "lld", "lldb"},
5557
}
5658

5759
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
@@ -130,12 +132,11 @@ def _add_dependencies(projects: Set[str]) -> Set[str]:
130132
def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
131133
projects_to_test = set()
132134
for modified_project in modified_projects:
133-
# Skip all projects where we cannot run tests.
134-
if modified_project not in PROJECT_CHECK_TARGETS:
135-
continue
136135
if modified_project in RUNTIMES:
137136
continue
138-
projects_to_test.add(modified_project)
137+
# Skip all projects where we cannot run tests.
138+
if modified_project in PROJECT_CHECK_TARGETS:
139+
projects_to_test.add(modified_project)
139140
if modified_project not in DEPENDENTS_TO_TEST:
140141
continue
141142
for dependent_project in DEPENDENTS_TO_TEST[modified_project]:

.ci/monolithic-linux.sh

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ set -o pipefail
1818

1919
MONOREPO_ROOT="${MONOREPO_ROOT:="$(git rev-parse --show-toplevel)"}"
2020
BUILD_DIR="${BUILD_DIR:=${MONOREPO_ROOT}/build}"
21-
INSTALL_DIR="${BUILD_DIR}/install"
2221
rm -rf "${BUILD_DIR}"
2322

2423
ccache --zero-stats
@@ -28,10 +27,14 @@ if [[ -n "${CLEAR_CACHE:-}" ]]; then
2827
ccache --clear
2928
fi
3029

30+
mkdir -p artifacts/reproducers
31+
32+
# Make sure any clang reproducers will end up as artifacts.
33+
export CLANG_CRASH_DIAGNOSTICS_DIR=`realpath artifacts/reproducers`
34+
3135
function at-exit {
3236
retcode=$?
3337

34-
mkdir -p artifacts
3538
ccache --print-stats > artifacts/ccache_stats.txt
3639

3740
# If building fails there will be no results files.
@@ -49,17 +52,31 @@ trap at-exit EXIT
4952

5053
projects="${1}"
5154
targets="${2}"
55+
runtimes="${3}"
5256

5357
lit_args="-v --xunit-xml-output ${BUILD_DIR}/test-results.xml --use-unique-output-file-name --timeout=1200 --time-tests"
5458

5559
echo "--- cmake"
5660
export PIP_BREAK_SYSTEM_PACKAGES=1
61+
5762
pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt
5863
pip install -q -r "${MONOREPO_ROOT}"/lldb/test/requirements.txt
5964
pip install -q -r "${MONOREPO_ROOT}"/.ci/requirements.txt
65+
66+
# This is an lldb requirement which is not listed above.
67+
pip install -q swig
68+
69+
# Set the system llvm-symbolizer as preferred.
70+
export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
71+
[[ ! -f "${LLVM_SYMBOLIZER_PATH}" ]] && echo "llvm-symbolizer not found!"
72+
73+
# Set up all runtimes either way. libcxx is a dependency of LLDB.
74+
# If it ends up being unused, not much harm.
6075
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6176
-D LLVM_ENABLE_PROJECTS="${projects}" \
77+
-D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
6278
-G Ninja \
79+
-D CMAKE_PREFIX_PATH="${HOME}/.local" \
6380
-D CMAKE_BUILD_TYPE=Release \
6481
-D LLVM_ENABLE_ASSERTIONS=ON \
6582
-D LLVM_BUILD_EXAMPLES=ON \
@@ -68,69 +85,47 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6885
-D LLVM_ENABLE_LLD=ON \
6986
-D CMAKE_CXX_FLAGS=-gmlt \
7087
-D LLVM_CCACHE_BUILD=ON \
88+
-D LIBCXX_CXX_ABI=libcxxabi \
7189
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
72-
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
90+
-D LLDB_ENABLE_PYTHON=ON \
91+
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON
7392

7493
echo "--- ninja"
94+
7595
# Targets are not escaped as they are passed as separate arguments.
7696
ninja -C "${BUILD_DIR}" -k 0 ${targets}
7797

78-
runtimes="${3}"
7998
runtime_targets="${4}"
8099

81-
# Compiling runtimes with just-built Clang and running their tests
82-
# as an additional testing for Clang.
100+
# Run runtimes tests.
101+
# We don't need to do a clean separate build of runtimes, because runtimes
102+
# will be built against just built clang, and because LIBCXX_TEST_PARAMS
103+
# and LIBCXXABI_TEST_PARAMS only affect lit configuration, which successfully
104+
# propagates without a clean build. Other that those two variables, builds
105+
# are supposed to be the same.
83106
if [[ "${runtimes}" != "" ]]; then
84107
if [[ "${runtime_targets}" == "" ]]; then
85108
echo "Runtimes to build are specified, but targets are not."
86109
exit 1
87110
fi
88111

89-
echo "--- ninja install-clang"
90-
91-
ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
92-
93-
RUNTIMES_BUILD_DIR="${MONOREPO_ROOT}/build-runtimes"
94-
INSTALL_DIR="${BUILD_DIR}/install"
95-
mkdir -p ${RUNTIMES_BUILD_DIR}
96-
97112
echo "--- cmake runtimes C++26"
98113

99-
rm -rf "${RUNTIMES_BUILD_DIR}"
100-
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
101-
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
102-
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
103-
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
104-
-D LIBCXX_CXX_ABI=libcxxabi \
105-
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
106-
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
114+
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
107115
-D LIBCXX_TEST_PARAMS="std=c++26" \
108-
-D LIBCXXABI_TEST_PARAMS="std=c++26" \
109-
-D LLVM_LIT_ARGS="${lit_args}"
116+
-D LIBCXXABI_TEST_PARAMS="std=c++26"
110117

111118
echo "--- ninja runtimes C++26"
112119

113-
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
120+
ninja -vC "${BUILD_DIR}" ${runtime_targets}
114121

115122
echo "--- cmake runtimes clang modules"
116123

117-
# We don't need to do a clean build of runtimes, because LIBCXX_TEST_PARAMS
118-
# and LIBCXXABI_TEST_PARAMS only affect lit configuration, which successfully
119-
# propagates without a clean build. Other that those two variables, builds
120-
# are supposed to be the same.
121-
122-
cmake -S "${MONOREPO_ROOT}/runtimes" -B "${RUNTIMES_BUILD_DIR}" -GNinja \
123-
-D CMAKE_C_COMPILER="${INSTALL_DIR}/bin/clang" \
124-
-D CMAKE_CXX_COMPILER="${INSTALL_DIR}/bin/clang++" \
125-
-D LLVM_ENABLE_RUNTIMES="${runtimes}" \
126-
-D LIBCXX_CXX_ABI=libcxxabi \
127-
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
128-
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
124+
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
129125
-D LIBCXX_TEST_PARAMS="enable_modules=clang" \
130-
-D LIBCXXABI_TEST_PARAMS="enable_modules=clang" \
131-
-D LLVM_LIT_ARGS="${lit_args}"
126+
-D LIBCXXABI_TEST_PARAMS="enable_modules=clang"
132127

133128
echo "--- ninja runtimes clang modules"
134129

135-
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
130+
ninja -vC "${BUILD_DIR}" ${runtime_targets}
136131
fi

0 commit comments

Comments
 (0)