Skip to content

Use clang-23 - #117346

Merged
thevar1able merged 103 commits into
masterfrom
use-clang-23
Nov 14, 2026
Merged

thevar1able merged 103 commits into
masterfrom
use-clang-23

Conversation

@thevar1able

@thevar1able thevar1able commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Build/Testing/Packaging Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Use clang-23 in CI.


Workflow [PR]
Sync PR [sync-upstream/pr/117346]

Version info

  • Merged into: 26.11.1.2315-master (included in 26.11 and later)

Bump the CI toolchain, docker images, toolchain build job and build docs
from clang-22 to clang-23 (apt.llvm.org ships 1:23.1.0~ snapshots for
amd64 and arm64; llvm-project has the release/23.x branch).

Co-Authored-By: Claude Fable 5 <[email protected]>
@mintlify

mintlify Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 13, 2026, 11:12 PM

@thevar1able
thevar1able marked this pull request as draft August 31, 2026 13:58
@clickhouse-gh

clickhouse-gh Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [b9473fd]

Summary: ✅


AI Review

Summary

Reviewed head b9473fda4003fb2c111a896156eece6a95a1dcd0, the complete PR diff, surrounding code, and all prior discussion. The PR upgrades CI to clang-23 and bundled LLVM 23, with targeted mitigations for compiler and library regressions. No new inline findings; the existing x86 sorting performance concern remains unverified.

Findings

⚠️ Majors

  • ci/defs/defs.py:528: The release-toolchain switch still lacks follow-up evidence for the x86 multi-column sorting regression. The 2026-11-10 comparison measured sort_multi_column_mixed #1/#5 at +18.0%/+17.2%, affecting ordinary multi-column ORDER BY. The author's analysis could not reproduce it on Zen 5 and explicitly leaves verification on Sapphire Rapids open. CIDB still contains no subsequent PR result for either query; current 30-day master history has 0 slower / 0 unstable in 1,266 runs for each. This remains a concern requiring verification, rather than a confirmed persistent compiler defect. Repeat these two queries with the current candidate and matching reference on x86 CI hardware; mitigate a reproducible slowdown or provide measurements explaining the earlier shift. Existing inline finding, author's analysis.
Missing context / blind spots
  • ⚠️ The current-head workflow is still running, with the selected x86 and ARM performance shards pending. Completed comparisons are needed to validate the latest mitigations. No local build or server tests were run; this checkout has no configured build or ClickHouse executable.
Final Verdict

⚠️ Request changes — close the existing sorting verification gap with the focused x86 comparison above. No duplicate inline comment was posted.

LLVM Coverage Report

Measured on commit b9473fd.

Metric Baseline Current Δ
Lines 91.70% 91.70% +0.00%
Functions 91.80% 91.80% +0.00%
Branches 81.40% 81.30% -0.10%

