<div dir="ltr">Hi Michael,<div><br></div><div>I assume you are making use of the query-driver I suggested in my last email. Unfortunately, it doesn't extract builtin macros as they are more hairy compared to headers.</div><div><br></div><div>Could you give more details about your problem, which predefined macro is causing you troubles, what does your fix in clang.cpp involve?</div><div>Most of the builtin macros are actually set when initializing the preprocessor, look for InitializePredefinedMacros in clang/lib/Frontend/InitPreprocessor.cpp.</div><div>Maybe we can come up with a generic fix in there, rather than trying to parse and redefine those macros in clangd.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jan 18, 2020 at 3:26 PM Michael Steinberg <<a href="mailto:michsteinb@gmail.com">michsteinb@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>Hello,</p>
    <p>I'm sorry to reply so late too, only now I have a machine capable
      enough to quickly build clang ;)<br>
      The clangd experience improved much in the meanwhile and I can use
      it in vscode with my embedded project. That being said, clangd
      seems to have the builtin GCC macros hardcoded, instead of
      detected by the gcc toolchain. It reports GCC version 4.2 in my
      case, although I have a GCC 8.2.1 installed. I believe that is
      because of Clang.cpp:5382. This is unfortunate if you need to
      differ between toolchains. As this controls the default for
      "-fgnuc-version", is there a way to supply that argument to clangd
      through the vscode plugin in addition to the stuff parsed from the
      compile_commands.json file? I tried mentioning it to the
      clangd-server, but that does not work. For now I hardcoded 8.2.1
      into the clang sources. Also, would it perhaps be possible to
      detect and supply all the nuiltin macros from what the toolchain
      reports instead?<br>
    </p>
    <p>Thanks and kind regards<br>
      Michael Steinberg<br>
    </p>
    <p><br>
    </p>
    <div>Am 05.09.2019 um 11:45 schrieb Kadir
      Çetinkaya:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Hi Michael, sorry for the late reply this got lost
        in my inbox.
        <div><br>
        </div>
        <div>We actually landed the mentioned support into clangd with <a href="https://reviews.llvm.org/D62804" target="_blank">https://reviews.llvm.org/D62804</a> you
          can find docs in <a href="https://clang.llvm.org/extra/clangd/Configuration.html#query-driver" target="_blank">https://clang.llvm.org/extra/clangd/Configuration.html#query-driver</a>.</div>
        <div>Let me know whether it works for you.</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, Jun 12, 2019 at 3:47
          PM Ilya Biryukov <<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">
            <div>Thanks for describing the setup. Clang is generally
              good at mocking GCC rules for searching includes and such,
              but only for widely used targets (e.g. gcc targeting
              linux).</div>
            <div>However, this does not seem to work as nicely for less
              supported toolchains (like the bare-metal arm toolchain
              you're using).</div>
            <div><br>
            </div>
            <a class="gmail_plusreply" id="gmail-m_-759298898631251044gmail-m_-7517533581751639856plusReplyChip-0" href="mailto:kadircet@google.com" target="_blank">+Kadir Çetinkaya</a> is working on
            adding a cquery-like configuration mechanism to clangd, that
            should address your use-case. And in general, this seems to
            be a reasonable
            <div>fallback mechanism in case we hit a toolchain not
              well-supported by clang.</div>
            <div>At the same time, adding better support for bare-metal
              arm into clang's driver would give other benefits:</div>
            <div>- other clang-based tools, like clang-tidy, would work
              without extra configuration;</div>
            <div>- would allow to more closely mimic various
              non-include-path flags, which could also affect
              correctness for some corner cases;</div>
            <div>- allow easy switching (no extra flags needed, etc)
              from gcc to clang for the actual builds.</div>
            <div><br>
            </div>
            <div>But we don't plan to put more effort of the clangd team
              into the bare-metal toolchain's driver. Hopefully someone
              else will improve this in the future.</div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Tue, Jun 11, 2019 at
              9:40 PM Michael Steinberg <<a href="mailto:michsteinb@gmail.com" target="_blank">michsteinb@gmail.com</a>>
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
              <div bgcolor="#FFFFFF">
                <p>Hi there,</p>
                <p>- I use cmake + ninja, which generates the necessary
                  compile_commands file.<br>
                  - I mentioned cquery, which opts to query the compiler
                  found in compile_commands for its builtins, as you can
                  ask gcc to disclose them<br>
                  - I would prefer not to be locked into actually using
                  clang to build the projects, and there are targets
                  which clang does not support<br>
                  - I could live really well with clangd ignoring inline
                  assembly and such, for which the syntax and
                  availability of features differs between clang and gcc<br>
                </p>
                <p>Kind Regards<br>
                  Michael<br>
                </p>
                <p><br>
                </p>
                <div>Am 11.06.2019 um 16:13 schrieb Ilya Biryukov:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">We don't really have alternatives to
                    compile_commands.json that support automatic
                    indexing. You could use 'compile_flags.txt', but the
                    auto-indexing won't know which files it should feed
                    into.
                    <div><br>
                    </div>
                    <div>- What build system do you use and how did you
                      generate the compile_commands.json file?</div>
                    <div>- You mentioned ccls could index your project,
                      did it work out of the box? If it required user
                      configuration, what was it?</div>
                    <div><br>
                    </div>
                    <div>Clangd relies on clang's code to parse command
                      line, which is <b>mostly</b> compatible with GCC,
                      but I'm not sure how it handles custom GCC
                      toolchains (and whether it handles those at all).</div>
                    <div>In general, if you manage to set up your build
                      so that it uses clang and generate
                      compile_commands.json from that configuration - it
                      should work just fine. </div>
                    <div><br>
                    </div>
                    <div><br>
                    </div>
                  </div>
                  <br>
                  <div class="gmail_quote">
                    <div dir="ltr" class="gmail_attr">On Sat, Jun 8,
                      2019 at 8:59 PM Michael Steinberg via clangd-dev
                      <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a>>
                      wrote:<br>
                    </div>
                    <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                      <div bgcolor="#FFFFFF">
                        <p>Hello again,</p>
                        <p>is there maybe a way to add --include
                          directives for the clangd indexer only? I
                          couldn't find any command line option for this
                          :( I don't really feel like adding around 400
                          defines through the commandline....</p>
                        <p>Regards<br>
                          Michael<br>
                        </p>
                        <p><br>
                        </p>
                        <div>Am 03.06.2019 um 11:52 schrieb Kadir
                          Çetinkaya:<br>
                        </div>
                        <blockquote type="cite">
                          <div dir="ltr">
                            <div dir="ltr">Could you try adding
                              "-log=verbose" to clangd args? Which can
                              be done by adding
                              <div>```<br>
                                <div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-size:14px;line-height:19px;white-space:pre-wrap"><div> <span style="color:rgb(156,220,254)">"clangd.arguments"</span>: [</div><div>        <span style="color:rgb(206,145,120)">"-log=verbose"</span>,</div><div> ],</div></div>
                              </div>
                            </div>
                            <div>```</div>
                            <div>to your settings.json. Then you should
                              see the diagnostics for those uncompilable
                              errors.<br>
                            </div>
                            <div><br>
                            </div>
                            <div>Wild guess; it will most likely be
                              fixed with: <a href="https://reviews.llvm.org/D62804" target="_blank">https://reviews.llvm.org/D62804</a></div>
                            <br>
                            <div class="gmail_quote">
                              <div dir="ltr" class="gmail_attr">On Sun,
                                Jun 2, 2019 at 7:40 PM Michael Steinberg
                                via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a>>
                                wrote:<br>
                              </div>
                              <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi
                                there,<br>
                                <br>
                                I'm trying to get clangd running inside
                                vscode on windows. The project <br>
                                is using the gnu-arm-none-eabi
                                toolchain. For almost all compilation <br>
                                units I get the error message
                                "IndexingAction failed: has uncompilable
                                <br>
                                errors". Is there any way to get more
                                infos about the failure cause?<br>
                                <br>
                                Kind regards<br>
                                Michael<br>
                                <br>
                                <br>
_______________________________________________<br>
                                clangd-dev mailing list<br>
                                <a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
                                <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
                              </blockquote>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                      _______________________________________________<br>
                      clangd-dev mailing list<br>
                      <a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
                      <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
                    </blockquote>
                  </div>
                  <br clear="all">
                  <div><br>
                  </div>
                  -- <br>
                  <div dir="ltr">
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">
                          <div>Regards,</div>
                          <div>Ilya Biryukov</div>
                        </div>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </div>
            </blockquote>
          </div>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div dir="ltr">
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div>Regards,</div>
                  <div>Ilya Biryukov</div>
                </div>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </div>

</blockquote></div>