Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Clangd extraFlags extension is going away #16

Open
sam-mccall opened this issue Oct 24, 2018 · 2 comments
Open

Clangd extraFlags extension is going away #16

sam-mccall opened this issue Oct 24, 2018 · 2 comments

Comments

@sam-mccall
Copy link

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

@thomasjo
Copy link
Owner

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

@sam-mccall
Copy link
Author

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

llvm-git-migration pushed a commit to llvm-git-prototype/llvm that referenced this issue Nov 6, 2018
Summary:
The new implementation is a GlobalCompilationDatabase that overlays a base.
Normally this is the directory-based CDB.
To preserve the behavior of compile_args_from=LSP, the base may be null.

The OverlayCDB is always present, and so the extensions to populate it
are always supported.

It also allows overriding the flags of the fallback command. This is
just unit-tested for now, but the plan is to expose this as an extension
on the initialize message. This addresses use cases like
thomasjo/atom-ide-cpp#16

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D53687

llvm-svn=345970
shrouxm pushed a commit to sourcegraph/lsif-clang that referenced this issue Jul 12, 2020
Summary:
The new implementation is a GlobalCompilationDatabase that overlays a base.
Normally this is the directory-based CDB.
To preserve the behavior of compile_args_from=LSP, the base may be null.

The OverlayCDB is always present, and so the extensions to populate it
are always supported.

It also allows overriding the flags of the fallback command. This is
just unit-tested for now, but the plan is to expose this as an extension
on the initialize message. This addresses use cases like
thomasjo/atom-ide-cpp#16

Reviewers: ilya-biryukov

Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D53687

llvm-svn: 345970
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants