Skip to content

fully_static_link is broken #8672

@iceboy233

Description

@iceboy233

Description of the problem / feature request:

fully_static_link is broken.

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

WORKSPACE

BUILD

cc_binary(
    name = "a",
    srcs = ["a.cc"],
)

a.cc

int main() { new int; }

Build command and output:

% bazel build --features=fully_static_link :a
INFO: Analyzed target //:a (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /usr/local/google/home/iceboy/tmp/hellobazel/BUILD:1:1: Linking of rule '//:a' failed (Exit 1) gcc failed: error executing command /usr/bin/gcc @bazel-out/k8-fastbuild/bin/a-2.params

Use --sandbox_debug to see verbose messages from the sandbox
bazel-out/k8-fastbuild/bin/_objs/a/a.pic.o:a.cc:function main: error: undefined reference to 'operator new(unsigned long)'
collect2: error: ld returned 1 exit status
Target //:a failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.190s, Critical Path: 0.10s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

release 0.27.0

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

Could you also share the state-of-the-art way of doing mostly static build? That is, linking libc and libm dynamically while linking other libraries (including libstdc++) statically?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-Rules-CPPIssues for C++ rulestype: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions