cheribuild icon indicating copy to clipboard operation
cheribuild copied to clipboard

ocaml projects aren't cloned from git before their builds are attempted?

Open nwf opened this issue 4 years ago • 2 comments

For example, if I don't have lem cloned, I get...

$ ~/cheri/cheribuild/cheribuild.py lem
Will execute the following 1 targets:
   lem
/usr/bin/opam --version
cd /home/nwf/cheri/lem && env GIT_TEMPLATE_DIR= OPAMROOT=/home/nwf/cheri/output/sdk/opamroot OPAM_USER_PATH_RO=/usr/bin /usr/bin/opam switch --root=/home/nwf/cheri/output/sdk/opamroot sail
cd /home/nwf/cheri/lem && env GIT_TEMPLATE_DIR= OPAMROOT=/home/nwf/cheri/output/sdk/opamroot OPAM_USER_PATH_RO=/usr/bin /usr/bin/opam switch --root=/home/nwf/cheri/output/sdk/opamroot export --switch=default /home/nwf/cheri/output/sdk/opamroot/default-export
Fatal error: Dependency for lem missing: missing opam package zarith
Possible solution: Try running `/usr/bin/opam install --root=/home/nwf/cheri/output/sdk/opamroot zarith`

but if I manually clone lem (https://github.com/rems-project/lem.git), everything works fine:

$ ~/cheri/cheribuild/cheribuild.py lem
Will execute the following 1 targets:
   lem
/usr/bin/opam --version
cd /home/nwf/cheri/lem && env GIT_TEMPLATE_DIR= OPAMROOT=/home/nwf/cheri/output/sdk/opamroot OPAM_USER_PATH_RO=/usr/bin /usr/bin/opam switch --root=/home/nwf/cheri/output/sdk/opamroot sail
# Run eval $(opam env) to update the current shell environment
/usr/lib/ocaml/zarith
/usr/lib/ocaml
cd /home/nwf/cheri/lem && git fetch
Skipping update: Current HEAD is up-to-date or ahead of upstream.
Warning: lem does not support out-of-source builds, using git clean to remove build artifacts.
cd /home/nwf/cheri/lem && git clean -dfx '--exclude=.*'
Configuring lem (-native) ...
Building lem (-native) ...
Installing lem (-native) ...
cd /home/nwf/cheri/lem && env GIT_TEMPLATE_DIR= OPAMROOT=/home/nwf/cheri/output/sdk/opamroot OPAM_USER_PATH_RO=/usr/bin sh -e -c 'eval `opam config env`
opam install -y .
'
lem is now pinned to git+file:///home/nwf/cheri/lem#master (version 2020-06-03)

I'm not sure why cheribuild concludes that zarith is the problem in the first iteration. While I have some cheribuild changes in place, I don't think any of them are relevant here.

nwf avatar Nov 02 '21 22:11 nwf

Dependency checking happens before cloning; check_system_dependencies ends up calling run_in_ocaml_env for each needed_ocaml_packages entry, which in turn tries to run all commands in the project's source_dir. The right fix is probably for check_system_dependencies to pass a flag saying not to do that, as you do still want that behaviour for all the actual build steps.

jrtc27 avatar Nov 02 '21 22:11 jrtc27

(Not something I'll be fixing immediately, but hopefully that's enough of a pointer if you feel like sending a patch... :))

jrtc27 avatar Nov 02 '21 22:11 jrtc27