atom-ide-cpp
atom-ide-cpp copied to clipboard
Clangd extraFlags extension is going away
Hi Thomas,
I'm afraid we're likely to remove the extraFlags extension that atom-ide-cpp is using: https://reviews.llvm.org/D53641
Clangd has grown lots of methods of customizing compile commands. They overlap and have subtle differences, and this is causing us some reasoning about how new features should behave.
I think there are a few good alternatives:
compile_flags.txtis a fully-supported alternative tocompile_commands.jsonfor specifying compile commands for simple projects. It has exactly the same format as.clang_completeso renaming or symlinking this file will work for users.- we have a protocol extension that allows the full compile command to be specified (currently only in a certain configuration, but soon always). The full compile command is just
clang $FILENAME $EXTRA_FLAGS, orclang -xobjective-c++-header $FILENAME $EXTRA_FLAGSfor *.h files. Happy to provide more details. - we can add a protocol extension that allows the fallback command to be customized with extra flags.
Hopefully one of these will work well enough. You may need to respect both the old and new method for a while, because of version skew.
Happy to help out with migration if you like!
Cheers, Sam
@sam-mccall Thanks for the heads up!
Based on your descriptions of the alternatives, I think perhaps going the protocol extension route makes most sense. Although if that is not currently available to all users, I might have to implement some type of logic to either assist users in renaming/symlinking .clang_complete to compile_flags.txt or notify them about this change.
Since this Atom package is still highly experimental, requiring users to use an up-to-date version of Clangd shouldn't be a problem. If I can avoid supporting both the old and new method, I'll be very happy.
Is there any documentation (or tests) that I can look at to get a reasonable understanding of the new functionality? In the past I had to dig through a lot of the implementation to figure things out.
Hi Thomas,
extraFlags is removed in https://reviews.llvm.org/rL345969, and the fallbackFlags initialization extension is added in https://reviews.llvm.org/rL345973 (almost simultaneously). This allows the flags to be set at initialize time, which seems like it should work.
e.g. in the InitializeRequest:
"initializationOptions": { "fallbackFlags": ["-Dfoo=1"] }
I think this mostly a drop-in replacement for your use case - you can pass the same data that's currently being passed to extraFlags.
Because clangd ignores unknown extensions, I do think passing both extensions will be simplest, but up to you.
Additionally in the long run recommending compile_flags.txt instead of .clang_complete is probably a good idea, as it avoids the need for extensions entirely and is compatible with other tools.
Cheers, Sam