carbon-lang
carbon-lang copied to clipboard
Toolchain configuration can't produce stripped binaries
On macOS, at 9ed1c5cee9c3326178b80a35a8f217257971b410, with or without .bazeliskrc wired to 4.0.0:
$ bazelisk build //executable_semantics:executable_semantics.stripped
[...]
ERROR: /Users/mattdr/src/carbon-lang/executable_semantics/BUILD:11:10: Stripping executable_semantics/executable_semantics.stripped for //executable_semantics:executable_semantics failed: (Exit 1): llvm-strip failed: error executing command /private/var/tmp/_bazel_mattdr/d9970d429502ef17c1da219b3a765faf/external/bootstrap_clang_toolchain/bin/llvm-strip
Use --sandbox_debug to see verbose messages from the sandbox llvm-strip failed: error executing command /private/var/tmp/_bazel_mattdr/d9970d429502ef17c1da219b3a765faf/external/bootstrap_clang_toolchain/bin/llvm-strip
Use --sandbox_debug to see verbose messages from the sandbox
OVERVIEW: llvm-strip tool
USAGE: llvm-strip [options] inputs...
[...]
We can confirm with aquery that Bazel is invoking llvm-strip with no arguments:
$ bazelisk aquery 'mnemonic("CcStrip", //executable_semantics:executable_semantics)'
INFO: Analyzed target //executable_semantics:executable_semantics (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
action 'Stripping executable_semantics/executable_semantics.stripped for //executable_semantics:executable_semantics'
Mnemonic: CcStrip
Target: //executable_semantics:executable_semantics
Configuration: darwin-fastbuild
ActionKey: f5e061b91160a2d1693c98ea4144f0090598e0d626416aa402d52095236980ed
Inputs: [bazel-out/darwin-fastbuild/bin/executable_semantics/executable_semantics, bazel-out/darwin-opt-exec-2B5CBBC6/internal/_middlemen/external_Sbazel_Ucc_Utoolchain_Cempty]
Outputs: [bazel-out/darwin-fastbuild/bin/executable_semantics/executable_semantics.stripped]
Environment: [LANG=en_US.UTF-8]
Command Line: (exec /private/var/tmp/_bazel_mattdr/d9970d429502ef17c1da219b3a765faf/external/bootstrap_clang_toolchain/bin/llvm-strip)
By comparison, if I create another Bazel workspace elsewhere and let it pick up the local toolchain, we see:
$ bazelisk aquery 'mnemonic("CcStrip", //:hello)'
INFO: Analyzed target //:hello (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
action 'Stripping hello.stripped for //:hello'
Mnemonic: CcStrip
Target: //:hello
Configuration: darwin-fastbuild
ActionKey: 010f253cf13d63c4f2509c10f0ee0b534d93c03d0c65d24a4398b1c6e04d6068
Inputs: [bazel-out/darwin-fastbuild/bin/hello, bazel-out/darwin-opt-exec-2B5CBBC6/internal/_middlemen/external_Slocal_Uconfig_Ucc_Cempty]
Outputs: [bazel-out/darwin-fastbuild/bin/hello.stripped]
Command Line: (exec /usr/bin/strip \
-S \
-o \
bazel-out/darwin-fastbuild/bin/hello.stripped \
bazel-out/darwin-fastbuild/bin/hello)
that configuration appears to come from: https://github.com/bazelbuild/bazel/blob/073ae810e4f61f56f68a31d5ee95f18633d176cc/tools/osx/crosstool/cc_toolchain_config.bzl#L296-L311
meanwhile, we configure the strip action but don't attach any flag_sets, so I guess Bazel just thinks it can run it with no flags.
https://github.com/carbon-language/carbon-lang/blob/2111b859da527d02c7eda7bcc1558b25a57f20f3/bazel/cc_toolchains/clang_cc_toolchain_config.bzl#L97-L100
for posterity: we noticed this when a developer ran
bazelisk build //executable_semantics:*
because the * picks up all file targets, which includes the implicit .stripped target of the executable_semantics binary. Building //executable_semantics/... or //executable_semantics:all wouldn't reproduce the issue.
/cc @chandlerc for interest
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the inactive label. The long term label can also be added for issues which are expected to take time.
This issue is labeled inactive because the last activity was over 90 days ago.