Skip to content

chore: bump LLVM to 77e43ec1 (May 21, 2026)#1241

Open
gennaroprota wants to merge 3 commits into
cppalliance:developfrom
gennaroprota:chore/bump_llvm_for_macro_comment_support
Open

chore: bump LLVM to 77e43ec1 (May 21, 2026)#1241
gennaroprota wants to merge 3 commits into
cppalliance:developfrom
gennaroprota:chore/bump_llvm_for_macro_comment_support

Conversation

@gennaroprota

@gennaroprota gennaroprota commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

The new pin includes llvm/llvm-project#198452, which attaches documentation comments to macro definitions. That is the prerequisite for reading them from Clang directly instead of scanning the source, as we were initially doing in PR #1192.

Changes

  • Third-party: Bump LLVM to 77e43ec1 (Associate documentation comments with macro definitions llvm/llvm-project#198452).

  • CI: Update the hardcoded LLVM hash in the cache key (ci-matrix.yml) and its mirror unit test (test_cache_keys.py) to match the new pin, so the key misses and LLVM builds fresh instead of restoring the old install. Build an instrumented libc++ for MSan only (the newer libc++ needs the latest Clang, and ASan works with the normal libc++), and prune the LLVM source tree's stray .profraw fixtures.

  • Source: The pin was about six months behind, so this also adapts MrDocs to the Clang API changes across that range:

    • USRGeneration.h moved from clang/Index to clang/UnifiedSymbolResolution; the clang::index namespace and signatures are unchanged.
    • clang::DiagnosticConsumer::finish() was removed, so the collecting diagnostic consumer relies on the forwarded EndSourceFile() instead.
    • The driver option table moved to clang/Options/Options.h, with its enumerators now in clang::options and getDriverOptTable() in clang.
    • cl::getRegisteredOptions() now returns a DenseMap, so its entries expose .second instead of getValue().
    • SubstituteConstraintExpressionWithoutSatisfaction was re-synced with Clang's current implementation.

    getRawCommentForDeclNoCache, the per-declaration comment lookup getDocumentation relied on, is no longer public. Its only public replacement, getRawCommentForAnyRedecl, follows the redeclaration chain and so cannot return a single declaration's own comment. getDocumentation keeps the per-declaration behavior by porting Clang's declaration-path comment search (getLocsForCommentSearch and getRawCommentNoCacheImpl) as file-local helpers.

    Parsing the newer libc++ also needs a new vcruntime_new.h stub and C++ guards so stdbool.h, stdalign.h, and threads.h stop redefining bool, alignas, and thread_local, which are keywords, not macros, in C++.

  • Golden tests: The regenerated goldens change only because Clang's output drifted over the six months: constrained templates and destructors get different symbol IDs from USR generation, though their structure is identical (requires-clause, dtor-overloads), and a few declaration locations shifted by a line or column (auto, param-types, function-template).

Testing

No new tests are added; this is a toolchain bump. The existing unit and golden suites already cover the affected behavior and run in CI on every build, and the goldens whose output changed have been regenerated as described above.

Documentation

No documentation changes are needed: this is an internal toolchain bump with no user-facing API changes.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

✨ Highlights

  • 🧪 Existing golden tests changed (behavior likely shifted)

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🛠️ Source 71% 442 242 200 7 1 6 - -
🔧 Toolchain Tests 13% 80 54 26 3 - 3 - -
🥇 Golden Tests 6% 38 19 19 5 - 5 - -
🔧 Toolchain 5% 33 23 10 2 - 2 - -
⚙️ CI 2% 14 11 3 2 - 2 - -
🧪 Unit Tests 1% 6 3 3 1 - 1 - -
🤝 Third-party 1% 6 3 3 1 - 1 - -
Total 100% 619 355 264 21 1 20 - -

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • src/lib/MrDocsCompilationDatabase.cpp (Source): 274 lines Δ (+137 / -137)
  • src/lib/AST/ClangHelpers.cpp (Source): 87 lines Δ (+60 / -27)
  • share/mrdocs/headers/libc-stubs/vcruntime_new.h (Source): 41 lines Δ (+41 / -0)

Generated by 🚫 dangerJS against cc2c819

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (197e765) to head (cc2c819).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1241   +/-   ##
========================================
  Coverage    83.16%   83.16%           
========================================
  Files           35       35           
  Lines         3658     3660    +2     
  Branches       843      844    +1     
========================================
+ Hits          3042     3044    +2     
  Misses         409      409           
  Partials       207      207           
Flag Coverage Δ
bootstrap 83.16% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot

cppalliance-bot commented Jul 2, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://1241.mrdocs.prtest2.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-07-09 14:35:48 UTC

@gennaroprota gennaroprota force-pushed the chore/bump_llvm_for_macro_comment_support branch 5 times, most recently from c7b6850 to feddc6f Compare July 7, 2026 10:29

@alandefreitas alandefreitas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice bump :)

