Skip to content

Conversation

@aaronsky
Copy link
Contributor

@aaronsky aaronsky commented Feb 5, 2025

Fixes #25167

Copies much of the logic over from blaze_util_linux.cc and its tests into the Darwin space to implement the feature request.

@aaronsky aaronsky marked this pull request as ready for review February 5, 2025 14:49
@github-actions github-actions bot added team-Rules-CPP Issues for C++ rules team-Documentation Documentation improvements that cannot be directly linked to other team labels awaiting-review PR is awaiting review from an assigned reviewer labels Feb 5, 2025
tetromino

This comment was marked as outdated.

@tetromino
Copy link
Contributor

@tetromino tetromino added team-CLI Console UI and removed team-Rules-CPP Issues for C++ rules labels Feb 5, 2025
@tetromino
Copy link
Contributor

tetromino commented Feb 5, 2025

Ok, I've done some git archaeology.

Already in 2016 (commit f107deb) @lberki removed the Unix domain socket file on both linux and mac, and after a rollback and a fix, the change stuck.

In the internal review for f107deb a reviewer noted that this change meant Bazel can switch back from /var/tmp to ${HOME}/Library/Caches (the "normal" cache directory on mac), however this was not followed up upon and not done.

Currently on a mac, find /private/var/tmp/_bazel* -type s finds nothing; it looks like we really are not using Unix domain sockets any more.

My conclusion is that this PR is mostly ok, but we should follow up by also moving to the expected cache dir on mac.

Copy link
Contributor

@tetromino tetromino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment explaining.

Something like:

string GetCacheDir() {
  // See https://stackoverflow.com/questions/3373948/equivalents-of-xdg-config-home-and-xdg-data-home-on-mac-os-x
  // for general background. On macOS, the normal cache directory is
  // ${HOME}/Library/Caches; Bazel historically instead used /var/tmp due to
  // path length limits on Unix domain sockets. (Those limits are no longer
  // relevant since we no longer create Unix domain sockets under output_base.)
  // However, it is still useful to respect ${XDG_CACHE_HOME} because it allows
  // users to easily override the cache directory and is respected by many
  // Linux-derived tools.
  ...

@aaronsky
Copy link
Contributor Author

aaronsky commented Feb 5, 2025

@tetromino Thank you for the feedback – I believe I've incorporated what you've asked for.

@aaronsky aaronsky requested a review from tetromino February 5, 2025 22:55
@aaronsky
Copy link
Contributor Author

aaronsky commented Feb 7, 2025

I don't think these Windows failures are due to my changes.

@aaronsky aaronsky requested a review from tetromino February 7, 2025 02:34
Copy link
Contributor

@tetromino tetromino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@tetromino tetromino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tetromino tetromino added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Feb 7, 2025
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Feb 11, 2025
@tetromino
Copy link
Contributor

@philwo benchmarked that this change noticeably improves build performance on Macs with many cores (e.g. Mac Studio M2 Ultra).

Maybe we ought to cherry-pick it into older branches...

@fmeum
Copy link
Collaborator

fmeum commented Aug 15, 2025

@bazel-io fork 8.4.0

bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Aug 15, 2025
Fixes bazelbuild#25167

Copies much of the logic over from `blaze_util_linux.cc` and its tests into the Darwin space to implement the feature request.

Closes bazelbuild#25205.

PiperOrigin-RevId: 725622080
Change-Id: I46a65076bdea4c0b1989b4816bc41efb123b14be
github-merge-queue bot pushed a commit that referenced this pull request Aug 15, 2025
Fixes #25167

Copies much of the logic over from `blaze_util_linux.cc` and its tests
into the Darwin space to implement the feature request.

Closes #25205.

PiperOrigin-RevId: 725622080
Change-Id: I46a65076bdea4c0b1989b4816bc41efb123b14be

Commit
f6d71e5

Co-authored-by: Aaron Sky <[email protected]>
copybara-service bot pushed a commit that referenced this pull request Dec 5, 2025
Fixes #25260

Implements the request made [here](#25205 (comment)) and moves the default output root on macOS from `/private/var/tmp` to `$HOME/Library/Caches`. May constitute an incompatible change, though on a cursory glance I didn't see any precedent for incompatible startup options in source.

Closes #25262.

PiperOrigin-RevId: 840604399
Change-Id: I391b805b2c8e99d3ffe44a76e916d1c9839225e5
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Dec 5, 2025
Fixes bazelbuild#25260

Implements the request made [here](bazelbuild#25205 (comment)) and moves the default output root on macOS from `/private/var/tmp` to `$HOME/Library/Caches`. May constitute an incompatible change, though on a cursory glance I didn't see any precedent for incompatible startup options in source.

Closes bazelbuild#25262.

PiperOrigin-RevId: 840604399
Change-Id: I391b805b2c8e99d3ffe44a76e916d1c9839225e5
github-merge-queue bot pushed a commit that referenced this pull request Dec 5, 2025
…27875)

Fixes #25260

Implements the request made
[here](#25205 (comment))
and moves the default output root on macOS from `/private/var/tmp` to
`$HOME/Library/Caches`. May constitute an incompatible change, though on
a cursory glance I didn't see any precedent for incompatible startup
options in source.

Closes #25262.

PiperOrigin-RevId: 840604399
Change-Id: I391b805b2c8e99d3ffe44a76e916d1c9839225e5

Commit
13da9a1

Co-authored-by: Aaron Sky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-CLI Console UI team-Documentation Documentation improvements that cannot be directly linked to other team labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Respect XDG directory settings on macOS

3 participants