Skip to content

Commit d31b82f

Browse files
authored
Merge branch 'main' into fix-135665
2 parents c5fcba3 + 52e10e6 commit d31b82f

File tree

760 files changed

+179596
-12012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

760 files changed

+179596
-12012
lines changed

.ci/compute_projects.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@
5252
"clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests"},
5353
"clang-tools-extra": {"libc"},
5454
"mlir": {"flang"},
55-
# Test everything if ci scripts are changed.
56-
# FIXME: Figure out what is missing and add here.
57-
".ci": {"llvm", "clang", "lld", "lldb"},
5855
}
5956

6057
DEPENDENT_RUNTIMES_TO_TEST = {"clang": {"libcxx", "libcxxabi", "libunwind"}}
@@ -133,11 +130,12 @@ def _add_dependencies(projects: Set[str]) -> Set[str]:
133130
def _compute_projects_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
134131
projects_to_test = set()
135132
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
136136
if modified_project in RUNTIMES:
137137
continue
138-
# Skip all projects where we cannot run tests.
139-
if modified_project in PROJECT_CHECK_TARGETS:
140-
projects_to_test.add(modified_project)
138+
projects_to_test.add(modified_project)
141139
if modified_project not in DEPENDENTS_TO_TEST:
142140
continue
143141
for dependent_project in DEPENDENTS_TO_TEST[modified_project]:

.ci/compute_projects_test.py

-13
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,6 @@ def test_exclude_gn(self):
188188
self.assertEqual(env_variables["runtimes_to_build"], "")
189189
self.assertEqual(env_variables["runtimes_check_targets"], "")
190190

