-
Notifications
You must be signed in to change notification settings - Fork 313
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
Mac support: Bazel plugin doesn't work with C++ std lib and repositories #109
Comments
+1 |
1 similar comment
+1 |
Is there an example project we could try loading? |
Thanks for helping out, Jan! I attached my *intellij-info.txt file. The cc_toolchain deps look like this:
I'll attempt to repro this with a toy project and will update the issue if successful. |
I'm on a Mac laptop too. |
I managed to repro this with a trivial HelloWorld project, which I uploaded here: https://github.com/danieldanciu/clion-bazel Attached is the bazel-bin/hello.intellij-info.txt file. |
Thanks for the repro! I think the issue is that the plugin needs to be able to get toolchain info from "apple_cc_toolchain" rule kinds and not just "cc_toolchain" rule kinds. |
Thanks for looking into this, Jan. Do you have a feeling on how much work it is to get toolchain info from apple_cc_toolchain? Are there any workarounds we could use to make bazel/clion work on our macs? |
Separately to the apple_cc_toolchain issue, a quick note that we currently only support Linux. We've heard anecdotally that the Bazel plugin already basically works on Macs, but it's not something we've tested. We do intend to support it in the future, but it's not currently a top priority. |
+1 for having tested CLion integration on Mac. |
I tried my hand at this, but because I don't have visibility into the true repo, I can not send an actual PR against the current code. The combination of these two commits was enough to get the CLion plugin working on Mac with the default toolchain. I understand that the aspect files have moved from the bazel repo to be shipped inside CLion, but my purpose here is to test the change in principal. Note that a much simpler workaround is to provide a cc_toolchain (not apple_cc_toolchain) using crosstool_top build flag in your project view file (.bazelproject). With the default toolchain, there are still some kinks. The includes and auto completes work fine, but some classes are not found inside the std namespace. See the attached screenshot. |
Hi Siddharthab, thanks a lot for looking into this. I have little experience using crosstool files, would you mind providing an example of how you define your cc_toolchain and include it in .bazelproject in this instance? |
+1 @siddharthab are you planning on contributing those changes to bazel / intellij plugin? |
@jgavris I think this repo is a read-only mirror of their true repo, so I am not sure how to contribute directly, but the change is really small and should not interfere with anything else. So if the team is interested, they will be able to fix it soon. @mkraft89 I will not be able to say how the cc_toolchain is defined as someone else in my company did it, and there are many specific customizations in it, but you can try to follow the guide from bazel team on how to define your own toolchain. As for the
|
Update on the Looks like LLVM needs either If I define either of these macros manually at the top of my file, CLion is able to parse the file correctly. Here's the same example from before, now working perfectly for the std::namespace. So now we know the exact things to get CLion working on Mac, at least at first glance. Cheers! |
I was going to post a message asking for help from @siddharthab (CROSSTOOL isn't exactly easy to follow) but amazingly I actually got this to work, at least as far as I can tell. The approach I took was to make a hello-world project, and then copy the toolchain files out of its build directory. Something like this:
There are lots of useful files in there. Now create your actual project with a structure like this:
The I couldn't get the I also had to change
to avoid the I think those were the only changes I made. |
Ugh you can't attach text files apparently?
|
Hi @Timmmm thanks for sharing the CROSSTOOL and BUILD file, they worked for me and I can now happily run and build bazel projects with CLion (2017.2.3) on Mac (10.13). Unfortunately, I cannot use the debugger yet. I encountered several errors trying to get it to work. First when clicking the debug symbol for a run configuration a small window with "unknown error" popped up. This was solved by adding a bazel before-run task in the run configuration as detailed here http://danieldanciu.blogspot.ch/2017/10/clion-with-bazel-unknown-error-when.html. Then I received this "Unable to find Mach task port for process-id 57573: (os/kern) failure (0x5)". After which I got an error message about NSUnbufferIO not being set followed by process error 255. I thought setting this variable in .bashrc to YES would help and indeed the error is gone. Unfortunately, the debugger is still not working. Using lldb I click on debug and am left with process error 255 and nothing happening. Switching to the bundled gdb I get "During startup terminated with SIG113" and it suggests switching from gdb to lldb in the preferences. For gdb this is a known error and can be solved by adding "set startup-with-shell off" to ~/.gdbinit, but this seems to have no effect within CLion. Does anyone have any ideas? |
Good work @mkraft89. What was the variable you added to According to this code exit code 255 happens when Although in my playing around with it, it actually prints the usage and calls
Maybe that is the |
@Timmmm. Thanks for helping out! |
With the most-recent published update and CLion 2017.3.3 this problem seems to be resolved on macOS 10.13.3 (for me at least). |
2020 is coming, has this problem been solved? |
+1 for this issue. |
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so. |
FYI this is still an issue, the bazel plugin does not seem to support macOS. |
Hey @cfstras could you share more details about the problem? |
Hello @cfstras, Could you please check the above comment and let us know if there is any update from your side. Thanks! |
Sorry, pretty stuffed week. I'll try to run another test soon. |
@sgowroji the minimal example seems to work fine now.
|
ok, I managed to reproduce this problem, but seems like something related to #4063 , which I hope will be merged soon. The problem happens when you build something that is dependent on a different external dependencies set ten the current targets imported by Intellij. As a workaround you may just rerun the build manual Screen.Recording.2023-02-06.at.11.43.54.mov |
FWIW I had the same problem as the issue title on my Macbook "Mac support: Bazel plugin doesn't work with C++ std lib and repositories" The solution to my problem was that environment variables |
@barrylapthorn but can you confirm the problem still exists? |
@tpasternak - sorry for the slow reply. As long as those two env-vars are set, I do not see the problem. I suspect that it's something to do with how XCode installed itself on my Macbook (which I rarely use). I don't know if it's exactly the same problem as the OP, but it seems like it. The warnings about the missing environment variables appear in the Bazel plugin's problem/issues pane. And since they're only a warning and in a different pane, they're easy to ignore even though they're the reason why the code resolution was failing (and in fact there was no code 'scope' for the particular file either). It's entirely possible the warnings are in the cropped pane in the right hand corner of this post above: #109 (comment) |
ok, it can be covered by #4651 |
That PR would indeed solve @barrylapthorn 's problem :D We saw the exact same symptoms. |
feat: Add commented-out gazelle target to default project view (bazelbuild#104) feat(release): Publish IntelliJ CE version of the plugin. (bazelbuild#103) feat(tools): Add script to check versions (bazelbuild#105) Radar: rdar://110389652 (Opening section of Bazel plugin setup confusing.) Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com> build: Add release pipeline for version checker (bazelbuild#109) Co-authored-by: Gibson Fahnestock <gib@apple.com>
feat: Add commented-out gazelle target to default project view (bazelbuild#104) feat(release): Publish IntelliJ CE version of the plugin. (bazelbuild#103) feat(tools): Add script to check versions (bazelbuild#105) Radar: rdar://110389652 (Opening section of Bazel plugin setup confusing.) Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com> build: Add release pipeline for version checker (bazelbuild#109) Co-authored-by: Gibson Fahnestock <gib@apple.com> feat: capture sdk and bazel plugin info for radar (bazelbuild#117) * feat: capture sdk and bazel plugin info for radar * Fix issues for clion plugin version Co-authored-by: Joshua Harris <jharris33@apple.com> build(prb): Make prb test every version of released products build(ci): Increase timeout in Rio build(ci): Key version counters by product build(ci): Make apple version checker publish optional fix: Default to workspace to infer project name (bazelbuild#122) Instead of defaulting to "the parent directory of the project view file", which is rarely what we want. feat: Add support for cc_gtest_testsuite in BUILD files (bazelbuild#121)
feat: Add commented-out gazelle target to default project view (bazelbuild#104) feat(release): Publish IntelliJ CE version of the plugin. (bazelbuild#103) feat(tools): Add script to check versions (bazelbuild#105) Radar: rdar://110389652 (Opening section of Bazel plugin setup confusing.) Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com> build: Add release pipeline for version checker (bazelbuild#109) Co-authored-by: Gibson Fahnestock <gib@apple.com> feat: capture sdk and bazel plugin info for radar (bazelbuild#117) * feat: capture sdk and bazel plugin info for radar * Fix issues for clion plugin version Co-authored-by: Joshua Harris <jharris33@apple.com> build(prb): Make prb test every version of released products build(ci): Increase timeout in Rio build(ci): Key version counters by product build(ci): Make apple version checker publish optional fix: Default to workspace to infer project name (bazelbuild#122) Instead of defaulting to "the parent directory of the project view file", which is rarely what we want. feat: Add support for cc_gtest_testsuite in BUILD files (bazelbuild#121) cleanup: Enable --test_output=errors by default
docs(readme): Reformat readme, change rebase process feat: Add commented-out gazelle target to default project view (bazelbuild#104) feat(release): Publish IntelliJ CE version of the plugin. (bazelbuild#103) feat(tools): Add script to check versions (bazelbuild#105) Radar: rdar://110389652 (Opening section of Bazel plugin setup confusing.) Co-authored-by: Daniel Wagner-Hall <dwagnerhall@apple.com> build: Add release pipeline for version checker (bazelbuild#109) Co-authored-by: Gibson Fahnestock <gib@apple.com> feat: capture sdk and bazel plugin info for radar (bazelbuild#117) * feat: capture sdk and bazel plugin info for radar * Fix issues for clion plugin version Co-authored-by: Joshua Harris <jharris33@apple.com> build(prb): Make prb test every version of released products build(ci): Increase timeout in Rio build(ci): Key version counters by product build(ci): Make apple version checker publish optional fix: Default to workspace to infer project name (bazelbuild#122) Instead of defaulting to "the parent directory of the project view file", which is rarely what we want. feat: Add support for cc_gtest_testsuite in BUILD files (bazelbuild#121) cleanup: Enable --test_output=errors by default feat(file-a-radar): add IntelliJ log to File a Radar draft Turns out to be surprisingly easy to attach IntelliJ logs to the created radar draft. rdar://117680933 ([IDE] Capture IntelliJ log when Filing a Radar) docs: Rewrite release instructions (bazelbuild#155)
I have checked and bazel binary is set correctly in the settings.
#include
Would not be detected properly by CLion. I have some repositories (both new_Http_repository and new_local_repository, for things like gtest, easylogging and llvm), neither is detected by CLion now.
Lots of warnings:
Warning:cc target //:type_inference_visitor_test does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:parser_test does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target @easylogging//:main does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:runtime does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:parser does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:classes does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target @llvm//:main does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:shwifty does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:common does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:ast does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target @gtest//:main does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:lexer does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:expression_type_visitor does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:codegen_test does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:type_inference_visitor does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:lexer_test does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:functions does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:jit does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:ast_compare_visitor does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:type does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Warning:cc target //:codegen does not depend on exactly 1 cc toolchain. Found 0 toolchains.
Unfortunately there is no explanation about what this means and how to fix this. I selected the default toolchain.
Symbols get properly detected (both std lib and my local repositories) when I use hand crafted cmake, which I use specifically for CLion.
The text was updated successfully, but these errors were encountered: