public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Paul Smith <paul@mad-scientist.net>
To: Eli Zaretskii <eliz@gnu.org>, gcc@gcc.gnu.org
Subject: Re: LSP based on GCC
Date: Wed, 17 May 2023 15:48:09 -0400	[thread overview]
Message-ID: <d84174b295ca982d939787aff0628534e5df516c.camel@mad-scientist.net> (raw)
In-Reply-To: <83a5y3xcai.fsf@gnu.org>

On Wed, 2023-05-17 at 17:28 +0300, Eli Zaretskii via Gcc wrote:
> If there are no current plans for implementing LSP, I hope someone
> will work on that soon, given that Emacs can now use it, and because
> having a GCC-based LSP implementation will allow people to use their
> installed GCC as the basis for LSP features, instead of having to
> install yet another compiler.

Just to note, existing LSP servers are stand-alone binaries: you don't
need to install the compiler.  The two main C/C++ LSP servers I'm aware
of are clangd and ccls.  Both of them are built from libclang, as you
suggest, but you don't need a full clang installation to get them.

You do need to install some Clang "resource" header files for
intrinsics etc. but not the entire compiler (for example you don't need
the STL or anything like that: they do work fine with the GCC STL).

Nevertheless I wholeheartedly agree with your hopes Eli because using
Clang-based LSP is annoying for people developing with GCC:

First, when you're viewing code that is using #ifdefs to choose between
compilers you always see the code for Clang as "active", even though
you're using GCC as the compiler, since it's using the Clang built-in
macros.

More frustratingly, Clang has made some poor decisions around
"compatibility": they tried to leverage the GNU ecosystem by emulating
GCC features and arguments but sometimes break things.  The most
egregious example I'm aware of is that they look for GCC-named
precompiled headers (.gch), even though the Clang PCH format is
completely different.  So if Clang (and the LSP servers built on it)
find a .gch header file they will try to read it, fail, and give an
error.  I filed a bug about this in 2019 but it's been ignored.

This means you need to modify your LSP server arguments to omit any PCH
compiler command line arguments; for environments based on auto-
generated definitions like compile_commands.json this is frustrating.

  parent reply	other threads:[~2023-05-17 19:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-17 14:28 Eli Zaretskii
2023-05-17 15:46 ` David Malcolm
2023-05-17 17:10   ` Eli Zaretskii
2023-05-17 21:18   ` Arsen Arsenović
2023-05-29 20:16     ` Alexandre Oliva
2023-05-30 14:33       ` Paul Smith
2023-06-01  1:57         ` Alexandre Oliva
2023-05-18 14:28   ` Jason Merrill
2023-05-17 19:48 ` Paul Smith [this message]
2023-05-17 22:38   ` Ben Boeckel
2023-05-18 13:25     ` Paul Smith
2023-05-18 14:52       ` Ben Boeckel
2023-05-18 15:42         ` Paul Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d84174b295ca982d939787aff0628534e5df516c.camel@mad-scientist.net \
    --to=paul@mad-scientist.net \
    --cc=eliz@gnu.org \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).