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 does not build with latest macOS gcc #15168

Closed
nresare opened this issue Apr 4, 2022 · 5 comments
Closed

bazel does not build with latest macOS gcc #15168

nresare opened this issue Apr 4, 2022 · 5 comments
Assignees
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged

Comments

@nresare
Copy link
Contributor

nresare commented Apr 4, 2022

Description of the problem / feature request:

Since Apple charmingly combines their security and feature updates, it is important to be on the latest released version of their operating system and Xcode command line tools. A recent upstream update seems to have broken the ability to compile bazel.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  • Clone and attempt to build bazel with bazel build //src:bazel on a fully up to date macOS

Expected outcome: successful compilation

Actual outcome:

Compilation fails with the following error:

external/com_google_absl/absl/functional/function_ref.h:124:16: error: definition of implicit copy constructor for 'FunctionRef<void (absl::string_view)>' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy]
  FunctionRef& operator=(const FunctionRef& rhs) = delete;
               ^

What operating system are you running Bazel on?

macOS 12.3.1 on an M1 MacBook Air
Command Line Tools for Xcode 13.2

% gcc --version
Apple clang version 13.1.6 (clang-1316.0.21.2)
Target: arm64-apple-darwin21.4.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

What's the output of bazel info release?

% bazel info release
release 5.1.0

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

git remote get-url origin ; git rev-parse master ; git rev-parse HEAD
git@github.com:bazelbuild/bazel.git
436d04d
436d04d

The same problem manifests when checking out version 5.1.0, 93677c6

Have you found anything relevant by searching the web?

It seems there was a fix landed upstream that is referenced here abseil/abseil-cpp#948

It seems from the commit closing the issue that there is a straight forward one line fix, but it is unclear to me how to patch this in the bazel code base.

When I update the grpc version referenced in distdir_deps.bzl from v1.41.1 to v1.45.1, I can no longer reproduce this problem.

@nresare
Copy link
Contributor Author

nresare commented Apr 4, 2022

Looking at the previous PR to update gRPC, making the switch seems to be a bit of work. #15169 does the super ugly "add a patch containing a patch" but it works for me^TM and being able to compile bazel on one of the supported platforms seems like a valuable thing ¯_(ツ)_/¯

@sgowroji sgowroji added untriaged team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website labels Apr 5, 2022
meteorcloudy added a commit to meteorcloudy/bazel that referenced this issue Apr 5, 2022
@nresare
Copy link
Contributor Author

nresare commented Apr 5, 2022

I can confirm that this problem is no longer reproducible in my environment as of commit ab77bd5

Since "being able to build with latest stable release of the main platforms" seems like a pretty important thing to have, I assume that this might be something to consider doing a point release for?

@meteorcloudy
Copy link
Member

@nresare Are you sure? b47aa71 was just submitted after ab77bd5

@nresare
Copy link
Contributor Author

nresare commented Apr 5, 2022

Sorry, my mistake. I had my fix to the problem as a local change in my repository.

With that out of the way, I can now confirm that the problem is indeed present with ab77bd5 but not with b47aa71

@Wyverald
Copy link
Member

Wyverald commented Apr 5, 2022

@bazel-io fork 5.1.1

Wyverald pushed a commit to Wyverald/bazel that referenced this issue Apr 5, 2022
Wyverald added a commit that referenced this issue Apr 5, 2022
Fixes #15168

Closes #15177.

PiperOrigin-RevId: 439541810

Co-authored-by: Yun Peng <pcloudy@google.com>
oliviernotteghem pushed a commit to oliviernotteghem/bazel that referenced this issue Apr 27, 2022
Fixes bazelbuild#15168

Closes bazelbuild#15177.

PiperOrigin-RevId: 439541810

Co-authored-by: Yun Peng <pcloudy@google.com>
lyqaiym pushed a commit to lyqaiym/bazel that referenced this issue May 14, 2023
3.1 bazelbuild#15168

distdir_deps.bzl 文件修改
"abseil-cpp": {
        "archive": "997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz",
        "sha256": "35f22ef5cb286f09954b7cc4c85b5a3f6221c9d4df6b8c4a1e9d399555b366ee",
        "urls": [
            "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz",
            "https://github.com/abseil/abseil-cpp/archive/997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz",
        ],
        "used_in": [
            "additional_distfiles",
            "test_WORKSPACE_files",
        ],
    },
