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

add cwd to cache prefix #200

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

chrisirhc
Copy link

@chrisirhc chrisirhc commented Nov 3, 2024

Caveat: I don't know what I'm doing with zig. The zig code was mostly code assistant-generated.

I don't think this is a breaking change, but if somebody does rely on the cache location, they can set the HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX to one of the prior values (/tmp, /var/tmp, C:\Temp) to maintain same behavior.

Test Plan

I added a debug print statement for the zig_cache_dir variable to see its value.
I tried the following test cases:

Input:HERMETIC_CC_TOOLCHAIN_CACHE_PREFIX Output: zig_cache_dir (Printed value)
unset <workspace root>/zig-cache
/tmp/my-test-cache /tmp/my-test-cache
my-test-cache <workspace root>/my-test-cache

Where <workspace root> for me looked like /private/var/tmp/_bazel_…/…/sandbox/darwin-sandbox/…/execroot/_main.

Closes #83
Closes #183
Closes #187

@chrisirhc chrisirhc force-pushed the chua/11-03-prefix-cache-dir branch 3 times, most recently from c7aae58 to a0f6a9b Compare November 4, 2024 01:33
@chrisirhc chrisirhc marked this pull request as ready for review November 19, 2024 12:55
@chrisirhc chrisirhc force-pushed the chua/11-03-prefix-cache-dir branch from 2af9bf4 to ec7e654 Compare November 19, 2024 12:58
@chrisirhc
Copy link
Author

Ready for review

@chrisirhc
Copy link
Author

chrisirhc commented Nov 20, 2024

Not sure why https://github.com/uber/hermetic_cc_toolchain/actions/runs/11867448986/job/33075522540 passed yet https://github.com/uber/hermetic_cc_toolchain/actions/runs/11914055410/job/33201139834?pr=200 fails.

The error is:
error: unable to create compilation: Unexpected

Maybe related to: ziglang/zig#19973 , but I don't have a windows machine to test on.

Next things to try:

  • to run using a dev/debug build of Zig to see a full trace
  • to fiddle around on a windows machine
  • try upgrading to zig 0.13 (Dead end, more issues, see upgrade to zig 0.13.0 #203 (comment) )

@chrisirhc chrisirhc force-pushed the chua/11-03-prefix-cache-dir branch from 59f75ed to 288af3c Compare November 21, 2024 11:29
@chrisirhc chrisirhc marked this pull request as draft November 21, 2024 11:30
@chrisirhc chrisirhc force-pushed the chua/11-03-prefix-cache-dir branch from 288af3c to 19dae46 Compare November 21, 2024 13:11
@chrisirhc chrisirhc force-pushed the chua/11-03-prefix-cache-dir branch from 19dae46 to e10f61f Compare November 22, 2024 05:39
@chrisirhc chrisirhc marked this pull request as ready for review November 23, 2024 02:10
@chrisirhc
Copy link
Author

chrisirhc commented Nov 23, 2024

Not sure why https://github.com/uber/hermetic_cc_toolchain/actions/runs/11867448986/job/33075522540 passed yet https://github.com/uber/hermetic_cc_toolchain/actions/runs/11914055410/job/33201139834?pr=200 fails.

The error is: error: unable to create compilation: Unexpected

Rerunning the CI seems to have passed (after I rebased back to a non-upgraded zig 0.13/14 attempt).
I'm guessing this is an intermittent error. 🤷 🫤

Moving this back to "Ready for review"

Copy link
Contributor

@linzhp linzhp left a comment

Choose a reason for hiding this comment

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

@sluongng @laurentlb can you verify if this works for you?

elif os == "linux":
cache_prefix = "/tmp/zig-cache"
if os == "windows" or os == "macos" or os == "linux":
cache_prefix = "zig-cache"
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put it in either bazel-zig-cache or bazel-out/zig-cache? Most bazel project have either /bazel-* or /bazel-out in their .gitignore. They don't need to ignore additional directory if we reuse the existing directories.

@cerisier
Copy link

cerisier commented Nov 30, 2024

Unless mistaken, wouldn't this store the cache inside the action sandbox root, unique to each cc target?
Also, wouldn't it be destroyed between each build invocation ?

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

Successfully merging this pull request may close these issues.

Move /tmp/zig-cache to bazel workspace
3 participants