-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Absolute paths embedded in dependency files #11817
Comments
The dependency file generated by Clang can sometimes contain absolute paths to system headers, system modules and files generated by Bazel during the build. These paths can defer between machines and between Bazel instances, for example: ``` bazel-out/apl-darwin_x86_64-fastbuild/bin/_objs/B/arc/B.o: B.m \ /private/var/tmp/_bazel_user/b4422045cf7215be2d3fa4e439c7376a/sandbox/darwin-sandbox/214/execroot/__main__/bazel-out/apl-darwin_x86_64-fastbuild/bin/A.modulemap \ /Applications/Xcode-11.6.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Modules/module.modulemap ``` This patch adds a post-process to wrapped_clang to normalize those paths by: * converting absolute paths to relative paths for paths to files under the execution root * standardizing the paths to system headers, system modules to always use the standard location of Xcode (`/Applications/Xcode.app`). The user doesn't need to have Xcode installed to this location as Bazel are already mapping them to the correct location locally. This makes the produced `.d` files deterministic and can reliably be shared with the remote cache. Fixes bazelbuild#11817.
The dependency file generated by Clang can sometimes contain absolute paths to system headers, system modules and files generated by Bazel during the build. These paths can defer between machines and between Bazel instances, for example: ``` bazel-out/apl-darwin_x86_64-fastbuild/bin/_objs/B/arc/B.o: B.m \ /private/var/tmp/_bazel_user/b4422045cf7215be2d3fa4e439c7376a/sandbox/darwin-sandbox/214/execroot/__main__/bazel-out/apl-darwin_x86_64-fastbuild/bin/A.modulemap \ /Applications/Xcode-11.6.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Modules/module.modulemap ``` This patch adds a post-process to wrapped_clang to normalize those paths by: * converting absolute paths to relative paths for paths to files under the execution root * standardizing the paths to system headers, system modules to always use the standard location of Xcode (`/Applications/Xcode.app`). The user doesn't need to have Xcode installed to this location as Bazel are already mapping them to the correct location locally. This makes the produced `.d` files deterministic and can reliably be shared with the remote cache. Fixes bazelbuild#11817.
The dependency file generated by Clang can sometimes contain absolute paths to system headers, system modules and files generated by Bazel during the build. These paths can defer between machines and between Bazel instances, for example: ``` bazel-out/apl-darwin_x86_64-fastbuild/bin/_objs/B/arc/B.o: B.m \ /private/var/tmp/_bazel_user/b4422045cf7215be2d3fa4e439c7376a/sandbox/darwin-sandbox/214/execroot/__main__/bazel-out/apl-darwin_x86_64-fastbuild/bin/A.modulemap \ /Applications/Xcode-11.6.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Foundation.framework/Modules/module.modulemap ``` This patch adds a post-process to wrapped_clang to normalize those paths by: * converting absolute paths to relative paths for paths to files under the execution root * standardizing the paths to system headers, system modules to always use the standard location of Xcode (`/Applications/Xcode.app`). The user doesn't need to have Xcode installed to this location as Bazel are already mapping them to the correct location locally. This makes the produced `.d` files deterministic and can reliably be shared with the remote cache. Fixes bazelbuild#11817.
Does using |
Tried but it didn’t change anything—the produced .d files are still part of the outputs and are still being cached as is. From the documentation of the option, it looks like it’s just for the Remote Builds w/o the Bytes feature. bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppOptions.java Lines 689 to 690 in 82e6b6a
|
I think non-determinism in .d files is harmless? |
Would it be fine to remove .d files from cache? |
This actually makes us unable to use remote cache when building Android app. The c++ toolchain used to build Android app has cxx_builtin_include_directories point to directory in an external workspace(androidndk). Those builtin include files will have abosulte path in dotd files. When we hit remote cache, the build will failed with message:
Since devs usually have different bazel execution root paths, other devs will failed to build the app. We tried |
After some experiments we found that it's caused by ndk clang on Windows "incorrectly" write absolute path for headers in gcc toolchain. The header files from clang are written with relative paths. On MacOS, the headers from gcc toolchain also are relative paths. But on Windows they're absolute paths. We don't know if this is a bug of ndk clang. We can fix this by adding |
Ok I found another actual issue that this causes, that I believe relative bazel/tools/cpp/osx_cc_configure.bzl Lines 41 to 54 in fdcaaf4
Then they build some C*, and then move Xcode to /Applications (where it ideally should have been all along), and build again, their local build artifacts, and local disk cache, are now polluted with the wrong absolute paths in the
|
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
/cc @ahumesky |
…ache issues with the Android NDK on Windows. See #11817 PiperOrigin-RevId: 658725449 Change-Id: I09edfa9af8a4956d661174bef76a7f8776891a8b
…ache issues with the Android NDK on Windows. See bazelbuild#11817 PiperOrigin-RevId: 658725449 Change-Id: I09edfa9af8a4956d661174bef76a7f8776891a8b
Description of the problem / feature request:
When compiling
objc_library
targets, we're seeing absolute paths of generated files being embedded in dependency files (.d
files).Feature requests: what underlying problem are you trying to solve with this feature?
We're trying to make the dependency files cacheable by removing or normalizing the absolute paths that are embedded in the dependency files.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Please check the attached project: nondeterministic-depfile.zip.
bazel build //:B
B.d
file contents. It contains an absolute path to a file that is generated during the build (/private/var/tmp/_bazel_user/b4422045cf7215be2d3fa4e439c7376a/sandbox/darwin-sandbox/214/execroot/__main__/bazel-out/apl-darwin_x86_64-fastbuild/bin/AModule-module.modulemap
)The attached project uses some custom rules but the issue can be reproduced with an
objc_library
(that has modules enabled) depending on aswift_library
and importing it via a Clang module.What operating system are you running Bazel on?
macOS Catalina 10.15.5 (19F101)
What's the output of
bazel info release
?release 3.4.1
Have you found anything relevant by searching the web?
Found a related issue with system headers: #7772. We found an additional issue with generated files during a build.
Found two issues with dependency files: #7769, #7771. The
dependency_file
feature can't be disabled because it's necessary to keep the C++ builds correct.The text was updated successfully, but these errors were encountered: