Skip to content
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

code navigation broken on project with custom toolchain and --incompatible_enable_cc_toolchain_resolution --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 #3319

Closed
redsun82 opened this issue Mar 10, 2022 · 20 comments
Assignees
Labels
lang: c++ C++ rules integration product: CLion CLion plugin topic: bazel Bazel integration (external repositories, aspects, flags, etc) type: user support User support

Comments

@redsun82
Copy link

We have a project where we configured a custom toolchain (using clang as executable on posix) skipping the auto-configured one by bazel. We are setting the --incompatible_enable_cc_toolchain_resolution and --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1. On this project the intellij bazel pluging prints the following warning when synced:

Warning:Unable to access compiler executable
  "<path to bazel cache>/execroot/__main__/external/local_config_cc/gcc".
Check if it is accessible from the cmdline.

and as a consequence, code navigation is more or less completely broken. We do have a workaround, which is to link symbolically clang to the location indicated by the warning, but that's not ideal.

I managed to reduce our case to a rather small project presenting the same warning (on Linux with gcc). You can find it here:

https://github.com/redsun82/foo

I noticed dropping --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 removes the warning, but my guess is that in that case the plugin will then use the host auto-configured compiler instead of the custom one.

@jesseschalken
Copy link

I believe the Bazel CLion plugin's toolchain resolution is still based on --crosstool_top, --compiler and --cpu and is yet to be upgraded to platforms and toolchains, and you will have to set those to an appropriate value to allow CLion to find the compiler. You can also use a platform mappings file.

@redsun82
Copy link
Author

Thanks for the pointer, I was unaware of the platform mappings migration feature, I will definitely try that!

@jesseschalken
Copy link

I tried to tell CLion about my compiler through platform mappings yesterday and couldn't get it to work. Not sure if I was doing it right or my plugin is out of date but you might need to add the command line options directly to your .bazelrc.

@redsun82
Copy link
Author

redsun82 commented Mar 16, 2022

yeah, I ended up with the same result, and the same solution 😄 I added a cc_toolchain_suite target (which is not required with the platform-driven toolchain resolution) and the --crosstool_top option in .bazelrc, with notes to remove them when CLion allows it.

Still, many thanks for pointing me in the right direction 😉

@sgowroji
Copy link
Member

sgowroji commented Nov 7, 2022

Hello @redsun82, Are you still looking support on the above issue. Thanks!

@sgowroji sgowroji added product: CLion CLion plugin topic: bazel Bazel integration (external repositories, aspects, flags, etc) lang: c++ C++ rules integration type: user support User support more-data-needed Awaiting response from issue author labels Nov 7, 2022
@LittleHuba
Copy link

I'm facing the same issue and assume that this is the underlying problem:
bazelbuild/bazel#12712

@sgowroji sgowroji added awaiting-maintainer Awaiting review from Bazel team on issues and removed more-data-needed Awaiting response from issue author labels Nov 9, 2022
@maxwellgumley-brt
Copy link

Can anyone provide a status update on this issue? I'm getting a warning every time use bazel-sync.

Warning:Unable to access compiler executable "(...)/cc_wrapper.sh".
Check if it is accessible from the cmdline.

@tpasternak
Copy link
Collaborator

I just tried the example above, prepared by @redsun82, and in my case CLion seems to load the correct toolchain. Maybe it was fixed in the meantime?

@tpasternak tpasternak removed their assignment Apr 6, 2023
@tpasternak tpasternak added awaiting-user-response Awaiting response from author on PRs and removed awaiting-maintainer Awaiting review from Bazel team on issues labels Apr 6, 2023
@raoarun
Copy link
Collaborator

raoarun commented Apr 21, 2023

@maxwellgumley-brt @redsun82 is this still an issue?

@maxwellgumley-brt
Copy link

@raoarun It is, but I'm not sure we're on the latest version. What version was it fixed in?

@tpasternak
Copy link
Collaborator

@maxwellgumley-brt we are not sure if everything works correct, I just can't reproduce it. When I'm trying to import the example prepared by @redsun82 , indexing just works. But when I tried it once again I noticed that debugger does not work so definitely there's something wrong here.

@tpasternak tpasternak added the P3 We're not considering working on this, but happy to review a PR. (No assignee) label Apr 26, 2023
@charles-toller
Copy link

Just tried version 2023.04.18.0.1-api-version-231 and am experiencing the same issue.

@tpasternak
Copy link
Collaborator

@charles-toller thanks for reaching out. Would it be possible for you to compare your project to the example above and try to find out what could be modified there in order to reproduce the issue?

Copy link

github-actions bot commented Nov 4, 2023

Thank you for contributing to the IntelliJ repository! This issue has been marked as stale since it has not had any activity in the last 6 months. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-maintainer". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Nov 4, 2023
@ujohnny ujohnny removed P3 We're not considering working on this, but happy to review a PR. (No assignee) awaiting-user-response Awaiting response from author on PRs labels Nov 17, 2023
@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Nov 18, 2023
@garethellis0
Copy link

garethellis0 commented Dec 6, 2023

The example provided by @redsun82 produces the expected error on indexing on my system, without any additional modification. @tpasternak - have you tried to reproduce on a clean system?

Plugin Ver: 2023.11.23.0.1-api-version-233

Warning:Unable to access compiler executable "/home/gellis/.cache/bazel/_bazel_gellis/16ecdb2c16e491184f86f97272d7cbbe/external/local_config_cc/gcc".
Check if it is accessible from the cmdline.

@ujohnny
Copy link
Collaborator

ujohnny commented Dec 6, 2023

@garethellis0 we both tried and for some reason the issue does not reproduce on our side. The last my attempt was 2 weeks ago and I started to think that it might be some stale issue, but sounds like it's not. Could you please provide more details on the bazel version you use, your system etc. that might help us? We can also chat about this one on bazelbuild.slack.com in #intellij channel, and any sensitive data might be shared via https://uploads.jetbrains.com

@garethellis0
Copy link

garethellis0 commented Dec 6, 2023

bazel version: bazel 4.2.2-5
os: ubuntu 20.04

I'll start a thread in slack as well.

Thanks for the speedy reply!

@ujohnny
Copy link
Collaborator

ujohnny commented Dec 10, 2023

@garethellis0 I'm not sure if I will be able to address this before the Christmas since I have vacation starting middle of the next week and then will be available only from 2nd week 2024. There is a little chance that we can sort us some legal questions with Google, so I might look into this, but I can't promise that. Hope for your understanding.

btw I tried to reproduce this with bazel 6.4.1, so this might be the case that I wasn't able to get it failed.

@garethellis0
Copy link

garethellis0 commented Dec 13, 2023

I just got around to testing the original repro from @redsun82 with bazel 6.4.0, and it seems the issue is addressed, the repro runs without issue! IMO we can close this ticket out.

@tpasternak
Copy link
Collaborator

ok, closing for now, feel free to reopen/create a new one if the problem comes back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: c++ C++ rules integration product: CLion CLion plugin topic: bazel Bazel integration (external repositories, aspects, flags, etc) type: user support User support
Projects
Development

No branches or pull requests

10 participants