diff --git a/.cirrus.yml b/.cirrus.yml index 4a5caa05..414da565 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -26,4 +26,4 @@ freebsd_task: - opam install -t ocaml-solo5 --deps-only build_script: opam reinstall -t ocaml-solo5 test_script: - - MODE=hvt opam exec -- dune build --root test + - MODE=hvt opam exec -- dune build --root example diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3fad913a..d7a39504 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,30 +5,8 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - ocaml-version: [4.13.1] - mode: - - name: hvt - exec: false - - name: spt - exec: true - - name: virtio - exec: false - - name: muen - exec: false - - name: xen - exec: false - include: - - operating-system: ubuntu-latest - ocaml-version: 4.13.0 - mode: - name: spt - exec: true - - operating-system: ubuntu-latest - ocaml-version: 4.12.1 - mode: - name: spt - exec: true - name: ${{ matrix.mode.name }} / ${{ matrix.ocaml-version }} + ocaml-version: [4.12.1,4.13.1,4.14.1] + name: OCaml ${{ matrix.ocaml-version }} runs-on: ${{ matrix.operating-system }} steps: - uses: actions/checkout@v2 @@ -37,12 +15,19 @@ jobs: ocaml-compiler: ${{ matrix.ocaml-version }} opam-local-packages: | !ocaml-solo5-cross-aarch64.opam - - name: Pinning package + - name: Pin package run: opam pin add -n -t -y ocaml-solo5 . - name: Install ocaml-solo5 and dune run: opam depext -iyt ocaml-solo5 conf-libseccomp dune - - name: Compiling example project - run: MODE=${{ matrix.mode.name }} opam exec -- dune build --root test - - name: Running example project - if: ${{ matrix.mode.exec }} - run: opam exec -- solo5-${{ matrix.mode.name }} test/_build/solo5/main.exe || [ $? -eq 1 ] + - name: Compile example with hvt + run: MODE=hvt opam exec -- dune build --root example + - name: Compile example with spt + run: MODE=spt opam exec -- dune build --root example + - name: Run example with spt + run: opam exec -- solo5-spt example/_build/solo5/main.exe + - name: Compile example with virtio + run: MODE=virtio opam exec -- dune build --root example + - name: Compile example with muen + run: MODE=muen opam exec -- dune build --root example + - name: Compile example with xen + run: MODE=xen opam exec -- dune build --root example diff --git a/README.md b/README.md index 04e2536b..c3b614b5 100644 --- a/README.md +++ b/README.md @@ -62,16 +62,16 @@ ocamlfind or dune: #### Example -The `example` describes the minimal structure needed to build an -ocaml-solo5 executable with dune, linked with the hvt bindings. It -requires an application manifest and a startup file to initialize the libc. +The `example` describes the minimal structure needed to build an ocaml-solo5 +executable with dune, linked with the hvt bindings by default. It requires an +application manifest and a startup file to initialize the libc. Build: `dune build -x solo5` -Run: `solo5-hvt _build/default.solo5/main.exe` +Run: `solo5-hvt _build/solo5/main.exe` ## Supported compiler versions -Tested against OCaml 4.12.1 through 4.13.0. Other versions may require +Tested against OCaml 4.12.1 through 4.14.1. Other versions may require changing `configure.sh`. ## Porting to a different (uni)kernel base layer diff --git a/example/dune b/example/dune index 50c8d6ca..f6b3eb8b 100644 --- a/example/dune +++ b/example/dune @@ -1,6 +1,6 @@ (executable (name main) - (link_flags -cclib "-z solo5-abi=hvt") + (link_flags :standard -cclib "-z solo5-abi=%{env:MODE=hvt}") (foreign_stubs (language c) (names startup manifest))) @@ -11,9 +11,16 @@ (action (run solo5-elftool gen-manifest manifest.json manifest.c))) +(rule + (alias runtest) + (enabled_if + (= %{context_name} solo5)) + (action + (run "solo5-%{env:MODE=hvt}" "%{dep:main.exe}"))) + (alias (name default) (enabled_if - (= %{context_name} default.solo5)) + (= %{context_name} solo5)) (deps (alias_rec all))) diff --git a/example/dune-project b/example/dune-project index c2e46604..45acd3f0 100644 --- a/example/dune-project +++ b/example/dune-project @@ -1 +1 @@ -(lang dune 2.8) +(lang dune 2.7) diff --git a/example/dune-workspace b/example/dune-workspace new file mode 100644 index 00000000..f03488a3 --- /dev/null +++ b/example/dune-workspace @@ -0,0 +1,9 @@ +(lang dune 2.0) + +(context (default)) + +(context + (default + (name solo5) + (toolchain solo5) + (host default))) diff --git a/example/main.ml b/example/main.ml index 4585b6cc..ef16b82d 100644 --- a/example/main.ml +++ b/example/main.ml @@ -1 +1 @@ -let () = Printf.printf "\nHello from solo5!\n\n" +let () = Printf.printf "Hello from OCaml on Solo5!\n%!";; diff --git a/example/manifest.json b/example/manifest.json index 4caa9a5f..32a1149a 100644 --- a/example/manifest.json +++ b/example/manifest.json @@ -1,5 +1,5 @@ { - "type": "solo5.manifest", - "version": 1, - "devices": [] + "type": "solo5.manifest", + "version": 1, + "devices": [] } \ No newline at end of file diff --git a/example/startup.c b/example/startup.c index cde67ab7..263eddb3 100644 --- a/example/startup.c +++ b/example/startup.c @@ -10,4 +10,5 @@ void _nolibc_init(uintptr_t heap_start, size_t heap_size); // defined in nolibc/ int solo5_app_main(const struct solo5_start_info *si) { _nolibc_init(si->heap_start, si->heap_size); caml_startup(unused_argv); + return 0; } diff --git a/test/dune b/test/dune deleted file mode 100644 index 4476fb55..00000000 --- a/test/dune +++ /dev/null @@ -1,57 +0,0 @@ -(executable - (name main) - (link_flags - -g - -w - +A-4-41-42-44 - -bin-annot - -strict-sequence - -principal - -safe-string - -color - always - -cclib - (:include solo5_abi_flag)) - (foreign_stubs - (language c) - (names startup manifest))) - -(rule - (targets manifest.c) - (deps manifest.json) - (action - (run solo5-elftool gen-manifest manifest.json manifest.c))) - -(rule - (target mode) - (deps - (env_var MODE)) - (action - (with-stdout-to - %{target} - (bash - "if [ ! -z \"${MODE+x}\" ]; then echo -n \"$MODE\"; else echo -n \"hvt\"; fi")))) - -(rule - (target solo5_abi_flag) - (deps mode) - (action - (with-stdout-to - %{target} - (bash "echo -n \"\\\"-z solo5-abi=\" && cat mode && echo -n \\\"")))) - -(rule - (alias runtest) - (enabled_if - (= %{context_name} solo5)) - (action - (with-accepted-exit-codes - 1 - (run "solo5-%{read:mode}" "%{dep:main.exe}")))) - -(alias - (name default) - (enabled_if - (= %{context_name} solo5)) - (deps - (alias_rec all))) diff --git a/test/dune-project b/test/dune-project deleted file mode 100644 index 45acd3f0..00000000 --- a/test/dune-project +++ /dev/null @@ -1 +0,0 @@ -(lang dune 2.7) diff --git a/test/dune-workspace b/test/dune-workspace deleted file mode 100644 index c7a72855..00000000 --- a/test/dune-workspace +++ /dev/null @@ -1,9 +0,0 @@ -(lang dune 2.0) - -(context (default)) - -(context (default - (name solo5) - (toolchain solo5) - (host default) -)) diff --git a/test/main.ml b/test/main.ml deleted file mode 100644 index c1373680..00000000 --- a/test/main.ml +++ /dev/null @@ -1 +0,0 @@ -let () = Printf.printf "Hello from OCaml !\n%!";; diff --git a/test/manifest.json b/test/manifest.json deleted file mode 100644 index 32a1149a..00000000 --- a/test/manifest.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "type": "solo5.manifest", - "version": 1, - "devices": [] -} \ No newline at end of file diff --git a/test/startup.c b/test/startup.c deleted file mode 100644 index 5544c44d..00000000 --- a/test/startup.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#define CAML_NAME_SPACE -#include -#include -#include -#include - -static char *unused_argv[] = { "mirage", NULL }; - -void _nolibc_init(uintptr_t heap_start, size_t heap_size); // defined in nolibc/sysdeps_solo5.c - -int solo5_app_main(const struct solo5_start_info *si) { - _nolibc_init(si->heap_start, si->heap_size); - caml_startup(unused_argv); -}