atom-ide-cpp icon indicating copy to clipboard operation
atom-ide-cpp copied to clipboard

Clangd extraFlags extension is going away

Open sam-mccall opened this issue 7 years ago • 2 comments

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.txt is a fully-supported alternative to compile_commands.json for specifying compile commands for simple projects. It has exactly the same format as .clang_complete so 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, or clang -xobjective-c++-header $FILENAME $EXTRA_FLAGS for *.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 avatar Oct 24 '18 13:10 sam-mccall

@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.

thomasjo avatar Oct 24 '18 13:10 thomasjo

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

sam-mccall avatar Nov 02 '18 15:11 sam-mccall