Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jablin opened this issue May 12, 2021 · 0 comments
Open

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

jablin opened this issue May 12, 2021 · 0 comments

Comments

@jablin
Copy link

jablin commented May 12, 2021

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?

@jablin jablin changed the title broken result file when build is aborted broken cc_binary result file when build is aborted May 21, 2021
@jablin jablin changed the title broken cc_binary result file when build is aborted broken result files when linking with _ld.gold_ is interrupted Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant