Skip to content

cmake builds in bazel 8+ can produce improper includes paths #1430

Open
@jared-rodgers-figure

Description

@jared-rodgers-figure

Not sure what changed in bazel 8+, but the repro below shows that this ruleset produces what looks like the full path of a dereferenced symlink in the includes dir. The issue does not appear in bazel 7.6.1

Create a workspace for the minimal repro

# MODULE.bazel
module(
    name = "proxsuite_repro",
    version = "0.1.0",
)

bazel_dep(name = "rules_foreign_cc", version = "0.15.0")

http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "proxsuite",
    build_file = "@//:third_party/proxsuite/build_file.bazel",
    integrity = "sha256-wukoqjXEL9xSl6gbncxqf5J8igsBoY0ZhHgNZ969qnY=",
    strip_prefix = "proxsuite-0.5.0",
    url = "https://github.com/Simple-Robotics/proxsuite/releases/download/v0.5.0/proxsuite-0.5.0.tar.gz",
)
# thirdparty/proxsuite/build_file.bazel
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

filegroup(
    name = "all_srcs",
    srcs = glob(["**"]),
)

cmake(
    name = "proxsuite",
    generate_args = [
        "-GNinja",
    ],
    cache_entries = {
        "CMAKE_BUILD_TYPE": "RelWithDebInfo",
        "BUILD_TESTING": "OFF",
        "BUILD_PYTHON_INTERFACE": "OFF",
        "BUILD_WITH_VECTORIZATION_SUPPORT": "ON",
    },
    copts = ["-Wno-error"],
    lib_source = ":all_srcs",
    out_headers_only = True,
    visibility = ["//visibility:public"],
)

Launch base container (assuming you are in your working dir)

docker run -v .:/tmp/workspace -it ubuntu:22.04 bash

In container Install deps for build

apt update && apt install -y wget build-essential libeigen3-dev=3.4.0* libsimde-dev=0.7.2*

Install bazelisk to swap between versions easily later

wget --progress=dot:giga https://github.com/bazelbuild/bazelisk/releases/download/v1.22.1/bazelisk-amd64.deb && dpkg -i bazelisk-amd64.deb && rm -f bazelisk-amd64.deb

enter working dir

cd /tmp/workspace

build using latest bazel version as of writing

echo 8.3.1 > .bazelversion
bazel build @proxsuite
ls bazel-bin/external/+_repo_rules+proxsuite/proxsuite/include
# Note that there are 2 dirs in the includes directory one looks like symlinks were dereferenced and the full path was placed in the direcory. 

output

root@4e93b28779b9:/tmp/workspace# tree -a bazel-bin/external/+_repo_rules+proxsuite/proxsuite
bazel-bin/external/+_repo_rules+proxsuite/proxsuite
`-- include
    |-- proxsuite
    |   |-- config.hpp
    |   |-- deprecated.hpp
    |   `-- warning.hpp
    `-- root
        `-- .cache
            `-- bazel
                `-- _bazel_root
                    `-- 9cc7d801fb7b9b2f471013117c1d1061
                        `-- sandbox
                            `-- processwrapper-sandbox
                                `-- 3
                                    `-- execroot
                                        `-- _main
                                            `-- external
                                                `-- +_repo_rules+proxsuite
                                                    `-- proxsuite
                                                        |-- fwd.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/+_repo_rules+proxsuite/include/proxsuite/fwd.hpp
                                                        |-- helpers
                                                        |   |-- common.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/+_repo_rules+proxsuite/include/proxsuite/helpers/common.hpp

...

Revert to latest 7.x.y version (7.6.1 as of writing)

echo 7.6.1 > .bazelversion
bazel build @proxsuite
ls bazel-bin/external/_main~_repo_rules~proxsuite/proxsuite/include
# Note that there is only 1 dir with the includes placed properly.

output

root@4e93b28779b9:/tmp/workspace# tree -a bazel-bin/external/_main~_repo_rules~proxsuite/proxsuite
bazel-bin/external/_main~_repo_rules~proxsuite/proxsuite
`-- include
    `-- proxsuite
        |-- config.hpp
        |-- deprecated.hpp
        |-- fwd.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/fwd.hpp
        |-- helpers
        |   |-- common.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/helpers/common.hpp
        |   |-- instruction-set.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/helpers/instruction-set.hpp
        |   |-- optional.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/helpers/optional.hpp
        |   |-- tl-optional.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/helpers/tl-optional.hpp
        |   `-- version.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/helpers/version.hpp
        |-- linalg
        |   |-- dense
        |   |   |-- core.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/dense/core.hpp
        |   |   |-- factorize.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/dense/factorize.hpp
        |   |   |-- ldlt.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/dense/ldlt.hpp
        |   |   |-- modify.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/dense/modify.hpp
        |   |   |-- solve.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/dense/solve.hpp
        |   |   `-- update.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/dense/update.hpp
        |   |-- sparse
        |   |   |-- core.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/sparse/core.hpp
        |   |   |-- factorize.hpp -> /root/.cache/bazel/_bazel_root/9cc7d801fb7b9b2f471013117c1d1061/execroot/_main/external/_main~_repo_rules~proxsuite/include/proxsuite/linalg/sparse/factorize.hpp
...

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