Skip to content

Conversation

@chrapkowski-sg
Copy link

Update scip-clang to newer Clang 21 version

@chrapkowski-sg
Copy link
Author

chrapkowski-sg commented Dec 30, 2025

This change is part of the following stack:

Change managed by git-spice.

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch from 1ca46e8 to 41926df Compare December 30, 2025 16:37
llvm::dyn_cast<clang::CXXRecordDecl>(baseType->getDecl());
if (!baseRecord || !baseRecord->hasDefinition())
continue;
auto baseResults =
Copy link
Author

Choose a reason for hiding this comment

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

CXXRecordDecl::lookupDependentName() was removed from the Clang API in LLVM 21. This is a local reimplementation with the same semantics.

Copy link
Member

Choose a reason for hiding this comment

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

Looked up the reason why it was removed: llvm/llvm-project#128392. It seems there is a newer API that should be used instead (HeuristicResolver).

auto symbol = optSymbol.value();

if (functionDecl.isPure() || functionDecl.isThisDeclarationADefinition()) {
if (functionDecl.isPureVirtual() || functionDecl.isThisDeclarationADefinition()) {
Copy link
Author

Choose a reason for hiding this comment

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

isPure() was renamed to isPureVirtual() in LLVM 21 for clarity.

}
DERIVE_CMP_ALL(FileLocalSourceRange)
DERIVE_EQ_ALL(FileLocalSourceRange)

Copy link
Author

Choose a reason for hiding this comment

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

DERIVE_CMP_ALL now generates operator== via C++20 operator<=>, making DERIVE_EQ_ALL redundant and causing a compile error.

@@ -0,0 +1,29 @@
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
Copy link
Author

Choose a reason for hiding this comment

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

Cherry-pick fix for CUDA assertion failure from llvm/llvm-project#173762. Can be removed once LLVM merges the fix.

# LLVM 21 uses new naming convention: LLVM-VERSION-Platform.tar.xz
# with strip prefix LLVM-VERSION-Platform
grailbio_llvm_toolchain(
name = name,
Copy link
Author

Choose a reason for hiding this comment

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

LLVM 21 changed release archive naming from clang+llvm-VERSION-TRIPLE to LLVM-VERSION-Platform.

#include "boost/interprocess/ipc/message_queue.hpp"
#pragma clang diagnostic pop

#include "llvm/ADT/Optional.h"
Copy link
Author

Choose a reason for hiding this comment

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

llvm::Optional was removed in favor of std::optional. This include is no longer needed.

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch 2 times, most recently from 88b71cb to 3480a7a Compare December 30, 2025 19:35
@@ -52,7 +52,6 @@
// ^^ reference local 5

g1<<<undeclared, 1>>>(42); // expected-error {{use of undeclared identifier 'undeclared'}}
Copy link
Author

Choose a reason for hiding this comment

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

In the line g1<<<undeclared, 1>>>(42);, when the kernel configuration contains an undeclared identifier (undeclared), Clang 21 no longer generates a DeclRefExpr for the callee function g1

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch from 3480a7a to 0fb5ccf Compare January 2, 2026 00:35
.bazelrc Outdated
common --enable_platform_specific_config

# Disable bzlmod for now - WORKSPACE dependencies not yet migrated
common --enable_bzlmod=false
Copy link
Author

Choose a reason for hiding this comment

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

Update to bazel 7 but we still use WORKSPACE not modules

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch from 0fb5ccf to 329783f Compare January 2, 2026 00:38
# Based on release notes from since we're on Bazel < 7
# https://github.com/bazel-contrib/toolchains_llvm/releases/tag/0.10.3
build --features=-supports_dynamic_linker
build --features=-libtool
Copy link
Author

Choose a reason for hiding this comment

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

We use bazel 7+ so no longer needed

build --incompatible_enable_cc_toolchain_resolution

build --repo_env BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
build --@llvm_zstd//:llvm_enable_zstd=false
Copy link
Author

Choose a reason for hiding this comment

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

We use bazel 7+ so no longer needed

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch 13 times, most recently from faff6c7 to 235fa63 Compare January 2, 2026 14:58
@chrapkowski-sg chrapkowski-sg marked this pull request as ready for review January 2, 2026 15:07
@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch 2 times, most recently from ea1763e to 3333e18 Compare January 7, 2026 14:50
@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch 4 times, most recently from ed33a2f to 5aab1f5 Compare January 9, 2026 17:57
@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch from 5aab1f5 to 2d95b5c Compare January 9, 2026 18:11
@chrapkowski-sg
Copy link
Author

The Release workflow triggered for this PR failed. This must be fixed before the PR can be merged. That said, the error doesn't seem to be caused by the code changes ("No space left on device," and I was able to build scip-clang manually on both Linux and macOS).

While not a hard requirement right now, in the future it would be nice to split such PRs into separate scopes (in this case, I imagine something like a Bazel update and a Clang update).

Overall, this looks good to me. Once we have the Release pipeline working, this should be easy to merge.

https://github.com/sourcegraph/scip-clang/actions/runs/20861193543

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch 3 times, most recently from 07231da to 9b2b1b9 Compare January 14, 2026 15:05
@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch from 9b2b1b9 to 3c2472a Compare January 14, 2026 15:11
@chrapkowski-sg chrapkowski-sg requested a review from jupblb January 14, 2026 16:41
Copy link
Member

@jupblb jupblb left a comment

Choose a reason for hiding this comment

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

Please fix //tools:compdb and replace tryFindDeclForBaseType with HeuristicResolver.

- build:
targets:
- //...
- -//tools:compdb # Exclude: com_grail_bazel_compdb is incompatible with current toolchain
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me that //tools:compdb is overall broken by this PR. This must be addressed as compile_commands.json is needed for local development (and C++ SCIP index generation). If there is an alternative way to generate this file that's also fine.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you are right of course.

I replaced:

load("@com_grail_bazel_compdb//:defs.bzl", "compilation_database")

with

load("@hedron_compile_commands//:refresh_compile_commands.bzl", "refresh_compile_commands")

Since compdb is unmaintained https://github.com/grailbio/bazel-compilation-database "This repository was archived by the owner on Mar 17, 2024. It is now read-only. "

llvm::dyn_cast<clang::CXXRecordDecl>(baseType->getDecl());
if (!baseRecord || !baseRecord->hasDefinition())
continue;
auto baseResults =
Copy link
Member

Choose a reason for hiding this comment

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

Looked up the reason why it was removed: llvm/llvm-project#128392. It seems there is a newer API that should be used instead (HeuristicResolver).

if bazel-bin/external/llvm_toolchain/clang-format --version >/dev/null 2>&1; then
CLANG_FORMAT="bazel-bin/external/llvm_toolchain/clang-format"
elif command -v clang-format >/dev/null 2>&1; then
echo "Warning: Using system clang-format (LLVM toolchain version not compatible with this system)"
Copy link
Member

Choose a reason for hiding this comment

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

Is this still an issue on newer OS like macOS Tahoe or Ubuntu 24.04? If not, I'd revert these changes.

strip_prefix = "abseil-cpp-%s" % _ABSL_COMMIT,
urls = ["https://github.com/abseil/abseil-cpp/archive/%s.zip" % _ABSL_COMMIT],
patch_args = ["-p1"],
patches = ["//third_party:abseil.patch"],
Copy link
Member

Choose a reason for hiding this comment

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

File with this patch can be removed.

# On Linux, use the bundled libc++ (builtin-libc++) for hermetic builds.
stdlib = {
"darwin-aarch64": "libc++",
"darwin-x86_64": "libc++",
Copy link
Member

Choose a reason for hiding this comment

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

We should drop support for darwin-x86_64 (can be done in another PR).


# macOS SDK path for system libc++ headers
# This is the standard location for Xcode Command Line Tools SDK
_MACOS_SDK = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment that this variable should be set to xcrun --show-sdk-path output.

## IDE integration

Run `./tools/regenerate-compdb.sh` to generate a compilation database
Run `./tools/regenerate-compile-commands.sh` to generate a compilation database
Copy link
Author

Choose a reason for hiding this comment

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

Since compdb has been removed, I renamed this tool to avoid confusion and coupling with underlaying tool name

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch from c3872c4 to c4e0b9b Compare January 21, 2026 13:28
self.arguments = shlex.split(entry["command"])
except KeyError:
self.arguments = entry(["arguments"])
self.arguments = entry["arguments"]
Copy link
Author

Choose a reason for hiding this comment

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

Bugfix in error handling

@chrapkowski-sg chrapkowski-sg force-pushed the cu-2083-update-scip-clang-to branch from c4e0b9b to 9636366 Compare January 21, 2026 13:33
# The --features flags disable module_maps which is incompatible with the
# grailbio/bazel-compilation-database library (archived, no longer maintained).
# See: https://github.com/grailbio/bazel-compilation-database/issues/101
bazel build //tools:compdb --features=-layering_check --features=-module_maps
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't seem to me that we use com_grail_bazel_compdb anymore? What is the consequence of disabling module_maps and layering_check?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, noticed #508 (comment)

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.

4 participants