Changed lines: Changed C/C++ lines covered: 316/340 (92.94%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-build Pull request with build/testing/packaging improvement label Aug 31, 2026
`cctools-port`'s configure copies the system LLVM's `llvm-c/lto.h` (and
`ExternC.h`) over its bundled headers, but since LLVM 23 `lto.h` also
includes `llvm-c/Visibility.h`, which configure does not copy, failing
the compilation of `libstuff_la-lto.lo` with:

    ../include/llvm-c/lto.h:20:10: fatal error: 'llvm-c/Visibility.h' file not found

Copy it next to the bundled headers before running configure.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=bbeba6209f488d4af4283f708a8c2116470820ce&name_0=PR&name_1=Dockers%20Build%20%28arm%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
thevar1able and others added 5 commits August 31, 2026 17:11
LLVM 23's `llvm-c/Visibility.h` includes `llvm/Config/llvm-config.h`
(a self-contained header with only defines), failing the cctools build
with:

    ../include/llvm-c/Visibility.h:19:10: fatal error: 'llvm/Config/llvm-config.h' file not found

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=ab1ed9bbc156d200fb4631e43ebfeb5437c4be66&name_0=PR&name_1=Dockers%20Build%20%28amd%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
apt.llvm.org does not publish llvm-toolchain-jammy-23 (jammy stops at
LLVM 22), so the `test-base` image failed with:

    E: The repository 'https://apt.llvm.org/jammy llvm-toolchain-jammy-23 Release' does not have a Release file.

The fasttest image is already on ubuntu:24.04 (noble), which has the
LLVM 23 repository. The deadsnakes and Kitware repositories key off
`lsb_release -cs` and both publish noble packages.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=f084c9c909095b513039e161c135a4bbb9f2a6dd&name_0=PR&name_1=Dockers%20Build%20%28arm%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
Verified by building test-base and all its children locally:

- fuzzer: the `awscli` apt package has no installation candidate on
  noble; install AWS CLI v2 from the official zip like the fasttest
  and stateless-test images do.
- fuzzer, performance-comparison: drop `dbus-python==1.2.18` from
  requirements.txt (fails to build a wheel without pkg-config and
  libdbus headers; nothing imports `dbus`), and pass
  `--ignore-installed` to pip, because noble ships Debian-packaged
  blinker 1.7.0 without a RECORD file, which pip cannot uninstall.
- test-base: remove the default `ubuntu` user (uid/gid 1000) shipped
  in ubuntu:24.04, which collided with the `clickhouse` user created
  by stateless-test.
- keeper-jepsen-test, server-jepsen-test: `/root/.ssh` already exists
  in the noble-based image, use `mkdir -p`.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=afe00dbf8ddb04427144d91b761ea123673ff17b&name_0=PR&name_1=Dockers%20Build%20%28arm%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
Verified by building both images locally on the noble test-base:

- integration/base: drop `dbus-python==1.2.18` from requirements.txt
  and pass `--ignore-installed` to pip (same as the fuzzer and
  performance-comparison images); `rpm2archive` from rpm 4.18 streams
  to stdout when it is not a tty instead of creating `<file>.tgz`, so
  redirect explicitly.
- integration/runner: the `awscli` apt package has no installation
  candidate on noble; install AWS CLI v2 from the official zip, and
  pass `--ignore-installed` to pip.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=bae483905d9ab4ae43623cc269f567858258795c&name_0=PR&name_1=Dockers%20Build%20%28arm%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
The suppression was gated on clang 24 when the diagnostic only existed
on trunk (for the Emscripten build), but it shipped in the clang 23
release, failing the build with:

    src/Interpreters/InterpreterSelectQuery.cpp:2098:47: error: stack memory associated with local variable 'creating_set_step' may be returned later. This could be a false positive as the storage may have been moved. [-Werror,-Wlifetime-safety-return-stack-addr-moved]

Move it into the clang 23 block next to the other `lifetime-safety-*`
suppressions.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=41a0e27004fbd9d892cb23120f2327a0f75c38d2&name_0=PR&name_1=Fast%20test
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
thevar1able and others added 4 commits August 31, 2026 23:36
clang-tidy 23 added new checks and renamed some existing ones, failing
the tidy build with ~188 unique findings across 22 check names.

Disable the new noisy checks in .clang-tidy (per the policy at the top
of the file), including the new canonical names of already-disabled
checks (`bugprone-signed-bitwise` for `hicpp-signed-bitwise`,
`portability-no-assembler` for `hicpp-no-assembler`) and the new
aliases of `google-explicit-constructor`, whose `NOLINT`s in the code
reference the google name.

Fix the small mechanical findings:
- `modernize-redundant-void-arg`: `std::function<void(void)>` and
  similar in 7 places.
- `readability-redundant-casting`: remove 11 redundant casts.
- `bugprone-unsafe-to-allow-exceptions`: `NOLINT` the deliberately
  throwing `~SimpleFaultInjection`.

Also disable the `lifetime-safety-dangling-field` compiler diagnostic
for clang >= 23: it does not understand a field that is deliberately
cleared (via `SCOPE_EXIT`) before the captured local dies.

All touched translation units compile cleanly in a local debug build.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=ed8367eb17b594dbb12b741e1354473f53f82c11&name_0=PR&name_1=Build%20%28arm_tidy%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
Disable `bugprone-unhandled-code-paths` (new in clang-tidy 23): all 7
findings were on switches already carrying
`NOLINT(bugprone-switch-missing-default-case)`, so the check duplicates
the enabled `bugprone-switch-missing-default-case` for this codebase.

Remove 11 redundant `static_cast<size_t>(i + 1)` casts flagged by
`readability-redundant-casting` in `gtest_coordination_changelog.cpp`;
`i` is already `size_t` in all of them.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=e687a44500e92d797a393e030550f128b219ffa9&name_0=PR&name_1=Build%20%28arm_tidy%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
UBSan in clang 23 reports a misaligned load in the `Install
ClickHouse` step of the asan_ubsan stateless test jobs:

    decompressor.cpp:199:25: runtime error: load of misaligned address
    0x7bd15e3b9161 for type 'const MetaData', which requires 8 byte
    alignment

`MetaData` is read from the end of the mmapped file and `FileData`
records are read at offsets that depend on preceding file name lengths,
so none of these loads are guaranteed to be aligned. Replace the
`reinterpret_cast` dereferences with `memcpy`.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=9102ce6e08d5fe41d5509e4056d3c06138adda1a&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20distributed%20plan%2C%20sequential%2C%20selected%20tests%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
Two reproducible failures in `Stateless tests (arm_binary, parallel)`,
both caused by the test image moving to ubuntu:24.04 rather than by
clang-23:

- `00746_sql_fuzzy`: newer perl prints `Smartmatch is deprecated` to
  stderr (and perl 5.42 removes the operator entirely), and the test
  fails on non-empty stderr. Replace the four `~~` uses with `eq`/`ne`
  comparisons.
- `03036_test_parquet_bloom_filter_push_down`: jq 1.7 preserves the
  precision of 64-bit integer literals, while the reference contains
  values rounded to double by jq 1.6 (`7711695863945022000` instead of
  `7711695863945021976`). Update the reference to the exact values.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=9102ce6e08d5fe41d5509e4056d3c06138adda1a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing b9473fda4 with master 2b1bef1d3 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes, slowest function optimization changes (thinlto), compile time of recompiled translation units.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes ⚠️

16215 object files changed (+220.86 MiB total), 44 added.

Object file Master PR Δ
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/FunctionsNumericIndexedVector.cpp.o 19.54 MiB 18.10 MiB -1.44 MiB (-7.38%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionsArgMinArgMax… 16.09 MiB 17.27 MiB +1.18 MiB (+7.34%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionAvgWeighted.c… 13.68 MiB 14.68 MiB +1.00 MiB (+7.31%)
contrib/cld2-cmake/CMakeFiles/_cld2.dir/__/cld2/internal/cld2_generated_quadchrome_2.cc.o 1.94 MiB 2.94 MiB +1022.74 KiB (+51.46%)
contrib/llvm-project-cmake/CMakeFiles/LLVMPasses.dir/__/llvm-project/llvm/lib/Passes/PassBuilder.cp… 5.66 MiB 6.56 MiB +918.85 KiB (+15.85%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionUniq.cpp.o 13.68 MiB 14.54 MiB +880.06 KiB (+6.28%)
contrib/hive-metastore-cmake/CMakeFiles/_hivemetastore.dir/__/hive-metastore/ThriftHiveMetastore.cp… 5.82 MiB 6.61 MiB +810.80 KiB (+13.60%)
contrib/llvm-project-cmake/CMakeFiles/LLVMVectorize.dir/__/llvm-project/llvm/lib/Transforms/Vectori… 2.62 MiB 3.36 MiB +758.55 KiB (+28.23%)
src/CMakeFiles/dbms.dir/Interpreters/Aggregator.cpp.o 28.56 MiB 29.25 MiB +708.80 KiB (+2.42%)
src/CMakeFiles/dbms.dir/Functions/FunctionsConversion.cpp.o 24.72 MiB 25.35 MiB +645.54 KiB (+2.55%)
src/CMakeFiles/dbms.dir/Core/Settings.cpp.o 3.59 MiB 4.21 MiB +638.56 KiB (+17.39%)
contrib/llvm-project-cmake/CMakeFiles/llvm-tblgen.dir/__/llvm-project/llvm/utils/TableGen/Common/Gl… new 592.13 KiB +592.13 KiB
contrib/llvm-project-cmake/CMakeFiles/LLVMVectorize.dir/__/llvm-project/llvm/lib/Transforms/Vectori… 1.14 MiB 1.68 MiB +549.79 KiB (+47.08%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionRegr.cpp.o 5.95 MiB 6.49 MiB +548.37 KiB (+9.00%)
contrib/llvm-project-cmake/CMakeFiles/LLVMipo.dir/__/llvm-project/llvm/lib/Transforms/IPO/Instrumen… new 533.41 KiB +533.41 KiB
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/avg2.cpp.o 7.32 MiB 7.82 MiB +520.01 KiB (+6.94%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/midpoint.cpp.o 7.31 MiB 7.81 MiB +519.25 KiB (+6.94%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionCorr.cpp.o 7.12 MiB 7.62 MiB +513.16 KiB (+7.04%)
src/Functions/CMakeFiles/clickhouse_functions_obj.dir/modulo.cpp.o 17.46 MiB 17.95 MiB +501.65 KiB (+2.81%)
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/AggregateFunctionCovar.cpp.o 6.93 MiB 7.42 MiB +500.80 KiB (+7.05%)

722 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Slowest function optimization changes (ThinLTO) ⚠️

⚠️ The master baseline has a link trace for programs/clickhouse, programs/clickhouse-keeper but this build uploaded none: the profile producer lost it and the comparison is incomplete.

Compile time of recompiled translation units ⚠️

15989 translation units recompiled, 41506 s compile time in total, 15906 of them have a recent master baseline.

Median compile-time ratio to the baselines is ×1.23 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio.
The matched translation units cost +7200.2 s (+21%) in total before that adjustment.

Translation unit Master PR Δ vs median
src/Functions/FunctionsConversion_reg.cpp 28.2 s 25.9 s -8.9 s (-26%)
contrib/arrow-cmake/__/arrow/cpp/src/arrow/compute/kernels/vector_select_k.cc 15.4 s 13.7 s -5.3 s (-28%)

Translation units without a recent master baseline:

  • contrib/llvm-project-cmake/__/llvm-project/llvm/utils/TableGen/Common/GlobalISel/MatchTable/Matcher…: 5.7 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Target/AArch64/AArch64SRLTDefineSuperRegs.cpp: 5.4 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Target/AArch64/SVEShuffleOpts.cpp: 5.2 s
  • contrib/llvm-project-cmake/__/llvm-project/llvm/lib/Transforms/IPO/Instrumentor.cpp: 5.1 s
Symbol sizes
Binary Symbol Master PR Δ
programs/clickhouse-keeper llvm::AArch64MCRegisterClassStorage new 203.23 KiB +203.23 KiB
programs/clickhouse llvm::AArch64MCRegisterClassStorage new 203.23 KiB +203.23 KiB
programs/clickhouse llvm::InlineFunctionImpl(llvm::CallBase&, llvm::InlineFunctionInfo&, bool, llvm::AAResults*, bool, … 88.11 KiB removed -88.11 KiB (-100.00%)
programs/clickhouse-keeper llvm::InlineFunctionImpl(llvm::CallBase&, llvm::InlineFunctionInfo&, bool, llvm::AAResults*, bool, … 88.02 KiB removed -88.02 KiB (-100.00%)
programs/clickhouse llvm::InlineFunctionImpl(llvm::CallBase&, llvm::InlineFunctionInfo&, bool, llvm::AAResults*, bool, … new 69.59 KiB +69.59 KiB
programs/clickhouse-keeper llvm::InlineFunctionImpl(llvm::CallBase&, llvm::InlineFunctionInfo&, bool, llvm::AAResults*, bool, … new 69.59 KiB +69.59 KiB
programs/clickhouse _ZNSt3__1L18__contention_tableE new 64.00 KiB +64.00 KiB
programs/clickhouse-keeper _ZNSt3__1L18__contention_tableE new 64.00 KiB +64.00 KiB

Job report

thevar1able and others added 2 commits September 2, 2026 04:13
- amd_darwin/arm_darwin: `std::min(total_size - offset, data_capacity)`
  in `ReadBufferFromAzureBlobStorage` fails template deduction on Darwin
  where `off_t` is `long long`, so the subtraction promotes to
  `unsigned long long` while `data_capacity` is `size_t` (aka
  `unsigned long`). Use `std::min<size_t>`.
- arm_fuzzers: the generated `out.pb.h` of `codegen_select_fuzzer` trips
  the new clang 23 `lifetime-safety-lifetimebound-violation` and
  `lifetime-safety-intra-tu-misplaced-lifetimebound` diagnostics.
  Disable them for this target.
- loongarch64: the clang/lld 23 snapshots are mid-transition of the
  LoongArch TLS relocations to the new PCADD scheme; the compiler still
  emits `R_LARCH_TLS_IE_PC_HI20` while `ld.lld-23` fails on it with
  'unknown relocation (87) against symbol thread_local_rng' and then
  crashes. Use `-ftls-model=global-dynamic` until the transition
  settles upstream (llvm/llvm-project#135521).

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=c5327723e4be9b25b184e60b81abdc93115bf1a8&name_0=PR
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
- `00746_sql_fuzzy`: tag as `no-flaky-check` - the test makes up to
  5 runs of 60 seconds each, exceeding the flaky check time limit
  under sanitizers (it entered the flaky check because the previous
  commit edited its .pl script).
- `test_input_format_parallel_parsing_memory_tracking`: since 2024 the
  test generated `data.jsonl` but curl posted `@data.json` - old curl
  warned and sent an empty body, so the test was silently a no-op;
  curl in ubuntu:24.04 hard-errors on the missing file. Fix the file
  name and generate valid `JSONEachRow` data (it was space-separated
  numbers before, which would fail parsing).
- `test_server_overload`: while the wait/busy ratio is still between
  `min_os_cpu_wait_time_ratio_to_throw` and
  `max_os_cpu_wait_time_ratio_to_throw`, a throw is a probabilistic
  Bernoulli draw; the test asserted saturation instead of waiting for
  it. Keep polling until the probability saturates at 1.
- Keeper Stress Tests: `import yaml` worked by accident via the apt
  `awscli` dependency on `python3-yaml`; the ubuntu:24.04 image
  installs AWS CLI v2 from a zip, dropping it. Pin `PyYAML` in the
  integration runner requirements.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=117346&sha=c5327723e4be9b25b184e60b81abdc93115bf1a8&name_0=PR
#117346

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added pr-performance Pull request with some performance improvements and removed pr-build Pull request with build/testing/packaging improvement labels Sep 2, 2026
thevar1able and others added 8 commits September 2, 2026 04:20
Rebased ClickHouse patches from `ClickHouse/release-22.x` onto upstream
`release/23.x` (llvmorg-23.1.0+3). Dropped patches that were merged
upstream: the `ProgramStack.cpp` include fix and the `unordered_map`
copy-constructor node-leak fix with its follow-ups.

CMake adaptation:
- Synced LLVM per-component source lists with 23.x (renames like
  `X86VZeroUpper.cpp` -> `X86InsertVZeroUpper.cpp`, `ExpandMemCmp.cpp`
  moved from CodeGen to Scalar, new TableGen `MatchTable/` files, etc.)
- Added `tsan_adaptive_delay.cpp` and `sanitizer_unwind_aix.cpp` to
  compiler-rt source lists
- Added `text_encoding.cpp` to libcxx sources
- Bumped bundled LLVM version macros to 23.1.0
- Compile libcxx `text_encoding.cpp` with `-std=c++26` (`std::text_encoding`
  is a C++26 feature; upstream builds libcxx sources with a newer standard)
- Add new LLVM 23 tablegen outputs: `X86GenSDNodeInfo.inc`,
  `X86GenPostLegalizeGICombiner.inc`, `IntrinsicsAVR.h`, and the
  `-gisel-extended-llt` flag for `AArch64GenGlobalISel.inc`
- Generate `InstrumentorVariables.inc` needed by the new `Instrumentor`
  pass in `LLVMipo`
- Handle `[[nodiscard]]` on `try_lock_for` in `ProfiledLocks.h` (newly
  annotated in libc++ 23)
- Add missing includes no longer provided transitively by libc++ 23:
  `<atomic>` in Poco JSON `Array.h`, `<cstdlib>` in rocksdb (submodule
  bump), `<array>` in Jieba-CPP (submodule bump)
clang-tidy 23 flags `.get()->` on smart pointers (`readability-redundant-smartptr-get`)
in more contexts, and libc++ 23 makes `std::string` iterators raw pointers, so
`begin().base()` no longer compiles in `gtest_compressionCodec`.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=116787&sha=da3ff9339cf7c2a77486aca83edd682a26824bb2&name_0=PR&name_1=Build%20%28arm_tidy%29
PR: #116787

Co-Authored-By: Claude Fable 5 <[email protected]>
…x commits

Same LLVM 23 include fixes (`<cstdlib>` in rocksdb `stderr_logger`,
`<array>` in `jieba_hmm_seg`), re-authored with the work email and pushed
to reachable branches: `ClickHouse/v10.10.1` in `ClickHouse/rocksdb` and
`clickhouse-submodule` in `thevar1able/Jieba-CPP`.

Co-Authored-By: Claude Fable 5 <[email protected]>
In `release/23.x`, `GlobalISelMatchTable.cpp` was split into
`Common/GlobalISel/MatchTable/{MatchTable,Matchers,Types}.cpp`, and
`lib/Support/APFloat.cpp` now includes `shared/math.h` from the `libc`
project, so `${LLVM_SOURCE_DIR}/../libc` must be on the include path
(matching upstream `LLVMSupport`).

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116787&sha=45de7279e5046c978ae85a97330864dcef89b327&name_0=PR&name_1=Build%20%28amd_binary%29
#116787

Co-Authored-By: Claude Fable 5 <[email protected]>
`PACKAGE_VERSION` is embedded into DWARF producer strings via
`AsmPrinter`, so keep it in sync with the bundled LLVM version.

Co-Authored-By: Claude Fable 5 <[email protected]>
`llvm::ConstantInt::get(type, -1)` implicitly truncates the sign-extended
value to the target width. LLVM 23 asserts that the value is representable
in the given bit width (`APInt.h:127`), so JIT compilation of `groupBitAnd`
aborted in debug builds for types narrower than 64 bits. Use
`llvm::Constant::getAllOnesValue` instead, which is exact for any width.

CI: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=116787&sha=24ff9d93a336ff032a847bf46bb704bae2cea4a9&name_0=PR&name_1=Stateless%20tests%20(amd_debug,%20parallel)
PR: #116787

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot mentioned this pull request Nov 15, 2026
@snelheidai

Copy link
Copy Markdown

@thevar1able @alexey-milovidov, since this PR was merged, CI compiles with apt.llvm.org's clang 23 instead of the PGO+BOLT toolchain. The binary-builder image still installs TOOLCHAIN_COMMIT=bbbf2c95 (a clang 22.1.8 build) into /usr/local/bin, so clang++-23 resolves to /usr/bin/clang++-23 and the linker to /usr/bin/ld.lld-23. Compare the amd_release logs before (/usr/local/bin/clang++-22, /usr/local/bin/ld.lld) and after (/usr/bin/clang++-23, /usr/bin/ld.lld-23). OptimizeToolchain only runs on dispatch; it last ran on 2026-08-14.

The Build ClickHouse step got slower in every build type, by 11-15% in PR runs and 5-13% in MasterCI (default.checks, successful runs; before: 2026-11-11 06:00 UTC to the merge, after: 2026-11-15 18:00 to 2026-11-17 09:00 UTC):

Build PR, p25 MasterCI, p50
amd_release 607 → 684 s (+13%) 1045 → 1160 s (+11%)
arm_release 807 → 926 s (+15%) 1397 → 1561 s (+12%)
amd_binary 206 → 237 s (+15%) 254 → 288 s (+13%)
amd_debug 284 → 314 s (+11%) 346 → 377 s (+9%)
amd_asan_ubsan 271 → 304 s (+12%) 351 → 369 s (+5%)
amd_tsan 240 → 274 s (+14%) 294 → 327 s (+11%)

The cause is the missing PGO+BOLT build, not clang 23. Compiling 96 random src files of master 9b10750 (RelWithDebInfo flags, 16-core Graviton3, two rounds) takes 943 CPU-seconds with apt clang 23.1.6, 988 s with apt clang 22.1.8, and 738 s with CI's PGO+BOLT clang 22.1.8: 22% less than apt clang 23, and faster on every file. Preprocessing alone, which sccache runs for every cached compile, takes 62.7 s with apt clang 23 and 49.6 s with the PGO+BOLT clang 22 (-21%).

Dispatching OptimizeToolchain and merging the Dockerfile PR it opens should restore this. The job has not run since build_toolchain.py moved to LLVM 23 and gained the static jemalloc (#131183) and zstd (#131720). #131745 (jemalloc 5.4.0) also takes effect only through this run, so merging it first saves a second toolchain build and a second round of sccache misses.

@snelheidai

Copy link
Copy Markdown

@alexey-milovidov @groeneai another effect of the LLVM 23 switch: lld now names its time trace <output>.time-trace.json instead of <output>.time-trace (llvm/llvm-project#122207). utils/prepare-time-trace/prepare-time-trace.sh and _RAW_TRACE_RE in build_profile_hook.py only accept .time-trace, so since this merge the link traces of master and PR builds are not extracted, and the "Build profile diff" check has no ThinLTO link data to compare. The hook does not fail, because the compile traces are still extracted.

In build_time_trace, arm_release builds with a programs/clickhouse link trace went from 955 of the 965 builds with compile traces on 2026-11-13 to 217 of 939 on 2026-11-16 (amd_release: 304 of 306 to 125 of 307). Nearly all of the remaining ones are release-branch and backport builds, which still link with lld 22.

The fix below accepts both names and keeps the same file key (.../programs/clickhouse), so the FINAL_BINARIES queries in build_profile_diff_job.py need no change. I checked it with a real clang 23 compile trace and an lld link trace: the current script drops all 40 link rows of clickhouse.time-trace.json, the patched one extracts all 40 under either name, and the compile rows are unchanged.

diff --git a/ci/jobs/scripts/job_hooks/build_profile_hook.py b/ci/jobs/scripts/job_hooks/build_profile_hook.py
index 3759aa31a..8832ddb78 100644
--- a/ci/jobs/scripts/job_hooks/build_profile_hook.py
+++ b/ci/jobs/scripts/job_hooks/build_profile_hook.py
@@ -102,7 +102,7 @@ def _has_data(file):
 # compiled TU (an sccache hit does not run the compiler) plus one per linked
 # binary, so their presence is the ground truth for whether this build was
 # expected to produce time-trace rows.
-_RAW_TRACE_RE = re.compile(r"\.(c|cpp|cc|cxx)\.json$|\.time-trace$")
+_RAW_TRACE_RE = re.compile(r"\.(c|cpp|cc|cxx)\.json$|\.time-trace(\.json)?$")
 
 
 def _raw_traces_exist(directory):
@@ -268,9 +268,11 @@ def check():
     objects_only = build_type in _OBJECTS_ONLY_BUILDS
     try:
         if objects_only:
-            # lld writes the link trace next to its output.
+            # lld writes the link trace next to its output: <output>.time-trace
+            # up to LLVM 22, <output>.time-trace.json from LLVM 23 on.
             for rel in _FINAL_BINARIES:
-                (Path(build_dir) / f"{rel}.time-trace").unlink(missing_ok=True)
+                for suffix in (".time-trace", ".time-trace.json"):
+                    (Path(build_dir) / f"{rel}{suffix}").unlink(missing_ok=True)
         Shell.check(
             "./utils/prepare-time-trace/prepare-time-trace.sh "
             f"{build_dir} {profiles_dir.absolute()}",
diff --git a/utils/prepare-time-trace/prepare-time-trace.sh b/utils/prepare-time-trace/prepare-time-trace.sh
index 10d546553..513794fdd 100755
--- a/utils/prepare-time-trace/prepare-time-trace.sh
+++ b/utils/prepare-time-trace/prepare-time-trace.sh
@@ -60,7 +60,7 @@ OUTPUT_DIR=$2
 
 # A build that was a complete compiler-cache hit compiles nothing and emits no
 # raw trace file at all - that is legitimate, unlike a failing extraction.
-TRACE_FILES=$(find "$INPUT_DIR" -name '*.json' -or -name '*.time-trace' | { grep -P '\.(c|cpp|cc|cxx)\.json|\.time-trace$' || true; })
+TRACE_FILES=$(find "$INPUT_DIR" -name '*.json' -or -name '*.time-trace' | { grep -P '\.(c|cpp|cc|cxx)\.json|\.time-trace(\.json)?$' || true; })
 
 if [[ -n "$TRACE_FILES" ]]
 then
@@ -68,7 +68,7 @@ then
     set -e
     set -o pipefail
 
-    ORIGINAL_FILENAME=\$(echo '{}' | sed -r -e 's!\.(json|time-trace)\$!!; s!/CMakeFiles/[^/]+\.dir!!')
+    ORIGINAL_FILENAME=\$(echo '{}' | sed -r -e 's!\.time-trace(\.json)?\$!!; s!\.json\$!!; s!/CMakeFiles/[^/]+\.dir!!')
     LIBRARY_NAME=\$(echo '{}' | sed -r -e 's!^.*/CMakeFiles/([^/]+)\.dir/.*\$!\1!')
     START_TIME=\$(jq '.beginningOfTime' '{}')
 

@snelheidai

Copy link
Copy Markdown

@thevar1able in all three master OptimizeToolchain runs since this PR, the aarch64 Build Toolchain (PGO, BOLT) job hangs in "Profile collection build (ClickHouse)", so no Dockerfile update PR is opened and CI still compiles with apt clang 23 (earlier comment). One link done by the instrumented stage-1 ld.lld spins forever. Linking that build with the distro ld.lld-23 avoids it without changing the collected profile (patch below).

In each failed run, one of the three links that run at about the same time never finished, and the build printed nothing more once the work that does not depend on it was done:

Run Link that never finished Last progress line
44080845898 (cancelled after 6.7 h) contrib/google-protobuf-cmake/protoc [12899/16948] at 12:50
44186562280 (cancelled after 4.9 h) contrib/grpc-cmake/grpc_cpp_plugin [13007/16957] at 22:46
44238292837 (8 h job timeout) contrib/llvm-project-cmake/llvm-tblgen [11587/16960] at 05:06

The #132530 validation run 44093071861 and all amd64 jobs completed these links with their instrumented linker.

I reproduced it on a Graviton3 host with the same stage 1 (LLVM 23.1.7 9613def24bf4, LLVM_BUILD_INSTRUMENTED=IR, built by apt.llvm.org clang 23.1.6). Relinking llvm-tblgen, clang-tblgen and llvm-min-tblgen concurrently with the instrumented ld.lld --threads=32 hung in 3 of 126 links; the others took 1-2 s. In each hung process the main thread waits in TaskGroup::~TaskGroup, and 4 to 10 worker threads spin in __llvm_profile_instrument_target, called from the parallel chunk writer in OutputSection::writeTo. With apt ld.lld 23.1.6, the same loop completed all 180 links.

The cause is the aarch64 profile runtime. apt.llvm.org's libclang_rt.profile-aarch64.a is built without COMPILER_RT_HAS_ATOMICS, so it uses the fallbacks lprofBoolCmpXchg and lprofPtrFetchAdd, which are plain loads and stores; the x86_64 runtime uses atomics. When lld's worker threads profile the same indirect call, the non-atomic updates can hand one value-profile node to two threads and link it twice, which makes the per-call-site list cyclic, and __llvm_profile_instrument_target walks it forever. Compiles are single-threaded, so only links hang, and only on aarch64.

The instrumented ld.lld contributes nothing to the profile anyway: lld exits through _Exit (lld::exitLld calls Process::Exit(val, /*NoCleanup=*/true)), so it never writes a .profraw. In the reproduction only clang's profile file grew, and no profile file contains an lld:: function.

--- a/ci/jobs/build_toolchain.py
+++ b/ci/jobs/build_toolchain.py
@@ -368,6 +368,10 @@
                 f" -DENABLE_THINLTO=0"
                 f" -DCMAKE_C_COMPILER={STAGE1_INSTALL_DIR}/bin/clang"
                 f" -DCMAKE_CXX_COMPILER={STAGE1_INSTALL_DIR}/bin/clang++"
+                # Link with the distro lld: the instrumented one never writes a profile
+                # (lld exits with `_Exit`), and its multithreaded value profiling uses
+                # non-atomic updates on aarch64, which can make a link spin forever.
+                f" -DLINKER_NAME=ld.lld-{LLVM_VERSION}"
                 f" -DCOMPILER_CACHE=disabled"
                 f" -DENABLE_TESTS=0"
                 f" -DENABLE_UTILS=0"

The compiler's directory has only ld.lld, so ch_find_program resolves ld.lld-23 to /usr/bin/ld.lld-23, from the lld-23 package that the binary-builder image inherits from fasttest.

This branch was successfully deployed

1 active deployment
staging - docs — b9473fda Deployed Nov 13, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-relocation-headroom-ok Accept an expected decrease of the relocation headroom in the build check comp-build-system Build system (CMake, compilation, platform builds). ignore-unresolved-threads Do not limit CI and block merge on unresolved review threads pr-build Pull request with build/testing/packaging improvement pr-performance Pull request with some performance improvements pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants