Skip to content

[clang dependency scanning] C APIs for Current Working Directory Optimization #10276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2025

Conversation

qiongsiwu
Copy link

@qiongsiwu qiongsiwu commented Mar 17, 2025

This PR cherry-picks two PRs to implement the C APIs for Current Working Directory Optimization.

rdar://145860213

…on 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
(cherry picked from commit 7bd492f)

 Conflicts:
	clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
…mization (llvm#10146)

This PR implements two new C APIs so the build system can communicate with the dependency scanner about current working directory optimization.

Two new functions are added:

1. `void clang_experimental_DependencyScannerServiceOptions_setCWDOptimization(CXDependencyScannerServiceOptions Opts, int)`: the caller can use this function to set `Opts` to indicate that it can support current working directory optimization.
2. `int clang_experimental_DepGraphModule_isCWDIgnored(CXDepGraphModule)`: this function can retrieve the module info from the scanner, indicating if the current working directory is ignored for this module's context hash.

As an example usage, the user of the APIs (e.g. a build system) can use them to set reasonable debug working directories for each `pcm`s.

rdar://145860213
(cherry picked from commit b9c8668)

 Conflicts:
	clang/test/ClangScanDeps/cas-fs-multiple-commands.c
	clang/test/ClangScanDeps/include-tree-multiple-commands.c
	clang/tools/libclang/libclang.map
@qiongsiwu qiongsiwu requested a review from a team as a code owner March 17, 2025 22:08
@qiongsiwu
Copy link
Author

@swift-ci please test llvm

@qiongsiwu
Copy link
Author

@swift-ci please test

@cyndyishida
Copy link

cyndyishida commented Mar 17, 2025

For llvm#129809

Does this mean the optimization is off by default for swift source compiles too? If so, how will it be turned on (since it is not using the C APIs)?

@qiongsiwu
Copy link
Author

For llvm#129809

Does this mean the optimization is off by default for swift source compiles too? If so, how will it be turned on (since it is not using the C APIs)?

Ah good question! We have this (swiftlang/swift#79919) Swift PR to make sure the optimization is on by default. The PR has already landed in main.

@qiongsiwu
Copy link
Author

The LLVM test failure (MergeFunc/comdat.ll) is known (rdar://147230546). I believe this PR is safe to merge.

@qiongsiwu qiongsiwu merged commit 7135e91 into swiftlang:stable/20240723 Mar 18, 2025
3 of 5 checks passed
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.

2 participants