Skip to content
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

C++ dependency pruning is broken for remote execution on Windows #11765

Closed
buchgr opened this issue Jul 14, 2020 · 4 comments
Closed

C++ dependency pruning is broken for remote execution on Windows #11765

buchgr opened this issue Jul 14, 2020 · 4 comments
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug

Comments

@buchgr
Copy link
Contributor

buchgr commented Jul 14, 2020

When using remote execution in Windows Bazel will fail with an error of the type

undeclared inclusion(s) in rule  "@foo//:bar" this rule is missing dependency declarations for the following files included by "external/foo/bar.cc".
  'C:/bot/w/external/foo/bar.h'
  ...

This is because the dependency pruning code [1] scanning the /showParams output makes the incorrect assumption that source and generated files have a parent folder named 'execroot'. The assumption only holds for local execution without sandboxing. However, in remote execution we can't make any assumptions about the absolute location of files. Bazel doesn't know under which directory path an action is executed on a remote system.

[1] https://osscs.corp.google.com/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/rules/cpp/ShowIncludesFilter.java;l=151;drc=0b081d8593d9eeb4e31aceed0b066ce4482ece49

Related #6931

@buchgr buchgr self-assigned this Jul 14, 2020
bazel-io pushed a commit that referenced this issue Jul 17, 2020
I a fixing a bug in ShowIncludesFilter [1]. For this I need to be able to invoke the include validation logic on a single artifact. Additionally, I'd consider this change a win for readability.

This change is a no-op. However, it might have implications on memory usage when loose header checking is used. This change always constructs the loose header checking set. I think this is fine as it's my understanding that loose header checking is barely used and going away.
[1] #11765

RELNOTES: None
PiperOrigin-RevId: 321753605
@oquenchil oquenchil added area-Windows Windows-specific issues and feature requests team-Rules-CPP Issues for C++ rules P3 We're not considering working on this, but happy to review a PR. (No assignee) type: bug labels Jul 22, 2020
@coeuvre
Copy link
Member

coeuvre commented Apr 16, 2021

To support compiling c++ on windows remotely, execution services must do a hack which they need to replace the paths of the lines matched pattern Note: including file: <absolute path> with relative paths (relative to action working directory) in stdout of cl.exe actions.

For example, Note: including file: C:/bot/w/external/foo/bar.h should be replaced with Note: including file: external/foo/bar.h.

I had a discussion with @meteorcloudy, and below are the options we came up to fix this:

  1. The easiest way is let cl.exe output relative header path, but MSVC doesn't support this option yet.
  2. Having a wrapper script which print cwd to stdout and then execute cl.exe so when we parse the stdout of the action, we know which working directory it was executed remotely in. However, this may have 10%-20% performance impact.
  3. Use parent directory of local execroot as input root, use execroot as working directory. So we can make sure folder execroot is included in the absolute paths.

/cc @lberki

@buchgr buchgr removed their assignment Jun 25, 2021
@jan11011977
Copy link

jan11011977 commented Jan 6, 2022

Hi I noticed that this issue has been open for a while. I'd like to propose another solution:

I understand that this include validation is needed on Windows because we don't have a sandbox. However running with remote execution effectively functions as a sandbox, so arguably this include validation isn't needed when running remotely. If the remote compile is successful, that proves that all the required include files were declared correctly.

Would there be a way to disable the validation on the client side (if it's possible to detect that the compile was executed remotely there), or if that's not possible, it could be done on the remote execution side either by removing the output of /showIncludes, or possibly by removing the /showIncludes flag altogether.

My knowledge of Bazel is limited so apologies if I have misunderstood the problem.

luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 4, 2022
    I a fixing a bug in ShowIncludesFilter [1]. For this I need to be able to invoke the include validation logic on a single artifact. Additionally, I'd consider this change a win for readability.

    This change is a no-op. However, it might have implications on memory usage when loose header checking is used. This change always constructs the loose header checking set. I think this is fine as it's my understanding that loose header checking is barely used and going away.
    [1] bazelbuild/bazel#11765

    RELNOTES: None
    PiperOrigin-RevId: 321753605
@github-actions
Copy link

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 14 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 (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Jun 13, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-CPP Issues for C++ rules type: bug
Projects
None yet
Development

No branches or pull requests

4 participants