191-
def test_ci(self):
192-
env_variables = compute_projects.get_env_variables(
193-
[".ci/compute_projects.py"], "Linux"
194-
)
195-
self.assertEqual(env_variables["projects_to_build"],
196-
"clang;lld;llvm;lldb")
197-
self.assertEqual(env_variables["project_check_targets"], "check-clang
198-
check-lld check-llvm check-lldb")
199-
self.assertEqual(env_variables["runtimes_to_build"],
200-
"libcxx;libcxxabi;libunwind")
201-
self.assertEqual(env_variables["runtimes_check_targets"], "check-cxx
202-
check-cxxabi check-unwind")
203-
204191

205192
if __name__ == "__main__":
206193
unittest.main()

.ci/monolithic-linux.sh

+40-32
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ 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"
2122
rm -rf "${BUILD_DIR}"
2223

2324
ccache --zero-stats
@@ -27,14 +28,10 @@ if [[ -n "${CLEAR_CACHE:-}" ]]; then
2728
ccache --clear
2829
fi
2930

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-
3531
function at-exit {
3632
retcode=$?
3733

34+
mkdir -p artifacts
3835
ccache --print-stats > artifacts/ccache_stats.txt
3936
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
4037

@@ -53,28 +50,17 @@ trap at-exit EXIT
5350

5451
projects="${1}"
5552
targets="${2}"
56-
runtimes="${3}"
5753

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

6056
echo "--- cmake"
61-
6257
export PIP_BREAK_SYSTEM_PACKAGES=1
6358
pip install -q -r "${MONOREPO_ROOT}"/mlir/python/requirements.txt
6459
pip install -q -r "${MONOREPO_ROOT}"/lldb/test/requirements.txt
6560
pip install -q -r "${MONOREPO_ROOT}"/.ci/requirements.txt
66-
67-
# Set the system llvm-symbolizer as preferred.
68-
export LLVM_SYMBOLIZER_PATH=`which llvm-symbolizer`
69-
[[ ! -f "${LLVM_SYMBOLIZER_PATH}" ]] && echo "llvm-symbolizer not found!"
70-
71-
# Set up all runtimes either way. libcxx is a dependency of LLDB.
72-
# If it ends up being unused, not much harm.
7361
cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
7462
-D LLVM_ENABLE_PROJECTS="${projects}" \
75-
-D LLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
7663
-G Ninja \
77-
-D CMAKE_PREFIX_PATH="${HOME}/.local" \
7864
-D CMAKE_BUILD_TYPE=Release \
7965
-D LLVM_ENABLE_ASSERTIONS=ON \
8066
-D LLVM_BUILD_EXAMPLES=ON \
@@ -83,47 +69,69 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
8369
-D LLVM_ENABLE_LLD=ON \
8470
-D CMAKE_CXX_FLAGS=-gmlt \
8571
-D LLVM_CCACHE_BUILD=ON \
86-
-D LIBCXX_CXX_ABI=libcxxabi \
8772
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
88-
-D LLDB_ENABLE_PYTHON=ON \
89-
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON
73+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
9074

9175
echo "--- ninja"
92-
9376
# Targets are not escaped as they are passed as separate arguments.
9477
ninja -C "${BUILD_DIR}" -k 0 ${targets}
9578

79+
runtimes="${3}"
9680
runtime_targets="${4}"
9781

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

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

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

116112
echo "--- ninja runtimes C++26"
117113

118-
ninja -vC "${BUILD_DIR}" ${runtime_targets}
114+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
119115

120116
echo "--- cmake runtimes clang modules"
121117

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

126134
echo "--- ninja runtimes clang modules"
127135

128-
ninja -vC "${BUILD_DIR}" ${runtime_targets}
136+
ninja -vC "${RUNTIMES_BUILD_DIR}" ${runtime_targets}
129137
fi

.clang-format-ignore

Whitespace-only changes.

.github/workflows/libc-fullbuild-tests.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
include:
2020
- os: ubuntu-24.04
2121
ccache-variant: sccache
22-
c_compiler: clang
23-
cpp_compiler: clang++
22+
c_compiler: clang-20
23+
cpp_compiler: clang++-20
2424
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
2525
- os: ubuntu-24.04-arm
2626
ccache-variant: ccache
27-
c_compiler: clang
28-
cpp_compiler: clang++
27+
c_compiler: clang-20
28+
cpp_compiler: clang++-20
2929
# TODO: add back gcc build when it is fixed
3030
# - c_compiler: gcc
3131
# cpp_compiler: g++
@@ -51,6 +51,9 @@ jobs:
5151
# For more information, see https://wiki.debian.org/Multiarch/LibraryPathOverview
5252
- name: Prepare dependencies (Ubuntu)
5353
run: |
54+
wget https://apt.llvm.org/llvm.sh
55+
chmod +x llvm.sh
56+
sudo ./llvm.sh 20
5457
sudo apt-get update
5558
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-libc-dev
5659
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm

bolt/CMakeLists.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ endforeach()
8282

8383
set(BOLT_ENABLE_RUNTIME_default OFF)
8484
if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
85-
OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$")
85+
OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$"
86+
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
8687
AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"
8788
OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
8889
AND (NOT CMAKE_CROSSCOMPILING))

bolt/lib/Core/Relocation.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static bool isSupportedRISCV(uint32_t Type) {
123123
case ELF::R_RISCV_LO12_S:
124124
case ELF::R_RISCV_64:
125125
case ELF::R_RISCV_TLS_GOT_HI20:
126+
case ELF::R_RISCV_TLS_GD_HI20:
126127
case ELF::R_RISCV_TPREL_HI20:
127128
case ELF::R_RISCV_TPREL_ADD:
128129
case ELF::R_RISCV_TPREL_LO12_I:
@@ -236,6 +237,7 @@ static size_t getSizeForTypeRISCV(uint32_t Type) {
236237
case ELF::R_RISCV_64:
237238
case ELF::R_RISCV_GOT_HI20:
238239
case ELF::R_RISCV_TLS_GOT_HI20:
240+
case ELF::R_RISCV_TLS_GD_HI20:
239241
// See extractValueRISCV for why this is necessary.
240242
return 8;
241243
}
@@ -491,6 +493,7 @@ static uint64_t extractValueRISCV(uint32_t Type, uint64_t Contents,
491493
return extractBImmRISCV(Contents);
492494
case ELF::R_RISCV_GOT_HI20:
493495
case ELF::R_RISCV_TLS_GOT_HI20:
496+
case ELF::R_RISCV_TLS_GD_HI20:
494497
// We need to know the exact address of the GOT entry so we extract the
495498
// value from both the AUIPC and L[D|W]. We cannot rely on the symbol in the
496499
// relocation for this since it simply refers to the object that is stored
@@ -707,6 +710,7 @@ static bool isPCRelativeRISCV(uint32_t Type) {
707710
case ELF::R_RISCV_RVC_BRANCH:
708711
case ELF::R_RISCV_32_PCREL:
709712
case ELF::R_RISCV_TLS_GOT_HI20:
713+
case ELF::R_RISCV_TLS_GD_HI20:
710714
return true;
711715
}
712716
}

bolt/lib/Rewrite/RewriteInstance.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -2926,12 +2926,12 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
29262926

29272927
if (BinaryData *BD = BC->getBinaryDataContainingAddress(SymbolAddress)) {
29282928
// Note: this assertion is trying to check sanity of BinaryData objects
2929-
// but AArch64 has inferred and incomplete object locations coming from
2930-
// GOT/TLS or any other non-trivial relocation (that requires creation
2931-
// of sections and whose symbol address is not really what should be
2932-
// encoded in the instruction). So we essentially disabled this check
2929+
// but AArch64 and RISCV has inferred and incomplete object locations
2930+
// coming from GOT/TLS or any other non-trivial relocation (that requires
2931+
// creation of sections and whose symbol address is not really what should
2932+
// be encoded in the instruction). So we essentially disabled this check
29332933
// for AArch64 and live with bogus names for objects.
2934-
assert((IsAArch64 || IsSectionRelocation ||
2934+
assert((IsAArch64 || BC->isRISCV() || IsSectionRelocation ||
29352935
BD->nameStartsWith(SymbolName) ||
29362936
BD->nameStartsWith("PG" + SymbolName) ||
29372937
(BD->nameStartsWith("ANONYMOUS") &&

0 commit comments

Comments
 (0)