Skip to content

undeclared inclusions if additional_compiler_inputs is in the root of the repo #543

@keith

Description

@keith

repro.zip

With this BUILD file in the root of the repo:

load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
    name = "lib",
    srcs = ["lib.cc"],
    additional_compiler_inputs = [
        "foo.txt",
    ],
    copts = [
        "-std=c++23",
        "-Wno-c23-extensions",
    ],
    local_defines = [
        "THING=\\\"$(execpath foo.txt)\\\"",
    ],
)

If you build this target with 9.0.0rc3 + 943f3b0 you get:

% CC=clang USE_BAZEL_VERSION=last_rc bazel build :lib
INFO: Analyzed target //:lib (1 packages loaded, 3 targets configured).
ERROR: /tmp/repro/BUILD.bazel:3:11: Compiling lib.cc failed: absolute path inclusion(s) found in rule '//:lib':
the source file 'lib.cc' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
  '/tmp/repro/foo.txt'
Target //:lib failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.741s, Critical Path: 0.43s
INFO: 3 processes: 3 internal.
ERROR: Build did NOT complete successfully

If you use the exact same structure in a nested directory it works as expected:

% CC=clang USE_BAZEL_VERSION=last_rc bazel build nested:lib
INFO: Analyzed target //nested:lib (1 packages loaded, 3 targets configured).
INFO: Found 1 target...
Target //nested:lib up-to-date:
  bazel-bin/nested/liblib.a
  bazel-bin/nested/liblib.so
INFO: Elapsed time: 0.141s, Critical Path: 0.00s
INFO: 1 process: 4 action cache hit, 1 internal.
INFO: Build completed successfully, 1 total action

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions