Skip to content

Commit 7bd492f

Browse files
authored
[clang dependency scanning] Make Current Working Directory Optimization Off by Default (llvm#129809)
llvm#124786 implemented current working directory (CWD) optimization and the optimization was on by default. We have discovered that build system needs to be compatible with the CWD optimization and default off is a better behavior. The build system needs to be aware that the current working directory is ignored. Without a good way of notifying the build system, it is less risky to default to off. This PR implement the change. rdar://145860213
1 parent fb9329c commit 7bd492f

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ enum class ScanningOptimizations {
6767
IgnoreCWD = (1 << 4),
6868

6969
DSS_LAST_BITMASK_ENUM(IgnoreCWD),
70-
Default = All
70+
71+
// The build system needs to be aware that the current working
72+
// directory is ignored. Without a good way of notifying the build
73+
// system, it is less risky to default to off.
74+
Default = All & (~IgnoreCWD)
7175
};
7276

7377
#undef DSS_LAST_BITMASK_ENUM

clang/test/ClangScanDeps/modules-context-hash-cwd.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// RUN: sed -e "s|DIR|%/t|g" %t/cdb3.json.in > %t/cdb3.json
1010
// RUN: sed -e "s|DIR|%/t|g" %t/cdb4.json.in > %t/cdb4.json
1111
// RUN: sed -e "s|DIR|%/t|g" %t/cdb5.json.in > %t/cdb5.json
12-
// RUN: clang-scan-deps -compilation-database %t/cdb0.json -format experimental-full > %t/result0.json
13-
// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full > %t/result1.json
12+
// RUN: clang-scan-deps -compilation-database %t/cdb0.json -format experimental-full -optimize-args=all > %t/result0.json
13+
// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full -optimize-args=all > %t/result1.json
1414
// It is not a typo to use cdb1.json for result2. We intend to use the same
1515
// compilation database, but different clang-scan-deps optimize-args options.
1616
// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full -optimize-args=header-search,system-warnings,vfs,canonicalize-macros > %t/result2.json
17-
// RUN: clang-scan-deps -compilation-database %t/cdb3.json -format experimental-full > %t/result3.json
18-
// RUN: clang-scan-deps -compilation-database %t/cdb4.json -format experimental-full > %t/result4.json
19-
// RUN: clang-scan-deps -compilation-database %t/cdb5.json -format experimental-full > %t/result5.json
17+
// RUN: clang-scan-deps -compilation-database %t/cdb3.json -format experimental-full -optimize-args=all > %t/result3.json
18+
// RUN: clang-scan-deps -compilation-database %t/cdb4.json -format experimental-full -optimize-args=all > %t/result4.json
19+
// RUN: clang-scan-deps -compilation-database %t/cdb5.json -format experimental-full -optimize-args=all > %t/result5.json
2020
// RUN: cat %t/result0.json %t/result1.json | FileCheck %s
2121
// RUN: cat %t/result0.json %t/result2.json | FileCheck %s -check-prefix=SKIPOPT
2222
// RUN: cat %t/result3.json %t/result4.json | FileCheck %s -check-prefix=RELPATH

clang/test/ClangScanDeps/modules-debug-dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: split-file %s %t
55
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
66
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format \
7-
// RUN: experimental-full > %t/result.json
7+
// RUN: experimental-full -optimize-args=all > %t/result.json
88
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s
99

1010
//--- cdb.json.in

0 commit comments

Comments
 (0)