Skip to content

Conversation

@Bigcheese
Copy link

While the source code isn't supposed to change during a build, in some environments it does. This adds an option that disables caching of stat failures, meaning that source files can be added to the build during scanning.

This adds a -no-cache-negative-stats option to clang-scan-deps to enable this behavior. There are no tests for clang-scan-deps as there's no reliable way to do so from it. A unit test has been added that modifies the filesystem between scans to test it.

Internally this uses an environment variable.

CLANG_SCAN_CACHE_NEGATIVE_STATS: If this is set or set to 1 negative stat caching is enabled. If it's 0 then it's disabled.

Negative stat caching is disabled by default.

While the source code isn't supposed to change during a build, in some
environments it does. This adds an option that disables caching of
stat failures, meaning that source files can be added to the build
during scanning.

This adds a `-no-cache-negative-stats` option to clang-scan-deps to
enable this behavior. There are no tests for clang-scan-deps as
there's no reliable way to do so from it. A unit test has been added
that modifies the filesystem between scans to test it.

Internally this uses an environment variable.

`CLANG_SCAN_CACHE_NEGATIVE_STATS`: If this is set or set to 1 negative
stat caching is enabled. If it's 0 then it's disabled.

Negative stat caching is disabled by default.
@Bigcheese
Copy link
Author

@swift-ci please test

@qiongsiwu
Copy link

@swift-ci please test llvm

static ScanningOptimizations OptimizeArgs;
static std::string ModuleFilesDir;
static bool EagerLoadModules;
static bool CacheNegativeStats = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default value here is always overwritten in ParseArgs().


EagerLoadModules = Args.hasArg(OPT_eager_load_pcm);

CacheNegativeStats = !Args.hasArg(OPT_no_cache_negative_stats);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means clang-scan-deps has a different default to other clients, why is that?

CASOptions(), nullptr, nullptr, nullptr, ScanningOptimizations::Default,
/*EagerLoadModules=*/false,
/*TraceVFS=*/false, llvm::sys::toTimeT(std::chrono::system_clock::now()),
true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add /*CacheNegativeStats=*/ label here other places the service gets constructed?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it set to true here? I'd think we'd want to match the default behavior of the libclang API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants