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

Revert default cpu value on x86 macOS to "darwin" #12918

Closed

Conversation

meteorcloudy
Copy link
Member

@meteorcloudy meteorcloudy commented Jan 28, 2021

Many downstream projects are still depending on the default cpu value
on x86 macOS being "darwin" instead of "darwin_x86_64"

https://buildkite.com/bazel/bazel-auto-sheriff-face-with-cowboy-hat/builds/412

Related: #11628

Many downstream projects are still depending on the default cpu value
being "darwin" instead of "darwin_x86_64"

https://buildkite.com/bazel/bazel-auto-sheriff-face-with-cowboy-hat/builds/412

Related: bazelbuild#11628
@meteorcloudy
Copy link
Member Author

FYI @keith

@bazel-io bazel-io closed this in e96b8ca Jan 28, 2021
meteorcloudy added a commit that referenced this pull request Apr 20, 2021
Many downstream projects are still depending on the default cpu value
on x86 macOS being "darwin" instead of "darwin_x86_64"

https://buildkite.com/bazel/bazel-auto-sheriff-face-with-cowboy-hat/builds/412

Related: #11628

Closes #12918.

PiperOrigin-RevId: 354279409
meteorcloudy added a commit that referenced this pull request Apr 20, 2021
After this PR, we can use a x86 version of Bazel to build an ARM64 Bazel binary for Apple Silicon by
```
bazel build --cpu=darwin_arm64 //src:bazel
```
The Bazel client, embedded tools and embedded JDK are all native ARM64 binaries.

Changes in this PR:
1. Add OpenJDK definitions for ARM64 macOS
2. Manually created the embedded JDK binaries on an Apple Silicon machine and uploaded them to the bazel mirror site.
3. AutoCpuConverter.java: identify the cpu value correctly
4. cc_toolchain_config.bzl: Explicitly specify the target platform also in the x86 cc toolchain, so that we can also do cross-platform compile from ARM64 to x86.

With the native arm64 Bazel binary, building Bazel itself takes only half of the time compared with the x86 Bazel binary on an Apple DTK machine:
```
$ bazel build --cpu=darwin_arm64 --disk_cache= --repository_cache= //src:bazel
Starting local Bazel server and connecting to it...
...
Target //src:bazel up-to-date:
  bazel-bin/src/bazel
INFO: Elapsed time: 1044.462s, Critical Path: 180.08s
INFO: 2984 processes: 179 internal, 2092 darwin-sandbox, 1 local, 712 worker.
INFO: Build completed successfully, 2984 total actions

cp  ./bazel-bin/src/bazel ~/bin/bazel-arm64

$ bazel-arm64 clean --expunge

$ bazel-arm64 build --disk_cache= --repository_cache= //src:bazel
Starting local Bazel server and connecting to it...
...
Target //src:bazel up-to-date:
  bazel-bin/src/bazel
INFO: Elapsed time: 464.470s, Critical Path: 114.88s
INFO: 2984 processes: 179 internal, 2092 darwin-sandbox, 1 local, 712 worker.
INFO: Build completed successfully, 2984 total actions

```

Closes: #11628

Closes #12900.

PiperOrigin-RevId: 354058336

Revert default cpu value on x86 macOS to "darwin"

Many downstream projects are still depending on the default cpu value
on x86 macOS being "darwin" instead of "darwin_x86_64"

https://buildkite.com/bazel/bazel-auto-sheriff-face-with-cowboy-hat/builds/412

Related: #11628

Closes #12918.

PiperOrigin-RevId: 354279409
meteorcloudy added a commit that referenced this pull request Apr 20, 2021
After this PR, we can use a x86 version of Bazel to build an ARM64 Bazel binary for Apple Silicon by
```
bazel build --cpu=darwin_arm64 //src:bazel
```
The Bazel client, embedded tools and embedded JDK are all native ARM64 binaries.

Changes in this PR:
1. Add OpenJDK definitions for ARM64 macOS
2. Manually created the embedded JDK binaries on an Apple Silicon machine and uploaded them to the bazel mirror site.
3. AutoCpuConverter.java: identify the cpu value correctly
4. cc_toolchain_config.bzl: Explicitly specify the target platform also in the x86 cc toolchain, so that we can also do cross-platform compile from ARM64 to x86.

With the native arm64 Bazel binary, building Bazel itself takes only half of the time compared with the x86 Bazel binary on an Apple DTK machine:
```
$ bazel build --cpu=darwin_arm64 --disk_cache= --repository_cache= //src:bazel
Starting local Bazel server and connecting to it...
...
Target //src:bazel up-to-date:
  bazel-bin/src/bazel
INFO: Elapsed time: 1044.462s, Critical Path: 180.08s
INFO: 2984 processes: 179 internal, 2092 darwin-sandbox, 1 local, 712 worker.
INFO: Build completed successfully, 2984 total actions

cp  ./bazel-bin/src/bazel ~/bin/bazel-arm64

$ bazel-arm64 clean --expunge

$ bazel-arm64 build --disk_cache= --repository_cache= //src:bazel
Starting local Bazel server and connecting to it...
...
Target //src:bazel up-to-date:
  bazel-bin/src/bazel
INFO: Elapsed time: 464.470s, Critical Path: 114.88s
INFO: 2984 processes: 179 internal, 2092 darwin-sandbox, 1 local, 712 worker.
INFO: Build completed successfully, 2984 total actions

```

