bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.13k stars 4.05k forks source link

Bazel Fails with "undeclared inclusion(s) in rule" with custom C++ toolchain and --output_user_root #15127

Open thomasyoung opened 2 years ago

thomasyoung commented 2 years ago

Description of the problem / feature request:

Have a .bazelrc file in home folder with

startup --output_user_root=

Using custom C++ toolchain which calls tensorflow style python wrapper of cuda compiler and gcc as needed. Bazel is calling the compiler with MF option for dependency. In the dependency output .d file reads most lines with relative path like

external/qnx710-ga1/target/qnx7/usr/include/stddef.h \

with one line using absolute path

/src/workspace/bazel/build_output/13bf0abeafa1b9e4b8e291d4ff774878/external/qnx710-ga1/host/linux/x86_64/usr/bin/../lib/gcc/aarch64-unknown-nto-qnx7.1.0/8.3.0/include/stddef.h \

and bazel is reporting failure like:

this rule is missing dependency declarations for the following files included by '': '/src/workspace/bazel/build_output/13bf0abeafa1b9e4b8e291d4ff774878/external/qnx710-ga1/host/linux/x86_64/usr/lib/gcc/aarch64-unknown-nto-qnx7.1.0/8.3.0/include/stddef.h'

Feature requests: what underlying problem are you trying to solve with this feature?

Build source code properly with custom output root folder.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Try use --output_user_root other than default.

What operating system are you running Bazel on?

Ubuntu 18.04LTS

What's the output of bazel info release?

release 4.2.2

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

NA

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

NA

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

Replace this line with your answer.

thomasyoung commented 2 years ago

Believe the absolute path in depencency (.d) file is from the underlying GCC somehow.

github-actions[bot] commented 1 year ago

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.

cameron-martin commented 1 year ago

I'm possibly having a similiar issue. It seem that dependencies from external repositories are written to the .d file as an absolute path, and maybe bazel thinks these are undeclared system dependencies.

fmeum commented 1 year ago

@cameron-martin It would be really helpful to have a reproducer for this kind of issue.

cameron-martin commented 1 year ago

The problem in my case was using clang but not passing -no-canonical-prefixes. I wonder if this is also the OPs issue.

github-actions[bot] commented 1 week ago

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. If you think this issue is still relevant and should stay open, please post any comment here and the issue will no longer be marked as stale.