Skip to content

CLion: Only forward builtin includes from a custom sysroot #7667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 11, 2025

Conversation

LeFrosch
Copy link
Collaborator

Discussion thread for this change

Issue number: #7489

Description of this change

Builtin includes reported by the CcToolchainInfo provider sometimes contain include paths for both libc++ and libstdc++ regardless of what compiler options are specified. CLion is able to find the right include path during compiler info collection automatically. But if both include paths are manually added to the switch builder CLion might select the wrong one after all.

Therefore, only forward builtin includes which point into a custom sysroot and let CLion detect the correct builtin includes during compiler info collection.

@LeFrosch LeFrosch changed the title CLion only forward builtin includes from a custom sysroot CLion: Only forward builtin includes from a custom sysroot May 12, 2025
@LeFrosch LeFrosch marked this pull request as ready for review May 15, 2025 11:43
@github-actions github-actions bot added product: CLion CLion plugin product: IntelliJ IntelliJ plugin product: GoLand GoLand plugin awaiting-review Awaiting review from Bazel team on PRs labels May 15, 2025
@LeFrosch
Copy link
Collaborator Author

This change requires further investigation, why does Bazel report both include directories? What if toolchain actually does define include paths that are not in the sysroot and cannot be discovered by CLion?

@LeFrosch
Copy link
Collaborator Author

As far as I understand the issue here is caused by a bug in rules_cc. Maybe we should not forward all include paths reported by rules_cc since they have proven to be unreliable and instead relay on CLions compiler info collection.

But not sure yet how to filter the include paths reported by rules_cc.

// includes can lead to headers being resolved into the wrong include directory.
final var sysroot = compilerSettings.getSysroot();
if (sysroot != null) {
compilerSettings.getBuiltInIncludes().stream()
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's revise this PR and consider doing this with registry key. I'm unsure if this change as is would lead to some unresolved headers etc, this has to be validated with custom toolchain with sysroot.

@ujohnny ujohnny merged commit e92c0df into bazelbuild:master Jul 11, 2025
5 checks passed
@github-project-automation github-project-automation bot moved this from Untriaged to Done in Bazel IntelliJ Plugin Jul 11, 2025
@github-actions github-actions bot removed the awaiting-review Awaiting review from Bazel team on PRs label Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: CLion CLion plugin product: GoLand GoLand plugin product: IntelliJ IntelliJ plugin
Projects
Development

Successfully merging this pull request may close these issues.

4 participants