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

Support FreeBSD as sccache-dist server #1184

Merged
merged 18 commits into from Dec 15, 2022

Conversation

grembo
Copy link
Contributor

@grembo grembo commented Jun 15, 2022

FreeBSD support makes use of pot for sandboxing.

Implementation aimed to be minimally invasive, almost all
FreeBSD specific parts happen in segregated files.

We've been using this successfully in CI for over a month now, so it
appears to be stable enough to be potentially useful to others.

@sylvestre
Copy link
Collaborator

Could you please add a job in the ci to test this on freebsd? Thanks

@codecov-commenter
Copy link

codecov-commenter commented Jun 16, 2022

Codecov Report

Base: 30.03% // Head: 30.02% // Decreases project coverage by -0.01% ⚠️

Coverage data is based on head (b4e85fb) compared to base (635b2a1).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1184      +/-   ##
==========================================
- Coverage   30.03%   30.02%   -0.02%     
==========================================
  Files          47       47              
  Lines       16642    16642              
  Branches     7870     7877       +7     
==========================================
- Hits         4999     4996       -3     
+ Misses       6334     6331       -3     
- Partials     5309     5315       +6     
Impacted Files Coverage Δ
src/compiler/compiler.rs 35.91% <ø> (+0.14%) ⬆️
src/config.rs 35.64% <ø> (-0.18%) ⬇️
src/jobserver.rs 47.91% <0.00%> (-2.09%) ⬇️
src/compiler/gcc.rs 54.33% <0.00%> (-1.04%) ⬇️
src/util.rs 33.44% <0.00%> (-0.33%) ⬇️
src/lru_disk_cache/mod.rs 41.03% <0.00%> (-0.31%) ⬇️
src/compiler/c.rs 38.26% <0.00%> (-0.23%) ⬇️
src/lib.rs 9.04% <0.00%> (-0.06%) ⬇️
src/test/utils.rs 37.37% <0.00%> (ø)
... and 7 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@sylvestre
Copy link
Collaborator

a way to do it:
https://github.com/uutils/coreutils/blob/main/.github/workflows/CICD.yml#L902-L919=

and please run rustfmt on your change

@grembo
Copy link
Contributor Author

grembo commented Jun 16, 2022

a way to do it: https://github.com/uutils/coreutils/blob/main/.github/workflows/CICD.yml#L902-L919=

and please run rustfmt on your change

Thanks for the pointer, I'll look into it.

@drahnr drahnr self-assigned this Jun 21, 2022
@sylvestre
Copy link
Collaborator

@grembo do you have an update on this? thanks

@grembo
Copy link
Contributor Author

grembo commented Jul 4, 2022

@grembo do you have an update on this? thanks

@sylvestre Thanks for asking, no updates yet, as I’ve been too busy with other things, but it will definitely happen soonish.

@grembo grembo force-pushed the freebsd-dist-server branch 2 times, most recently from 0759a5e to c56ecdd Compare July 6, 2022 00:17
@grembo
Copy link
Contributor Author

grembo commented Jul 6, 2022

@sylvestre I rebased the patch and added a series of CI tests for FreeBSD. With those I also found a small issue with creating server tokens which I fixed in the process. Tests for the latest push worked out ok in my account's actions, see https://github.com/grembo/sccache/actions/runs/2619631534 (assuming it is visible to you).

They won't run on your account though, as the required actions aren't allowlisted:

