[PATCH] D63194: [clangd] Link in target infos and pass target and mode while invoking driver

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 13 04:35:18 PDT 2019


kadircet added inline comments.


================
Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:36
   Cmd.CommandLine = ArgsAdjuster(Cmd.CommandLine, Cmd.Filename);
+  tooling::addTargetAndModeForProgramName(Cmd.CommandLine, Cmd.CommandLine[0]);
   // Inject the resource dir.
----------------
ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > Do we actually need this if we provide a proper `Argv[0]` to the driver?
> > > My understanding is that the driver should figure out the targets from custom binary names on its own.
> > unfortunately yes. 
> > 
> > because if the "-target" is missing, driver tries to deduce it from the "running binary" which is "clangd" in our case.
> I wonder if it would sense to change this? Where does this code live?
> 
> That's exactly what `argv[0]` is for in `compile_commands.json`. Fixing that at the driver level would "fix" all libclang- and libtooling-based binaries, like `clang-tidy`, etc.
ah sorry, I've mixed that one actually. the behavior is: if the "-target" is missing, we always use the default target(depends on the host). even though `ClangExecutable` is available in the Driver and set correctly to `argv[0]`.
tools that care about target deduction needs to pass "-target" to driver explicitly. currently the driver only deduces "driver-mode" from the executable name.

adding this to rather driver side, looks like nothing is broken.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63194/new/

https://reviews.llvm.org/D63194





More information about the cfe-commits mailing list