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

Document how to bring non-source tree absolute paths into your workspace. #8846

Open
sertel opened this issue Jul 10, 2019 · 5 comments
Open
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: documentation (cleanup)

Comments

@sertel
Copy link

sertel commented Jul 10, 2019

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

I'm trying to configure a simple C++ project with the following BUILD:

cc_binary(
    name = "my-llvm-project",
    srcs = glob(["*.cc"]),
    copts = ["-I/usr/inlcude/llvm-6.0/include"],
)

The error is:

The include path '/usr/inlcude/llvm-6.0/include' references a path outside of the execution root.

I also tried to use includes instead:

cc_binary(
    name = "my-llvm-project",
    srcs = glob(["*.cc"]),
    includes = ["/usr/inlcude/llvm-6.0/include"],
)

Bazel says:

in includes attribute of cc_binary rule //main:my-llvm-project: ignoring invalid absolute path '/usr/inlcude/llvm-6.0/include'

Even if I declare llvm as a library:

cc_library(
    name = "llvm-dep",
    hdrs = glob(["/usr/include/llvm-6.0/include/*.h",
    "/usr/include/llvm-6.0/include/**/*.h"]),
)

cc_binary(
    name = "my-llvm-project",
    srcs = glob(["*.cc"]),
    deps = ["llvm-dep"]
)

I get the following error message:

pattern cannot be absolute

If there is a preferred way of doing this in bazel then it should be in the docs.

What operating system are you running Bazel on?

Ubuntu LTS 18.04 (bionic) on the following kernel:
Linux 4.4.0-17763-Microsoft (WSL)

What's the output of bazel info release?

release 0.27.1

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

I used the binary installer as described here:
https://docs.bazel.build/versions/master/install-ubuntu.html#install-with-installer-ubuntu

Have you found anything relevant by searching the web?

This issue might be related:
#3239

@sertel
Copy link
Author

sertel commented Jul 10, 2019

I finally found this post:
https://groups.google.com/forum/#!searchin/bazel-discuss/cc_library$20includes%7Csort:date/bazel-discuss/lsbxZxNjJQw/NKb7f_eJBwAJ
It suggests to set up a local repository:

WORKSPACE:

new_local_repository(
    name = "llvm",
    path = "/usr/lib/llvm-6.0/include",
    build_file_content = """
package(default_visibility = ["//visibility:public"])
cc_library(
    name = "headers",
    hdrs = glob(["**/*.h"])
)
"""
)

BUILD:

package(default_visibility = ["//visibility:public"])

cc_binary(
    name = "my-llvm-project",
    srcs = glob(["*.cc"]),
    copts = ["-Iexternal/llvm"],
    deps = ["@llvm//:headers"]
)

I leave the issue open nevertheless because it would really be great to find this trivial use case on the documentation website. It would have been a great help for me.

@aiuto aiuto added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: documentation (cleanup) untriaged labels Jul 11, 2019
@aiuto aiuto changed the title Absolute include paths don't work for CPP projects Document how to bring non-source tree absolute paths into your workspace. Jul 11, 2019
@aiuto
Copy link
Contributor

aiuto commented Jul 11, 2019

I changed the title to highlight that this is really a knowledge transfer problem. PTAL.

@laurentlb laurentlb added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Jul 24, 2019
@brianjenkins94
Copy link

brianjenkins94 commented Dec 18, 2019

Is creating a repository the generally accepted solution? Feels like there's still a documentation gap -- if not a knowledge gap here.

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@philwo philwo added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) labels Dec 8, 2020
andreabolognani added a commit to andreabolognani/kubevirt that referenced this issue Jul 19, 2021
Original error message:

  ERROR: /root/go/src/kubevirt.io/kubevirt/cmd/container-disk-v2alpha/BUILD.bazel:3:10:
  undeclared inclusion(s) in rule '//cmd/container-disk-v2alpha:container-disk':
  this rule is missing dependency declarations for the following files
  included by 'cmd/container-disk-v2alpha/main.c':
    '/usr/lib/gcc/x86_64-redhat-linux/8/include/stdarg.h'
    '/usr/lib/gcc/x86_64-redhat-linux/8/include/stddef.h'
    '/usr/lib/gcc/x86_64-redhat-linux/8/include/stdbool.h'

Adapted from:

  bazelbuild/bazel#8846 (comment)

This is probably not the correct solution: for one, it's pretty
obvious that it won't work on aarch64.

Some tests still fail even after this change.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
@ShreeM01 ShreeM01 added the team-Documentation Documentation improvements that cannot be directly linked to other team labels label Dec 5, 2022
Copy link

github-actions bot commented Feb 9, 2024

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.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 9, 2024
@hzeller
Copy link

hzeller commented Mar 3, 2024

Is there a documentation in the meantime ?
It would be good if bazel would emit an actionable error message, i.e. have a link to an explanation and how to fix or work-around.

The more people start using systems that expose includes in content-hash-derived paths (such as NixOS), being able to direct bazel to accept system headers in in paths outside its sandboxed comfort-zone is important.

@github-actions github-actions bot removed the stale Issues or PRs that are stale (no activity for 30 days) label Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Documentation Documentation improvements that cannot be directly linked to other team labels team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: documentation (cleanup)
Projects
None yet
Development

No branches or pull requests

7 participants