Closed Warchant closed 1 year ago
Hey, @Warchant. Thanks for writing in again.
Sorry I'm a little slower than usual in getting back. I took some time off for the Thanksgiving holiday and am scrambling to catch back up. (If new, Thanksgiving is a day of being thankful for things one might otherwise take for granted. We were all humbled reading your reply about life in Kharkiv. Peace, electricity, freedom...all wonderful things, too easy to take for granted. Thank you for taking the time to share; our hearts are with you.)
Anyway, back to trying to help!
I'd like to understand a bit better about what you're aiming to do here, one step up the backtrace of your goals. The reason I'm asking is that I'm not sure that clangd is going to do what you want here, since it only really understands gcc/msvc flags. So I better understand, can I ask what you're using this for, what these compilers are, etc? Basically, I'd like to figure out if and how we can best support your goal here.
In the meantime, I'll try to add some context for each in turn:
exclude_headers = "all"
, as in the README, and it won't run the msvc/clang args-format dependent header extraction--no source changes required.
Conversely, linking back to (1), it's not clear to me that it makes sense to support header extraction for proprietary flag schemes that clangd won't support, but if it does, I'd be open to merging in cases for them. One thing we probably shouldn't do, though, is throw an error in the default case, since lots of toolchains have the annoying habit of wrapping clang in scripts that we need to call through.Cheers, Chris
I'd like to understand a bit better about what you're aiming to do here, one step up the backtrace of your goals.
My goal is to just generate compile_commands.json, without an intention of running clangd on it. I tried:
I would LOVE to run clangd, clang-tidy and related tools... But at this point I need it for TICS.
All of that is proprietary :(
Got it! Thanks. Can't say I've used most of those, so I extra appreciate your linking me to them.
Bummer that they aren't (all) flag compatible with MSVC/gcc. If they were close, I'd propose that we add code to massage their flags to be clang compatible so you could run those tools, but it sounds like there are too many and/or the clang tools aren't enough of a goal?
I'm guessing you don't need compile commands entries for headers for the static analysis tool?
If that's right, then I'd propose we resolve this as follows, so we can get you everything you want while keeping you on the mainline and continue to collaborate and get you future fixes:
exclude_headers = "all"
in your configuration. That'll turn off the header extraction you don't want, make things run fast, and bypass most of the coupling with gcc/clang.@Warchant, please do let me know what you think of that approach when you get a chance! (I know you've got, ahem, a lot going on around you, so no pressure--just thought of you while I was tweaking my fix to your other issue.)
Hey @Warchant--haven't heard from you in a while. I'm hoping you're OK!
I was about to implement the workaround for (3) that I'd proposed above, but the directory check isn't actually sufficient, since the arg with a source extension can be generated directory and therefore not yet exist. Indeed that's exactly the example in #37. My bad.
So I've implemented exactly your original suggestion. Hopefully that plus exclude_headers = "all"
gets this working for your use case. If you want the clang tools to work, the next step would be to add _platform_patch functions for your compilers, massaging their flags into clang compatible ones that the tooling can understand.
I'm going to close this for now, since I haven't heard from you in a good while, but I can open this right back up if you reply and want it.
This tool does not work with proprietary compilers which do not have gcc-compatible CLI interface. For now I made my private fork with "hardcoded" types of fixes. In this issue I will enumerate my changes:
-o
or/Fo
are expected. But one of compilers I tried uses--output_file=something/file.o
. Other-fe something/file.o
. Maybe potential solution is to give users ability to defineoutput_flag="-o"
value in bazel rule, then use it to search for output flag?_get_headers_gcc
and will obviously fail, because they won't have gcc-compatible flags. I excluded this call during my tests, not sure why it is required.arg.endswith(_get_files.source_extensions)
. If this returns 1 candidate, then we found a file. Else, fallback to current approach, or fail._get_headers_gcc
is necessary just to get a list of headers for this deduplication. In my solution I check entries for uniqueness here by primary key (directory, file). It does not require additional .d file generation and parsing, so it eliminates the need for_get_headers_gcc
. It could be that I misunderstood the purpose of_get_headers_gcc
...With these points fixed and with support of #88, the tool works for multiple proprietary compilers.