Reimplementing rawCommentForDecl ourselves ended up a little verbose. We could add the pinned commit (77e43ec1) to the comment on locsForCommentSearch so the next bump can compare the port against the exact revision it came from. We could also check why they removed it in their PRs, issues and git blame (doing that might even reveal a better way of doing things) and we should consider filing an issue upstream asking to re-expose a per-declaration lookup (making getRawCommentNoCache public would do). If Clang takes it, we can delete the port on a later bump.

# *.profraw.
- name: Prune third-party profraw
if: matrix.coverage
run: find build/third-party -name '*.profraw' -delete

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What’s this profraw issue? The explanation is more descriptive than explanatory of the motivation of the command. It seems to me like if this is happening and coverage is globing the wrong directory, that’s what should be fixed instead of a second workaround to accommodate the first mistake.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that the coverage step scans build/ for *.profraw, which happens to include the *.profraw test fixtures in the LLVM extracted source tree; but they are in an older format, which makes the llvm-profdata merge fail. I'm not sure why this issue didn't occur when the cache was cold, the first time. Yes, this would better be fixed in the action.

Comment thread .github/workflows/ci-matrix.yml Outdated
append-common-cxxflags: |
clang: -gz=zstd
extra-values: |
# libc++ runtimes: clang + (ASan or MSan) needs instrumented libc++

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these gone? Weren't they being used? Interesting. I thought we used the custom libc++ whenever we had msan or asan. It it because the logic for this necessity is now being checked in the bootstrap script?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this was an unrelated change, I restored them. Anyway, the decision of whether to build an instrumented libc++ is made in bootstrap, even on develop.

// Non-allocating placement allocation functions
void* operator new ( std::size_t count, void* ptr );
void* operator new[]( std::size_t count, void* ptr );
#include <vcruntime_new.h>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Is this something being fixed in passing or do we have something about the new version that interacts with the libc stubs? In fact, I would have this question about all other changes to the libc stubs. It's unexpected to me that they interacted in an LLVM bump.

<source-path>function-template.cpp</source-path>
<line-number>22</line-number>
<column-number>6</column-number>
<column-number>1</column-number>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes to line numbers and column numbers are curious. Since the fixtures didn't change, we need to check whether they were broken before or whether they're broken now. Or maybe they're referencing a different part of the symbol.

Comment thread util/bootstrap/src/recipes/builder.py Outdated
return False
san = sanitizer_flag_name(sanitizer.lower())
if san not in ("address", "memory"):
if san != "memory":

@alandefreitas alandefreitas Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could discuss this with Matheus, but I believe the changes to this file are incorrect. At the very least we lose some std lib annotations, and so on. ASan doesn't need sanitized dependencies as much as MSan but it's less effective without sanitized dependencies. And we're building+caching our own libc++ anyway so the cost is low.

#ifndef MRDOCS_SHARE_HEADERS_LIBC_STUBS_VCRUNTIME_NEW_H
#define MRDOCS_SHARE_HEADERS_LIBC_STUBS_VCRUNTIME_NEW_H

// libc++ includes this Microsoft runtime header (through <__new/align_val_t.h>)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole comment, especially "Provide just enough of it for parsing." seems redundant because this is true for all stubs by definition. They're headers libc++ includes for its own functionality and we provide only enough for parsing.

