Code Monkey home page Code Monkey logo

borealis's Introduction

borealis

ISA simulation and development toolchain

CI

Build Requirements

OR

Testing

earthly +test to run all tests.

Docker/Earthly

The included Earthfile builds, tests, and generates documentation for borealis. It is used by the GitHub Actions workflow for CI. For that reason, borealis should always be x86_64 compatible, while aarch64 (and non-Linux) support will be provided on a best-effort basis.

Usage

To build:

$ earthly +build

To run both unit and the end-2-end test:

$ earthly +test

Workspace Packages

borealis

Sail frontend to GenSim. Depends on sail crate to parse Sail definition, which is then compiled to GenC.

sail

Rust interface for the the Sail compiler and AST written in OCaml.

common

Rust does not support cyclic dependencies among crates so this crate contains types and logic shared by multiple other crates in the workspace.

Common Issues

Linker Errors

Typically Rust programs benefit from a high degree of portability, unfortunately by depending on the Sail library borealis has a more complex linking situation. The sail crate contains an OCaml library called wrapper. This is built with the build.rs script in sail. wrapper depends on the Opam sail package, which depends on conf-gmp (a virtual Opam package relying on the system GMP library installation).

On several systems we have experienced linker errors relating to GMP as conf-gmp does not add the correct paths to the shared libary search paths. Building GMP statically and manually exporting the path to the object file does work, however we elected to add the gmp Opam package as a dependency to the wrapper library, as even though sail Opam package does not use it in any way, it sets the correct paths used by OCaml allowing conf-gmp to build successfully.

Additionally, on macOS, -lgmp must be supplied as well as the path to the Homebrew /lib folder, which is done in the build.rs inside conditional compilation flags.

Wrong OCaml Version

Currently only version 4.14.0 is supported (or whichever version is in the Dockerfile). Until the ocaml-rs crate is updated to depend on the latest ocaml-boxroot-sys, building with OCaml 5 will result in several warnings and an error vendor/boxroot/boxroot.c:821:7: error: too few arguments to function ‘action’ from ocaml-boxroot-sys.

Missing Opam/Dune Binaries

If the opam or dune binary is not in PATH then you may experience the following errors in ocaml-rs or sail respectively:

error: failed to run custom build command for `ocaml-boxroot-sys v0.2.0`

Caused by:
  process didn't exit successfully: `/Users/ferdiamckeogh/.cargo/target/release/build/ocaml-boxroot-sys-88e415fa3d2fbfcd/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=vendor/boxroot/boxroot.c
  cargo:rerun-if-changed=vendor/boxroot/boxroot.h
  cargo:rerun-if-env-changed=OCAMLOPT
  cargo:rerun-if-env-changed=OCAML_WHERE_PATH

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /Users/ferdiamckeogh/.cargo/registry/src/github.com-1ecc6299db9ec823/ocaml-boxroot-sys-0.2.0/build.rs:108:26
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `ocaml-sys v0.22.3`

Caused by:
  process didn't exit successfully: `/Users/ferdiamckeogh/.cargo/target/release/build/ocaml-sys-de095a00ef3bb896/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=OCAMLOPT
  cargo:rerun-if-env-changed=OCAML_VERSION
  cargo:rerun-if-env-changed=OCAML_WHERE_PATH

  --- stderr
  thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /Users/ferdiamckeogh/.cargo/registry/src/github.com-1ecc6299db9ec823/ocaml-sys-0.22.3/build.rs:143:11
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to run custom build command for `sail v0.1.1 (/Users/ferdiamckeogh/Downloads/borealis/sail)`

Caused by:
  process didn't exit successfully: `/Users/ferdiamckeogh/.cargo/target/release/build/sail-c7644b8fa718363b/build-script-build` (exit status: 101)
  --- stderr
  The application panicked (crashed).
  Message:  Failed to execute dune, is it installed and in the PATH?
  Location: sail/build.rs:77

  Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
  Run with RUST_BACKTRACE=full to include source snippets.

To fix, ensure the opam and dune binaries are installed and made available to the environment in which you are compiling. For example, when using rust-analyzer in VSCode, you may want to launch VSCode from the command line prefixed with eval (opam env), as opening it as an application may not result in the PATH being updated.

borealis's People

Contributors

fmckeogh avatar tspink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

borealis's Issues

Leaking OCaml allocations

Currently valgrind appears to be reporting that all OCaml allocations are being leaked; needs investigation.

Progress bar from Sail

enable sail progress bar during parsing/type checking

also see if we can skip type checking

Convert OCaml exception backtraces and sail errors to nested rust errors

Error: 
   0: Error returned by Sail wrapper function
   1: Sail error: Type(Root(Root(0x140540050)), "No val spec found for not_bool\n")

Location:
   sail/examples/sigsegv.rs:16

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

should be

Error: 
   0: Error returned by Sail wrapper function
   1: Sail error
   2: Type error
   3: No val spec found for `not_bool`

Location:
   sail/examples/sigsegv.rs:16

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Format/initial instruction execute behaviour fixes

This location in code is where we adapt GenC's instruction format structure to the call to the instructions' xxx_decode function.

  • Constant ranges' values need to be assigned to a local variable (IE. Rd: [0,1,1,0,1])
  • Split ranges with constants inside need to be assigned to a local variable.

Fix bitvector ordering

for the fixed bits JIB type, the boolean refers to the ordering of the bits. This should be formalised into LittleEndian or BigEndian, and then standardised and removed in BOOM types.

Code snippet for merging constant segments

Not currently needed, but shame to throw it all away

// merge adjacent constant segments
        let groups = self.0.iter().cloned().group_by(|segment| {
            if let SegmentContent::Constant(_) = segment.content {
                true
            } else {
                false
            }
        });

        let mut segments = groups
            .into_iter()
            .map(|(constant, segments)| {
                if false {
                    let (value, length) = segments
                        .fold((0b0, 0usize), |(acc_value, acc_length), segment| {
                            let SegmentContent::Constant(val) = segment.content else { panic!("unexpected variable segment") };

                            println!();
                            println!("{:b} {}", acc_value, acc_length);
                            println!("{:b} {}", val, segment.length);

                            let new_val = acc_value << segment.length | val;
                            println!("{:b}", new_val);

                            (new_val, acc_length + segment.length)
                        });

                    let segment = Segment {
                        content: SegmentContent::Constant(value),
                        length,
                    };

                    vec![segment].into_iter()
                } else {
                    segments.collect::<Vec<_>>().into_iter()
                }
            })
            .flatten();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.