Skip to content

broken result files when linking with _ld.gold_ is interrupted #117

@jablin

Description

@jablin

Description of the problem

When I interrupt a link step of a C++ project, I get a result of in bazel-bin that has got the correct size but contains only nul bytes.

How To Reproduce The Problem

  • set up a C++ project with lots of cc_binary rules
  • make sure your toolchain uses ld.gold (-fuse-ld=gold)
  • start the build with bazel build --experimental_use_sandboxfs
  • press Ctrl-C
  • look for files filled with nul bytes
    find bazel-bin/ -xtype f -size +0 -exec grep --text --files-without-match -P '[^\0]' {} + -ls

The problem also occurs when a build error occurs and Bazel interrupts currently running linking steps on its own (if you don't use --keep_going).

Environment

RHEL 7.4: Linux 3.10.0, CPU with four cores + HT, using devtool-10 (devtoolset-10-binutils-2.35-3.el7.x86_64).

SW Version

bazel 4.1.0
sandboxfs 0.2.0

Further Observations

ld.gold does not seem to make any effort to prevent broken output files if it gets killed: https://sourceware.org/bugzilla/show_bug.cgi?id=27972

The problem does not occur with GNU ld. GNU ld deletes unfinished output filse in an atexit handler.

Does sandboxfs only check for the existance of the output files and ignore the exit value of ld.gold?

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