Skip to content

githedgehog/dataplane

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7372a19 · Oct 28, 2024
Oct 28, 2024
Oct 28, 2024
Oct 26, 2024
Oct 28, 2024
Oct 28, 2024
Oct 23, 2024
Oct 26, 2024
Oct 26, 2024
Oct 23, 2024
Oct 23, 2024
Oct 23, 2024
Oct 25, 2024
Oct 24, 2024
Oct 28, 2024
Oct 26, 2024
Oct 26, 2024
Oct 26, 2024
Oct 24, 2024
Oct 23, 2024
Oct 25, 2024
Oct 25, 2024
Oct 21, 2024
Oct 25, 2024
Oct 28, 2024
Oct 23, 2024

Repository files navigation

Hedgehog Dataplane

Build instructions

Prerequisites

  • Recent x86_64 linux machine of some kind required for development

  • Bash (you very likely have this)

  • Docker (install through your package manager

  • Cargo / Rust (install via rustup)

    • ⚠️ You need a recent version of rust (1.82.0 or better) to build the project.

      rustup update
    • ⚠️ You need to install both the glibc and musl targets to use the default builds.

      rustup target add x86_64-unknown-linux-gnu
      rustup target add x86_64-unknown-linux-musl
  • just (install through your package manager or cargo)

Step 0. Clone the repository

git clone git@github.com:githedgehog/dataplane.git
pushd dataplane

Step 1. Get the sysroot

In the source directory, run

just refresh-compile-env

You should now have a directory called compile-env which contains the tools needed to build dpdk-sys such as clang and lld. You should also have ./compile-env/sysroot which contains the libraries that dpdk-sys needs to link against. Both x86_64-unknown-linux-gnu and x86_64-unknown-linux-musl targets are currently supported.

Step 3. Fake nix

The sysroot is currently built using nix, but you don't need nix to build the project. The idea is to symlink /nix to ./compile-env/nix so that the build scripts can find the libraries they need. This is a compromise between requiring the developer to understand nix (which can be non-trivial) and requiring the developer to have a bunch of libraries installed on their system.

Warning

This is a hack! It works fine but the plan won't work if you already have /nix. If you already have /nix talk to me, and we will make it work. It should be pretty easy.

just fake-nix

Note

If you move your project directory, you will need to run just fake-nix refake to update the symlinks.

Step 3. Build the project

At this point you should be able to run

just cargo build

You should now have statically linked ELF executables in target/x86_64-unknown-linux-gnu/debug/scratch and target/x86_64-unknown-linux-musl/debug/scratch.

You can build in release mode with

just cargo build --profile=release

at which point the executables will be in target/x86_64-unknown-linux-gnu/release/scratch and target/x86_64-unknown-linux-musl/release/scratch.

Step 4. Run the tests (debug mode)

To run the test suite you can run

just cargo test

By default, this will run both the musl and glibc tests. To run the test suite under glibc or musl specifically, try

just cargo test --target x86_64-unknown-linux-gnu

or

just cargo test --target x86_64-unknown-linux-musl

To run the test suite under release mode

just cargo test --profile=release

Note

Why the just in just cargo build ...?

just is computing the correct RUSTFLAGS for us depending on the profile. After that it just calls cargo build. Normally we would include those kinds of setting in Cargo.toml but cargo can not currently express all the RUSTFLAGS we are using (thus the just wrapper).