"com_google_absl": {
        "archive": "20211102.0.tar.gz",
        "sha256": "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
        "urls": [
            "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
            "https://github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
        ],
        "used_in": [
            "additional_distfiles",
            "test_WORKSPACE_files",
        ],
        "strip_prefix": "abseil-cpp-20211102.0",
    },

WORKSPACE 文件增加
# Override the abseil-cpp version defined in grpc_deps(), which doesn't work on latest macOS
# Fixes bazelbuild#15168
dist_http_archive(
    name = "com_google_absl",
)

  3.2 src/main/java/net/starlark/java/eval/EvalUtils.java:399: 错误: 找不到符号
      return s.repeat(n);
              ^
  符号:   方法 repeat(int)
  位置: 类型为String的变量 s

    .bazelrc
     # Enable Bzlmod
     build:bzlmod --experimental_enable_bzlmod
     # TODO(pcloudy): The following should be removed after fixing bazelbuild#14279
     build:bzlmod --crosstool_top=@rules_cc.0.0.1.cc_configure.local_config_cc//:toolchain
     build:bzlmod --xcode_version_config=@rules_cc.0.0.1.cc_configure.local_config_xcode//:host_xcodes

     # Enable Java 11 language features (bazelbuild#14592)
     # Toolchain resolution configuration for Bazel >= 5
     build --java_language_version=11
     build --tool_java_language_version=11
     # Legacy configuration for Bazel <= 4
     build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
     build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
lyqaiym pushed a commit to lyqaiym/bazel that referenced this issue May 14, 2023
3.1 bazelbuild#15168

distdir_deps.bzl 文件修改
"abseil-cpp": {
        "archive": "997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz",
        "sha256": "35f22ef5cb286f09954b7cc4c85b5a3f6221c9d4df6b8c4a1e9d399555b366ee",
        "urls": [
            "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz",
            "https://github.com/abseil/abseil-cpp/archive/997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz",
        ],
        "used_in": [
            "additional_distfiles",
            "test_WORKSPACE_files",
        ],
    },
"com_google_absl": {
        "archive": "20211102.0.tar.gz",
        "sha256": "dcf71b9cba8dc0ca9940c4b316a0c796be8fab42b070bb6b7cab62b48f0e66c4",
        "urls": [
            "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
            "https://github.com/abseil/abseil-cpp/archive/refs/tags/20211102.0.tar.gz",
        ],
        "used_in": [
            "additional_distfiles",
            "test_WORKSPACE_files",
        ],
        "strip_prefix": "abseil-cpp-20211102.0",
    },

WORKSPACE 文件增加
# Override the abseil-cpp version defined in grpc_deps(), which doesn't work on latest macOS
# Fixes bazelbuild#15168
dist_http_archive(
    name = "com_google_absl",
)

  3.2 src/main/java/net/starlark/java/eval/EvalUtils.java:399: 错误: 找不到符号
      return s.repeat(n);
              ^
  符号:   方法 repeat(int)
  位置: 类型为String的变量 s

    .bazelrc
     # Enable Bzlmod
     build:bzlmod --experimental_enable_bzlmod
     # TODO(pcloudy): The following should be removed after fixing bazelbuild#14279
     build:bzlmod --crosstool_top=@rules_cc.0.0.1.cc_configure.local_config_cc//:toolchain
     build:bzlmod --xcode_version_config=@rules_cc.0.0.1.cc_configure.local_config_xcode//:host_xcodes

     # Enable Java 11 language features (bazelbuild#14592)
     # Toolchain resolution configuration for Bazel >= 5
     build --java_language_version=11
     build --tool_java_language_version=11
     # Legacy configuration for Bazel <= 4
     build --java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
     build --host_java_toolchain=@bazel_tools//tools/jdk:toolchain_java11
     -------------
     def use_cpp_toolchain(mandatory = True):
         """
         Helper to depend on the c++ toolchain.

         Usage:
         ```
         my_rule = rule(
             toolchains = [other toolchain types] + use_cpp_toolchain(),
         )
         ```

         Args:
           mandatory: Whether or not it should be an error if the toolchain cannot be resolved.
             Currently ignored, this will be enabled when optional toolchain types are added.

         Returns:
           A list that can be used as the value for `rule.toolchains`.
         """
         return [CPP_TOOLCHAIN_TYPE]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged
Projects
None yet
4 participants