-
Notifications
You must be signed in to change notification settings - Fork 4
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
remove opam dependancy #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. The context here is that when used in a nix
build, the opam
command is not available (or available but with no switch bound to it), so we need a default configuration for the number of jobs used in the build.
I'm sorry to be picky, but Or, in case of |
Yes we figured the portability issue. Another solution is to use GMP is quite long to build so parallel jobs are very useful, hence the choice to use more than one job when possible. The reason why |
Yes, I tried to build an opam switch in a nix derivation but there doesn't seem to be a nice way to install the compiler without network access.
I've just pushed a change that defaults to 1 if
It seems like the variable for CPU cores in sysctl differs by platform ( This shouldn't be an issue outside though. Where opam is available outside nix derivations this will continue working as normal. On Linux the number of physical cores will be used, and otherwise it will fall back on 1. |
It seems rather counter-intuitive to me when the |
I'm all in for removing the opam dependency from the build of Now, on the downside I'm against adding complexity (read: conditionals) to the build systems. So, if it is desired to use multiple CPU cores while building ocaml-gmp, why not resort to the opam package processor (https://github.com/haesbaert/ocaml-processor) that provides a function |
It actually does not really anymore -- I mean truly there's the opam-repository, and Anyways, I gathered the parts of opam that are needed (or used to be needed?) in a shell script https://github.com/roburio/orb/blob/next/opam.sh (NB: mirage3 and mirage4 workflows) (which works fine to build many unikernels. see the https://builds.robur.coop overview). |
With this workflow we actually only use opam to resolve dependency versions. Nix provides binary or source (for the monorepo workflow) derivations for all the dependencies. |
Correct me if I'm wrong, but this would require adding OCaml as a dependency to the project? |
@RyanGibb yes, this will add "ocaml" as a dependency to ocaml-gmp. But turns out, it already depends on |
Great, this sounds like it would be a more portable solution then :) |
I can confirm this is building mirage-www! |
Can you run a |
uhm, this still uses |
I've replaced this with a call to
And removed the opam conditional. Let me know what you think of this! |
thanks, looks good to me |
Hmm, this doesn't seem to work in a monorepo:
I could try and patch/submit a PR for this but I'm not familiar with the project. Do you know what's going on here (why these modules don't have an implementation) @hannesm? |
/cc @haesbaert |
Basically we try to do some discovery on how to best build the topology and query modules, somehow you're not falling into any of the cases from dune:
Do the dune variables somehow evaluate to something else in the monorepo ? as in is system not linux and architecture not amd64 ? |
Btw: you can also:
|
May be related to / an instance of ocaml/dune#3917 |
hmm could be, maybe @TheLortex can cheap in ? I never used monorepo, but to my knowledge those variables are obtained in the runtime (it's what comes from |
Thanks, that makes sense.
Hmm, this is running on x86-64 Linux. Possibly nix sandboxing is to blame. I'm trying to figure out a way to debug dune variables (e.g. print them to stdout).
The only issue with this is that |
Not sure I agree, threads helping or not is not much related to it being CPU bound, it's more related to instructions per cycles and therefore cache-misses, building stuff is very cache non friendly, so threading should help. IMHO: this isn't something you/we should ponder much, this is hard to know in advance and depends on a bunch of stuff, the sane thing to do is just build on every logical CPU available (you can test if you want, but I doubt you find a case where threading doesn't help). I used to build many things on a Niagra T2 (8 threads per core) on an SO where the kernel was completely giant locked, and using all threads were still almost always beneficial. |
That makes complete sense. It sounds like to avoid the complexity of building I believe |
yes, well, at least on FreeBSD that's fine. :) |
886b28f
to
04704d2
Compare
Great :) I've also added a default value of 1 if |
Good call ! |
Ok, so if everyone is happy with this PR, we can merge it. @TheLortex do you want to release it? |
Yes I can take care of it today. |
CHANGES: - Build system: when used in a monorepo, do not invoke `opam` to figure out the level of parallelism. Instead, use `sysctl` to obtain the number of cores and provide `1` as a default value. (@RyanGibb, mirage/ocaml-gmp#18)
if the
opam config subst
call fails, substitute the jobs variable with the number of physical cores in the machine