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

Jan Svoboda via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 18 12:21:54 PDT 2022


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


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