@gennaroprota gennaroprota force-pushed the chore/bump_llvm_for_macro_comment_support branch from feddc6f to e0bd9e6 Compare July 8, 2026 10:16
@gennaroprota

Copy link
Copy Markdown
Collaborator Author

Reimplementing rawCommentForDecl ourselves ended up a little verbose. We could add the pinned commit (77e43ec1) to the comment on locsForCommentSearch so the next bump can compare the port against the exact revision it came from. We could also check why they removed it in their PRs, issues and git blame (doing that might even reveal a better way of doing things) and we should consider filing an issue upstream asking to re-expose a per-declaration lookup (making getRawCommentNoCache public would do). If Clang takes it, we can delete the port on a later bump.

Good news! None of the above applies! :-) Turns out that I misread ASTContext.h and getRawCommentNoCache is public (the declaration appears to be in what seems a private section at first glance, but it's public)! So I'm using that now. Good that we re-examined this.

@gennaroprota gennaroprota force-pushed the chore/bump_llvm_for_macro_comment_support branch from e0bd9e6 to 21e4e77 Compare July 9, 2026 09:54
The new pin includes llvm/llvm-project#198452, which attaches
documentation comments to macro definitions. That is the prerequisite
for reading them from Clang directly instead of scanning the source, as
we were initially doing in PR cppalliance#1192.

The pin was about six months behind, so this also adapts MrDocs to the
Clang API changes across that range:

- USRGeneration.h moved from clang/Index to
  clang/UnifiedSymbolResolution; the `clang::index` namespace and
  signatures are unchanged.
- `clang::DiagnosticConsumer::finish()` was removed, so the collecting
  diagnostic consumer relies on the forwarded `EndSourceFile()` instead.
- The driver option table moved to clang/Options/Options.h, with its
  enumerators now in `clang::options` and `getDriverOptTable()` in
  `clang`.
- `cl::getRegisteredOptions()` now returns a `DenseMap`, so its entries
  expose `.second` instead of `getValue()`.
- `SubstituteConstraintExpressionWithoutSatisfaction` was re-synced with
  Clang's current implementation.

Parsing the newer libc++ also needs a new vcruntime_new.h stub, since
its align_val_t.h now includes vcruntime_new.h under the vcruntime ABI.

The regenerated goldens change only because Clang's output drifted over
the six months: constrained templates and destructors get different
symbol IDs from USR generation, though their structure is identical
(requires-clause, dtor-overloads), and a few declaration locations
changed.
The MSan and ASan jobs build MrDocs against a sanitizer-instrumented
libc++. MSan requires that, since it reports false positives on any
uninstrumented code; ASan doesn't require it, but is more effective with
it, through libc++'s container-overflow annotations.

The pinned libc++ contains a self-guard (added upstream in
llvm/llvm-project#168955) that errors out when an ASan-instrumented
libc++ is parsed without ASan, and MrDocs parses libc++ with normal
flags for the libcxx.cpp golden. So an instrumented libc++ can no longer
double as the one MrDocs reads.

Thus, install both an instrumented and an uninstrumented libc++.
Specifically, install the instrumented libc++ into a prefix separate
from the main LLVM build's plain libc++; `needs_libcxx_runtimes` still
selects it for Clang + ASan/MSan. MrDocs links the instrumented library
through `libcxx_runtime_flags` but parses the plain headers the main
build leaves at the LLVM install prefix.

Also, move Clang ASan and MSan to the latest Clang, since building the
pinned libc++ from source needs a recent one.
The coverage step globs build/ for *.profraw, which after the bump also
holds the extracted LLVM source tree. That tree ships llvm-profdata test
fixtures in an older raw-profile version that llvm-profdata rejects,
failing the merge. Delete build/third-party profraw first; MrDocs' own
profraw live elsewhere under build/.
@gennaroprota gennaroprota force-pushed the chore/bump_llvm_for_macro_comment_support branch from 21e4e77 to cc2c819 Compare July 9, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants