bazelbuild / bazelbuild/bazel

Support cc_toolchain specifying runtime dynamic libraries

Open
#16,309 17 comments 8 reactions 0 assignees View on GitHub
P3 team-Rules-CPP type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the feature request:

When using a `cc_toolchain` which contains self-contained tools (e.g. `clang` + `lld` + `libstdc++`), and dynamically linking, produced binaries have a runtime dependency on some `libstdc++` being present on the machine.

Ideally, we would like our remote execution environment not to have a `libstdc++` present, and would like to specify our hermetically supplied `libstdc++` from our toolchain as a runtime dependency when a binary is run as an action (e.g. when used in a `genrule`).

Currently, we're working around this by installing `libstdc++` in our remote execution environment, but we'd really like to get rid of this if possible. I couldn't find any way of configuring a `cc_toolchain` to set this up.

### What underlying problem are you trying to solve with this feature?

Being able to run Bazel actions in purely hermetic environments, so that each team using our remote execution infrastructure is forced to bring their own `libstdc++` or `libc++` long in their toolchain, rather than falling back to a shared version.

### Which operating system are you running Bazel on?

Linux

### What is the output of `bazel info release`?

release 5.3.1

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

_No response_

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

_No response_

### Have you found anything relevant by searching the web?

Brief discussion on Slack: https://bazelbuild.slack.com/archives/CA31HN1T3/p1663676883083889

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

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by examining how cc_toolchain describes self-contained tools and how genrule actions receive runtime dependencies in Bazel 5.3.1. Reproduce the Linux remote-execution scenario with dynamically linked libstdc++ or libc++, then define the toolchain configuration and action behavior needed for hermetic execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.