Error: .github#L1
swatinem/rust-cache@v1 and vmactions/freebsd-vm@v0.1.6 are not allowed to be used in mozilla/sccache. Actions in this workflow must be: within a repository that belongs to your Enterprise account, created by GitHub, or matching the following: !/mozilla/, !mozilla/, ./**, 10up/wpcs-action@, aws-actions/, codecov/codecov-action@v2, docker/, pypa/gh-action-pypi-publish@v1.4.2, slackapi/slack-github-action@, google-github-actions/*, erlef/setup-beam@v1.

(see https://github.com/mozilla/sccache/actions/runs/2619631572)

@grembo
Copy link
Contributor Author

grembo commented Jul 6, 2022

@sylvestre I removed the dependency rust-cache and updated the testsuite to be based on macos-12, as it appears to be more stable.

See https://github.com/grembo/sccache/runs/7212100672?check_suite_focus=true#logs for successful CI run in my repo (you would have to allow vmactions/freebsd-vm@b528c16ee726e448eda5b1a78a96b7dc81899b02 or a wildcard version of that in your actions).

@grembo
Copy link
Contributor Author

grembo commented Jul 21, 2022

@sylvestre Rebased again to keep track with @dependabot

Is there anything else from my side that's required at this point?

notallowed

@drahnr
Copy link
Collaborator

drahnr commented Aug 5, 2022

No, at this point it requires some verification on my end, but I won't have time to setup a test env until end of next week.

@grembo
Copy link
Contributor Author

grembo commented Aug 5, 2022

No, at this point it requires some verification on my end, but I won't have time to setup a test env until end of next week.

Cool, thanks for spending time on this. It's certainly not perfect, but works reliably for us.

@sylvestre
Copy link
Collaborator

Sorry again.
I was looking at merging this but the patch needs some rebasing :(

@grembo
Copy link
Contributor Author

grembo commented Oct 19, 2022

Sorry again.
I was looking at merging this but the patch needs some rebasing :(

Rebased and merged some redundant changes (e.g., adding exp: to JWT, which my patch included).

Actions ran successfully in my fork:

Built_ok

@sylvestre
Copy link
Collaborator

Thanks.
I opened this bug on the Mozilla side to get this github action enabled:
https://bugzilla.mozilla.org/show_bug.cgi?id=1796182

@drahnr
Copy link
Collaborator

drahnr commented Oct 20, 2022

Note I just setup freebsd, so I am not at the stage to confirm functionality.

.github/workflows/ci.yml Outdated Show resolved Hide resolved
@sylvestre
Copy link
Collaborator

Yeah, the github action has been activated:
https://github.com/mozilla/sccache/actions/runs/3290878677/jobs/5424313325

@grembo
Copy link
Contributor Author

grembo commented Oct 21, 2022

@sylvestre Moving parts of the action to a script (which then could also be used for local testing) makes a lot of sense. It will also allow to runs tests in a loop on beefier hardware to check test stability.

It's a bit unclear what happened with the previous runs (timing out after 6 hours, while a build should take < 1 hour):

Screen Shot

I'll also add "copyback: false" to the CI action, as there are no artifacts we want to copy out (maybe that's part of the issue).

@grembo
Copy link
Contributor Author

grembo commented Oct 23, 2022

@sylvestre Like you suggested, I moved most of the CI actions into a separate script, which now allow to run the test locally. I ran this in a loop and after some tinkering it seems to be stable. Also did a few other minor improvements like outlined in the commit log.

@sylvestre
Copy link
Collaborator

Much better, thanks

grembo and others added 13 commits November 30, 2022 17:24
FreeBSD support makes use of [pot](https://github.com/potbsd/pot)
for sandboxing.

Implementation was done to be minimally invasive, almost all
FreeBSD specific parts happen in segregated files.
This was broken in 5032a83, which correctly stated
in its commit message that "exp" is mandatory in the
new version of jwtwebtoken.
This:
- Builds sccache/sccache-dist
- Runs unit tests
- Does a real world test of sccache and sccache-dist
  using ZFS/pot and a small sample rust project
Since macOS VMs should have plenty of RAM, I went all in.
Also add sleep to give sscache server time to settle in.
This also has vmware and appears to be a bit more stable.

Also reformat test_freebsd target to use longer lines.
Move most of FreeBSD CI script into a shell script that can
be used locally. Update documentation for 13.1.

Disable copyback from vm image, set time limit on CI.

Account for first distributed compile call sometimes
failing.

Rename job to match others.
@sylvestre
Copy link
Collaborator

Seems that they regressed on

  error[E0308]: mismatched types
    --> /opt/tester/.cargo/registry/src/github.com-1ecc6299db9ec823/core_affinity-0.7.5/src/lib.rs:51:5
     |
  50 | pub fn set_for_current(core_id: CoreId) -> bool {
     |                                            ---- expected `bool` because of return type
  51 |     set_for_current_helper(core_id)
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
  

Rings a bell ?
thanks

grembo added a commit to grembo/core_affinity_rs that referenced this pull request Nov 30, 2022
This fixes the build on FreeBSD (and other OSes). See mozilla/sccache#1184
@grembo
Copy link
Contributor Author

grembo commented Nov 30, 2022

core_affinity

I downloaded the repo, debugged it and was about to open a pull request, just to find that there is one already:

Elzair/core_affinity_rs#15

sylvestre added a commit to sylvestre/gzp that referenced this pull request Dec 9, 2022
sstadick pushed a commit to sstadick/gzp that referenced this pull request Dec 12, 2022
@sylvestre sylvestre merged commit febb667 into mozilla:main Dec 15, 2022
@drahnr
Copy link
Collaborator

drahnr commented Dec 15, 2022

Thank you, I was about to hit the button 👍

@sylvestre
Copy link
Collaborator

@grembo it is now in the 4.0.0 pre1 release
freebsd binaries aren't available here:
https://github.com/mozilla/sccache/releases
would you like to update the CI to generate them?

@grembo
Copy link
Contributor Author

grembo commented Dec 19, 2022

@grembo it is now in the 4.0.0 pre1 release freebsd binaries aren't available here: https://github.com/mozilla/sccache/releases would you like to update the CI to generate them?

@sylvestre Sounds like a good idea. How would you approach it though? Right now we build and test in one target (which does not build a release version). Creating a separate build target for FreeBSD would be an option, but the mac-wrapping is already quite expensive - maybe build the release after build/test worked out ok (and then upload the artifacts)? Otherwise, if this consumes too many resources, sccache-dist will certainly become part of the FreeBSD sccache port, so it will also be available to users using pkg install eventually.

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.

None yet

4 participants