Skip to content

Cherry pick #98882 to 26.3: Use llvm-project 22.1.1 - #122872

Merged
PedroTadim merged 13 commits into
backport/26.3/98882from
cherrypick/26.3/98882
Sep 29, 2026
Merged

PedroTadim merged 13 commits into
backport/26.3/98882from
cherrypick/26.3/98882

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

Original pull-request #98882

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

thevar1able and others added 13 commits March 5, 2026 19:54
Update the `contrib/llvm-project` submodule from LLVM 21 (release/21.x)
to LLVM 22 (release/22.x). All 11 ClickHouse-specific patches were
cherry-picked onto the new `ClickHouse/release-22.x` branch in the fork;
the e2k `config.guess` patch was already upstream and skipped.

Changes in the main repo:
- Bump `LLVM_VERSION` to `22.1.1bundled`
- Add `_LIBCPP_ASSERTION_SEMANTIC_DEFAULT` to `__config_site` (new
  requirement in LLVM 22 hardening framework)
- Remove `common_constants.cpp` from `libllvmlibc` sources (moved to
  header-only in LLVM 22)

Assisted-by: Claude Opus 4.6 via GitHub Copilot
LLVM 22 libc++ removed transitive includes that older versions
provided. Code relying on `<map>` being transitively included
now needs an explicit include.

Assisted-by: Claude Opus 4.6 via GitHub Copilot
- `StorageFile.cpp`: suppress `[[nodiscard]]` warning on `fs::canonical`
  called only for its side-effect (throwing if file does not exist)
- `StorageMergeTree.cpp`: suppress thread-safety analysis on
  `movePartitionToTable` where `std::lock` + `std::adopt_lock` pattern
  for two mutexes is correct but opaque to the analyzer

Assisted-by: Claude Opus 4.6 via GitHub Copilot
LLVM 22 libc++ removed implicit `operator==` synthesis for types
that only define `operator!=`. The `TEnumIterator` class in thrift
0.16.0 only had `operator!=`, causing build failures with the new
`__tree::__insert_range_unique` that requires `operator==`.

Upstream fixed this in apache/thrift PR #2633 (THRIFT-5603),
included in v0.22.0. Cherry-picked the ClickHouse locale patch
(`std::locale::classic()` instead of `std::locale("C")`) on top.

Assisted-by: Claude Opus 4.6 via GitHub Copilot
- `Intrinsic::getDeclaration` renamed to `Intrinsic::getOrInsertDeclaration`
  in LLVM 22 (abs.cpp, bitCount.cpp)
- `createTargetMachine` first argument changed from `StringRef` to
  `const Triple&` — construct `llvm::Triple` explicitly (CHJIT.cpp)
- `std::__gcd` internal removed from libc++ — use `std::gcd` from
  `<numeric>` (AggregateFunctionKolmogorovSmirnovTest.cpp)
- Added `(void)` casts for new `[[nodiscard]]` on `std::stod`,
  `std::filesystem::is_directory`, and `future.get()`
  (KQLGeneralFunctions.cpp, LocalServer.cpp,
  ZooKeeperRemoveByList.cpp, EphemeralLockInZooKeeper.cpp)

Assisted-by: Claude Opus 4.6 via GitHub Copilot
Construct DataTypeQBit on the stack instead of using std::make_shared,
avoiding the unused-result warning on the discarded shared_ptr.
The LLVM 22 libc++ upgrade changed std::unordered_map behavior such that
a copy no longer preserves iteration order. This exposed two latent bugs
in the text index prewhere machinery:

1. `IndexReadTasks` (`std::unordered_map`) is copied into
   `MergeTreeReadPoolBase` and then iterated independently in
   `getPrewhereActions` / `getReadTaskColumns`.  When the copy has a
   different iteration order, prewhere readers and actions get paired by
   index incorrectly, producing either LOGICAL_ERROR (column count
   mismatch) or ILLEGAL_TYPE_OF_COLUMN_FOR_FILTER (String in a filter
   position).  Fixed by switching to `std::map` for deterministic order.

2. The `MergeTreeRangeReader` constructor executed prewhere step actions
   on `result_sample_block` for `None`-type steps (text index read
   steps), but `executePrewhereActionsAndFilterColumns` skips them at
   runtime.  This caused the sample block column order to diverge from
   the actual data, leading to wrong query results when two text indexes
   are present.  Fixed by skipping action execution on the sample block
   for `None`-type steps, matching the runtime behavior.
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request labels Sep 29, 2026
@PedroTadim
PedroTadim merged commit 938c576 into backport/26.3/98882 Sep 29, 2026
477 of 489 checks passed
@PedroTadim
PedroTadim deleted the cherrypick/26.3/98882 branch September 29, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants