Attempt to fix the test failures observed in CI: * Add Option dependency, which caused BUILD_SHARED_LIBS builds to fail * Adapt tests that accidentally depended on the host platform: platforms that don't use an integrated assembler (e.g. AIX) get a different set of commands from the driver. Most dependency scanner tests can use -fsyntax-only or -E instead of -c to avoid this, and in the rare case we want to check -c specifically, set an explicit target so the behaviour is independent of the host. Original commit message follows. --- Instead of trying to "fix" the original driver invocation by appending arguments to it, split it into multiple commands, and for each -cc1 command use a CompilerInvocation to give precise control over the invocation. This change should make it easier to (in the future) canonicalize the command-line (e.g. to improve hits in something like ccache), apply optimizations, or start supporting multi-arch builds, which would require different modules for each arch. In the long run it may make sense to treat the TU commands as a dependency graph, each with their own dependencies on modules or earlier TU commands, but for now they are simply a list that is executed in order, and the dependencies are simply duplicated. Since we currently only support single-arch builds, there is no parallelism available in the execution. Differential Revision: https://reviews.llvm.org/D132405
94 lines
3.7 KiB
C
94 lines
3.7 KiB
C
// RUN: rm -rf %t && mkdir %t
|
|
// RUN: cp -r %S/Inputs/modules-context-hash/* %t
|
|
|
|
// Check that the scanner reports the same module as distinct dependencies when
|
|
// a single translation unit gets compiled with multiple command-lines that
|
|
// produce different **strict** context hashes.
|
|
|
|
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_a.json.template > %t/cdb_a.json
|
|
// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-context-hash/cdb_b.json.template > %t/cdb_b.json
|
|
|
|
// We run two separate scans. The context hash for "a" and "b" can differ between
|
|
// systems. If we'd scan both Clang invocations in a single run, the order of JSON
|
|
// entities would be non-deterministic. To prevent this, run the scans separately
|
|
// and verify that the context hashes differ with a single FileCheck invocation.
|
|
//
|
|
// RUN: clang-scan-deps -compilation-database %t/cdb_a.json -format experimental-full -j 1 > %t/result.json
|
|
// RUN: clang-scan-deps -compilation-database %t/cdb_b.json -format experimental-full -j 1 >> %t/result.json
|
|
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t -check-prefix=CHECK
|
|
|
|
// CHECK: {
|
|
// CHECK-NEXT: "modules": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "clang-module-deps": [],
|
|
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK-NEXT: "-cc1"
|
|
// CHECK: "-emit-module"
|
|
// CHECK: "-I"
|
|
// CHECK: "[[PREFIX]]/a"
|
|
// CHECK: "-fmodule-name=mod"
|
|
// CHECK: ],
|
|
// CHECK-NEXT: "context-hash": "[[HASH_MOD_A:.*]]",
|
|
// CHECK-NEXT: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/a/dep.h",
|
|
// CHECK-NEXT: "[[PREFIX]]/mod.h",
|
|
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "name": "mod"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "translation-units": [
|
|
// CHECK-NEXT: {
|
|
// CHECK: "clang-context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "clang-module-deps": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "context-hash": "[[HASH_MOD_A]]",
|
|
// CHECK-NEXT: "module-name": "mod"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK: ],
|
|
// CHECK: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/tu.c"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK: "modules": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NEXT: "clang-module-deps": [],
|
|
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK-NEXT: "-cc1"
|
|
// CHECK: "-emit-module"
|
|
// CHECK: "-I"
|
|
// CHECK: "[[PREFIX]]/b"
|
|
// CHECK: "-fmodule-name=mod"
|
|
// CHECK: ],
|
|
// CHECK-NOT: "context-hash": "[[HASH_MOD_A]]",
|
|
// CHECK: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/b/dep.h",
|
|
// CHECK-NEXT: "[[PREFIX]]/mod.h",
|
|
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "name": "mod"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "translation-units": [
|
|
// CHECK-NEXT: {
|
|
// CHECK: "clang-context-hash": "{{.*}}",
|
|
// CHECK-NEXT: "clang-module-deps": [
|
|
// CHECK-NEXT: {
|
|
// CHECK-NOT: "context-hash": "[[HASH_MOD_A]]",
|
|
// CHECK: "module-name": "mod"
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "command-line": [
|
|
// CHECK: ],
|
|
// CHECK: "file-deps": [
|
|
// CHECK-NEXT: "[[PREFIX]]/tu.c"
|
|
// CHECK-NEXT: ],
|
|
// CHECK-NEXT: "input-file": "[[PREFIX]]/tu.c"
|
|
// CHECK-NEXT: }
|