Closes: #11628

Closes #12900.

PiperOrigin-RevId: 354058336

Revert default cpu value on x86 macOS to "darwin"

Many downstream projects are still depending on the default cpu value
on x86 macOS being "darwin" instead of "darwin_x86_64"

https://buildkite.com/bazel/bazel-auto-sheriff-face-with-cowboy-hat/builds/412

Related: #11628

Closes #12918.

PiperOrigin-RevId: 354279409

Update platform version to 0.0.4

Use configuration flags for //src/conditions:darwin_arm64

Partially reverts 6d637f4, to allow
cross-compiling Bazel from darwin_x86_64 to darwin_arm64 with
the `--cpu=darwin_arm64` flag.

The only source that is different between darwin_x86_64 and darwin_arm64
now is the embedded JDK.

Closes #12653.

PiperOrigin-RevId: 346298051

Make sure Bazel selects correct remote JDK on Apple Silicon
philwo pushed a commit that referenced this pull request Apr 20, 2021
After this PR, we can use a x86 version of Bazel to build an ARM64 Bazel binary for Apple Silicon by
```
bazel build --cpu=darwin_arm64 //src:bazel
```
The Bazel client, embedded tools and embedded JDK are all native ARM64 binaries.

Changes in this PR:
1. Add OpenJDK definitions for ARM64 macOS
2. Manually created the embedded JDK binaries on an Apple Silicon machine and uploaded them to the bazel mirror site.
3. AutoCpuConverter.java: identify the cpu value correctly
4. cc_toolchain_config.bzl: Explicitly specify the target platform also in the x86 cc toolchain, so that we can also do cross-platform compile from ARM64 to x86.

With the native arm64 Bazel binary, building Bazel itself takes only half of the time compared with the x86 Bazel binary on an Apple DTK machine:
```
$ bazel build --cpu=darwin_arm64 --disk_cache= --repository_cache= //src:bazel
Starting local Bazel server and connecting to it...
...
Target //src:bazel up-to-date:
  bazel-bin/src/bazel
INFO: Elapsed time: 1044.462s, Critical Path: 180.08s
INFO: 2984 processes: 179 internal, 2092 darwin-sandbox, 1 local, 712 worker.
INFO: Build completed successfully, 2984 total actions

cp  ./bazel-bin/src/bazel ~/bin/bazel-arm64

$ bazel-arm64 clean --expunge

$ bazel-arm64 build --disk_cache= --repository_cache= //src:bazel
Starting local Bazel server and connecting to it...
...
Target //src:bazel up-to-date:
  bazel-bin/src/bazel
INFO: Elapsed time: 464.470s, Critical Path: 114.88s
INFO: 2984 processes: 179 internal, 2092 darwin-sandbox, 1 local, 712 worker.
INFO: Build completed successfully, 2984 total actions

```

Closes: #11628

Closes #12900.

PiperOrigin-RevId: 354058336

Revert default cpu value on x86 macOS to "darwin"

Many downstream projects are still depending on the default cpu value
on x86 macOS being "darwin" instead of "darwin_x86_64"

https://buildkite.com/bazel/bazel-auto-sheriff-face-with-cowboy-hat/builds/412

Related: #11628

Closes #12918.

PiperOrigin-RevId: 354279409

Update platform version to 0.0.4

Use configuration flags for //src/conditions:darwin_arm64

Partially reverts 6d637f4, to allow
cross-compiling Bazel from darwin_x86_64 to darwin_arm64 with
the `--cpu=darwin_arm64` flag.

The only source that is different between darwin_x86_64 and darwin_arm64
now is the embedded JDK.

Closes #12653.

PiperOrigin-RevId: 346298051

Make sure Bazel selects correct remote JDK on Apple Silicon
@keith
Copy link
Member

keith commented Apr 14, 2022

Do you all think we should ever attempt this change again? I don't know if having this legacy value has any impact on platforms or anything that would make it worth trying to do it again?

@meteorcloudy
Copy link
Member Author

Rolling this forward again will of course make the cpu value more clear, but it's a breaking change, many config_settings that have cpu = "darwin" will break. And unfortunately this is again an incompatible change that's hard to migrate because users cannot use cpu = "darwin_x86_64" with current Bazel release version.

@keith
Copy link
Member

keith commented Apr 14, 2022

Yea definitely. Can you think of anything else this will block in the future? Otherwise sounds like we should leave it indefinitely and workaround the issues that come up

@meteorcloudy
Copy link
Member Author

Can you think of anything else this will block in the future?

I don't think so, because even if we change the name to darwin_x86_64, we won't use the original name (darwin) for anything else. So it shouldn't block us.

But ideally, I still want this to be fixed, maybe when less people use cpu = <name> in config_setting, I think that would happen when we enable platform based C++ toolchain resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants