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

Bazel 4.0.0 does not work on MacOS #1902

Closed
nakabonne opened this issue Apr 22, 2021 · 4 comments · Fixed by #1912
Closed

Bazel 4.0.0 does not work on MacOS #1902

nakabonne opened this issue Apr 22, 2021 · 4 comments · Fixed by #1912
Assignees
Labels
kind/enhancement New feature or request

Comments

@nakabonne
Copy link
Member

nakabonne commented Apr 22, 2021

What would you like to be added:
After bumping Bazel to 4.0.0, make build failed leaving this clang log: error: unknown argument: '-fdebug-compilation-dir'

Entire log is here:

❯ make build
bazelisk  build  -- //...
(14:05:27) INFO: Current date is 2021-04-22
(14:06:07) INFO: Analyzed 266 targets (2392 packages loaded, 232062 targets configured).
(14:06:07) INFO: Found 266 targets...
(14:06:10) ERROR: /private/var/tmp/_bazel_xxx/05008c7b92f4d912ff12e35796f13e1a/external/com_google_protobuf/BUILD:377:11: Compiling src/google/protobuf/compiler/cpp/cpp_enum_field.cc failed: (Exit 1): wrapped_clang failed: error executing command
  (cd /private/var/tmp/_bazel_xxx/05008c7b92f4d912ff12e35796f13e1a/sandbox/darwin-sandbox/5/execroot/pipe && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.15 \
    PATH=/bin:/usr/bin:/usr/local/bin \
    XCODE_VERSION_OVERRIDE=11.3.1.11C504 \
  external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG '-DNS_BLOCK_ASSERTIONS=1' '-std=c++11' -fdebug-compilation-dir . -iquote external/com_google_protobuf -iquote bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf -iquote external/zlib -iquote bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/zlib -isystem external/com_google_protobuf/src -isystem bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src -isystem external/zlib/zlib/include -isystem bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/zlib/zlib/include -MD -MF bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/_objs/protoc_lib/cpp_enum_field.d '-frandom-seed=bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/_objs/protoc_lib/cpp_enum_field.o' -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks '-mmacosx-version-min=10.15' -g0 -g0 -DHAVE_PTHREAD -DHAVE_ZLIB -Woverloaded-virtual -Wno-sign-compare -Wno-unused-function -Wno-write-strings -Wno-deprecated-declarations -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/com_google_protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc -o bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/_objs/protoc_lib/cpp_enum_field.o)
Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox wrapped_clang failed: error executing command
  (cd /private/var/tmp/_bazel_s07726/05008c7b92f4d912ff12e35796f13e1a/sandbox/darwin-sandbox/5/execroot/pipe && \
  exec env - \
    APPLE_SDK_PLATFORM=MacOSX \
    APPLE_SDK_VERSION_OVERRIDE=10.15 \
    PATH=/bin:/usr/bin:/usr/local/bin \
    XCODE_VERSION_OVERRIDE=11.3.1.11C504 \
  external/local_config_cc/wrapped_clang '-D_FORTIFY_SOURCE=1' -fstack-protector -fcolor-diagnostics -Wall -Wthread-safety -Wself-assign -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG '-DNS_BLOCK_ASSERTIONS=1' '-std=c++11' -fdebug-compilation-dir . -iquote external/com_google_protobuf -iquote bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf -iquote external/zlib -iquote bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/zlib -isystem external/com_google_protobuf/src -isystem bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/src -isystem external/zlib/zlib/include -isystem bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/zlib/zlib/include -MD -MF bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/_objs/protoc_lib/cpp_enum_field.d '-frandom-seed=bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/_objs/protoc_lib/cpp_enum_field.o' -isysroot __BAZEL_XCODE_SDKROOT__ -F__BAZEL_XCODE_SDKROOT__/System/Library/Frameworks -F__BAZEL_XCODE_DEVELOPER_DIR__/Platforms/MacOSX.platform/Developer/Library/Frameworks '-mmacosx-version-min=10.15' -g0 -g0 -DHAVE_PTHREAD -DHAVE_ZLIB -Woverloaded-virtual -Wno-sign-compare -Wno-unused-function -Wno-write-strings -Wno-deprecated-declarations -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/com_google_protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc -o bazel-out/darwin-py2-opt-exec-2B5CBBC6/bin/external/com_google_protobuf/_objs/protoc_lib/cpp_enum_field.o)
Execution platform: @local_config_platform//:host

Use --sandbox_debug to see verbose messages from the sandbox
clang: error: unknown argument: '-fdebug-compilation-dir'
clang: warning: .: 'linker' input unused [-Wunused-command-line-argument]
(14:06:10) INFO: Elapsed time: 43.267s, Critical Path: 0.59s
(14:06:10) INFO: 25 processes: 23 internal, 2 darwin-sandbox.
(14:06:10) FAILED: Build did NOT complete successfully
make: *** [build] Error 1

I tried with bazelisk installed not only go get but brew. But both were the same.

clang version:

❯ clang --version
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Why is this needed:

@nakabonne nakabonne added the kind/enhancement New feature or request label Apr 22, 2021
@nakabonne
Copy link
Member Author

nakabonne commented Apr 22, 2021

We can see the old clang could cause this though: bazelbuild/bazel#12905

@nakabonne
Copy link
Member Author

The path to Xcode was /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin so I reset the path to Xcode with:

sudo xcode-select --switch /Library/Developer/CommandLineTools

Then it was upgraded as expected.

❯ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

But still I am facing the original issue...

@nakabonne
Copy link
Member Author

nakabonne commented Apr 22, 2021

Probably, the reason why it still fails even though clang is updated is wrapped_clang is made of the old one. I assumed it from the skimming the log:

DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer \

The clang under this directory (/Applications/Xcode.app/Contents/Developer) is old one (v11.0.0). So I'm guessing Bazel still refers the old one.

pipecd-bot pushed a commit that referenced this issue Apr 22, 2021
This reverts commit 3b9d3e6.

**What this PR does / why we need it**:
From #1901

#1902 can take a little bit long time. So to workaround we can revert it.

**Which issue(s) this PR fixes**:

Fixes #

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
-->
```release-note
NONE
```

This PR was merged by Kapetanios.
@nakabonne
Copy link
Member Author

/assign @nakabonne

pipecd-bot pushed a commit that referenced this issue Apr 23, 2021
**What this PR does / why we need it**:
Finally I won the game.

**Which issue(s) this PR fixes**:

Fixes #1902

**Does this PR introduce a user-facing change?**:
<!--
If no, just write "NONE" in the release-note block below.
-->
```release-note
NONE
```

This PR was merged by Kapetanios.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant