[PATCH] D121997: [clang][driver] Fix compilation database dump with multiple architectures

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 18 13:28:11 PDT 2022


dexonsmith added inline comments.


================
Comment at: clang/test/Driver/compilation_database_multiarch.c:2
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: %clang -c %s -o %t/out -arch x86_64 -arch arm64 -MJ %t/compilation_database.json
+// RUN: FileCheck --input-file=%t/compilation_database.json %s
----------------
jansvoboda11 wrote:
> dexonsmith wrote:
> > Usually driver tests don't depend on the `-cc1` working. The `-cc1` depends on the backends. You'd need to check that the relevant targets have been built and linked in. It'd be better to keep this isolated to the driver?
> > 
> > Is there a way to get the driver to dump the compilation database only (without actually running the actions)?
> > 
> > E.g., will `-###` still emit the compilation database? Looks like not:
> > ```
> >   // If this is a dry run, do not create the compilation database file.
> >   if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH))
> >     return;
> > ```
> > But maybe there's some other way to avoid running the actions. Or, we can add something like `-MJ-only <cdb>`, which acts like `-MJ <cdb>` and then exits before running the actions.
> If we manage to only run the driver (without invoking the `-cc1`s), would the question of built targets go away?
> 
> Flang has a frontend option `-init-only`. Maybe we could add something similar to that to Clang's driver? (`-driver-only`) Creating a specialized `-MJ-only` seems too specific IMO.
Sure, `-driver-only` makes sense to me:
- Run driver, including side effects.
- Don't run actions.

It'd be worth testing that it works correctly with `-v`. My intuition is that `-driver-only -v` should do the same thing as `-###`, except that `-###` suppresses driver outputs that come before running the actions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121997



More information about the cfe-commits mailing list