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

MacOS crosstool configures /usr/bin/strip with invalid flags #4028

Closed
jmillikin-stripe opened this issue Nov 6, 2017 · 2 comments
Closed
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) type: bug

Comments

@jmillikin-stripe
Copy link
Contributor

This report is against Bazel release 0.7.0.

tools/osx/crosstool/CROSSTOOL.tpl configures /usr/bin/strip with multiple -R flags. In the GNU toolchain this flag removes a named section, but Clang (installed by Apple's dev tools) has a different definition of the -R flag.

       -R filename
              Remove the symbol table entries for the global symbols listed in
              filename.  This file has the same  format  as  the  -s  filename
              option  above.   This option is usually used in combination with
              other options that save some symbols, -S, -x, etc.

This causes builds of stripped binaries to fail on MacOS:

$ ~/bin/bazel build -s //:hello.stripped
# [...]
>>>>> # //:hello [action 'Stripping hello.stripped for //:hello']
(cd /private/var/tmp/_bazel_jmillikin/6469710131e6db2fa36d059d1b1c2547/execroot/__main__ && \
  exec env - \
    PATH=/usr/local/bin:/usr/bin:/bin \
    TMPDIR=/var/folders/bd/0cbzdsgs2lq1dtg56xn8c07c0000gn/T/ \
  /usr/bin/strip -S -o bazel-out/local-fastbuild/bin/hello.stripped -R .gnu.switches.text.quote_paths -R .gnu.switches.text.bracket_paths -R .gnu.switches.text.system_paths -R .gnu.switches.text.cpp_defines -R .gnu.switches.text.cpp_includes -R .gnu.switches.text.cl_args -R .gnu.switches.text.lipo_info -R .gnu.switches.text.annotation bazel-out/local-fastbuild/bin/hello)
ERROR: /Users/jmillikin/src/hello_cc/BUILD:1:1: Stripping hello.stripped for //:hello failed (Exit 1).
fatal error: /Library/Developer/CommandLineTools/usr/bin/strip: only one -R option allowed
Target //:hello.stripped failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.491s, Critical Path: 0.19s

Here's the workspace content to reproduce:

$ cat BUILD 
cc_binary(
    name = "hello",
    srcs = ["hello.cc"],
)
$ cat hello.cc 
#include <cstdio>

int main() {
  printf("Hello world!\n");
  return 0;
}
jmillikin-stripe added a commit to jmillikin-stripe/bazel that referenced this issue Nov 6, 2017
@damienmg damienmg added category: rules > C++ P2 We'll consider working on this in future. (Assignee optional) type: bug labels Nov 8, 2017
@hlopko hlopko self-assigned this Nov 12, 2017
@hlopko
Copy link
Member

hlopko commented Nov 13, 2017

Hi John, internal reviewer asked for tests, could you add some to src/test/shell/bazel/apple/bazel_objc_test.sh please?

jmillikin-stripe added a commit to jmillikin-stripe/bazel that referenced this issue Nov 13, 2017
@jmillikin-stripe
Copy link
Contributor Author

Test added, to cpp_darwin_integration_test.sh -- this isn't Objective-C, it's just regular C++.

I'm some trouble running the test (with changes or at HEAD) because Bazel gets into an infinite loop and consumes all my disk. I'll keep trying.

jmillikin-stripe added a commit to jmillikin-stripe/bazel that referenced this issue Nov 13, 2017
jmillikin-stripe added a commit to jmillikin-stripe/bazel that referenced this issue Nov 14, 2017
jmillikin-stripe added a commit to jmillikin-stripe/bazel that referenced this issue Nov 15, 2017
Fixes bazelbuild#4028

Also fixes bazelbuild#4085 by removing
incorrect output redirection from the Darwin integration tests used to
verify `strip` works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) type: bug
Projects
None yet
Development

No branches or pull requests

3 participants