-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45d2f79
commit 2449c24
Showing
110 changed files
with
1,435 additions
and
1,472 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,13 @@ | ||
[target.'cfg(debug_assertions)'] | ||
runner = 'sudo -E' | ||
rustflags = [ | ||
"-C", "linker=clang", | ||
"-C", "link-arg=-fuse-ld=lld", | ||
"-C", "link-arg=--ld-path=/home/dnoland/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld/ld.lld", | ||
"-C", "opt-level=0", | ||
"-C", "lto=false", | ||
] | ||
[env] | ||
DEV_ENV = { value = "compile-env", relative = true, force = false } | ||
SYSROOT = { value = "compile-env/sysroot", relative = true, force = false } | ||
|
||
PATH = { value = "compile-env/bin", relative = true, force = true } | ||
LD_LIBRARY_PATH = { value = "compile-env/lib", relative = true, force = true } | ||
LIBCLANG_PATH = { value = "compile-env/lib", relative = true, force = true } | ||
|
||
[target.'cfg(not(debug_assertions))'] | ||
rustflags = [ | ||
"-C", "linker=clang", | ||
"-C", "link-arg=-fuse-ld=lld", | ||
"-C", "link-arg=--ld-path=/home/dnoland/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld/ld.lld", | ||
"-C", "opt-level=3", | ||
"-C", "codegen-units=1", | ||
"-C", "linker-plugin-lto", | ||
"-C", "lto=thin", | ||
"-C", "embed-bitcode=yes", | ||
# Full RELRO as a basic security measure | ||
# <https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro> | ||
"-C", "relro-level=full", | ||
# "-Z", "sanitizer=cfi", | ||
# "-Z", "sanitizer=safestack", | ||
] | ||
[build] | ||
target = [ | ||
"x86_64-unknown-linux-gnu", | ||
"x86_64-unknown-linux-musl", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Build project | ||
on: [ push, pull_request ] | ||
|
||
permissions: | ||
contents: write | ||
packages: read | ||
id-token: write | ||
jobs: | ||
build: | ||
name: build project | ||
runs-on: | ||
- lab | ||
timeout-minutes: 180 | ||
container: | ||
image: ghcr.io/githedgehog/dpdk-sys/dev-env:main-rust-pinned | ||
credentials: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: compile-env is self | ||
run: just _ci-compile-env-hack | ||
- run: just cargo build | ||
- run: just cargo build --release | ||
- run: just cargo test | ||
- run: just cargo test --release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
on: [ push, pull_request ] | ||
|
||
permissions: | ||
contents: write | ||
packages: read | ||
id-token: write | ||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
profile: [ "debug", "release" ] | ||
just_version: [ "1.36.0" ] | ||
rust_toolchain: [ "stable", "1.82.0", "nightly-2024-10-22" ] | ||
runs-on: | ||
- lab | ||
timeout-minutes: 180 | ||
steps: | ||
- name: login to ghcr.io | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: install just | ||
uses: extractions/setup-just@v2 | ||
with: | ||
just-version: ${{matrix.just_version}} | ||
- name: install rustup | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: ${{matrix.rust_toolchain}} | ||
targets: "x86_64-unknown-linux-gnu,x86_64-unknown-linux-musl" | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: refresh-compile-env | ||
run: just --yes refresh-compile-env | ||
- run: just --yes fake-nix | ||
- name: just build (glibc) | ||
run: just cargo +${{matrix.rust_toolchain}} build --profile=${{matrix.profile}} --target=x86_64-unknown-linux-gnu | ||
- name: just test (glibc) | ||
run: just cargo +${{matrix.rust_toolchain}} test --profile=${{matrix.profile}} --target=x86_64-unknown-linux-gnu | ||
- name: just build | ||
run: just cargo +${{matrix.rust_toolchain}} build --profile=${{matrix.profile}} --target=x86_64-unknown-linux-musl | ||
- name: just test | ||
run: just cargo +${{matrix.rust_toolchain}} test --profile=${{matrix.profile}} --target=x86_64-unknown-linux-musl |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
export RUSTFLAGS?=-C linker=${HOME}/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin/gcc-ld/ld.lld | ||
|
||
install-nix: | ||
sh <(curl -L https://nixos.org/nix/install) --no-daemon | ||
|
||
sysroot: | ||
echo "Building sysroot..." | ||
rm sysroot || true | ||
nix build -f default.nix 'env' --out-link sysroot | ||
echo "Built sysroot." | ||
|
||
update-channel: | ||
nix-channel --update | ||
|
||
update-flake: update-channel | ||
nix flake update | ||
|
||
build: sysroot | ||
cargo build --target=x86_64-unknown-linux-musl | ||
|
||
test: build | ||
cargo test --target=x86_64-unknown-linux-musl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Hedgehog Dataplane | ||
|
||
## Build instructions | ||
|
||
### Prerequisites | ||
|
||
- Recent linux machine of some kind required for development | ||
|
||
> [!NOTE] | ||
> I might be able to make this work on Mac if folks are interested and can help test. | ||
- Bash (you very likely have this) | ||
- [Docker](https://www.docker.com/) (install through your package manager | ||
- Cargo / Rust (install via [`rustup`](https://rustup.rs/)) | ||
- [just](https://github.com/casey/just) (install through your package manager or cargo) | ||
|
||
> [!WARNING] | ||
> System privileges required for testing! | ||
> This project requires root privileges to run the tests. | ||
> This is because the tests require access to raw network interfaces. | ||
> You can either run in docker or with `sudo`. | ||
> `sudo` happens by default when you run `cargo test`. | ||
## Step 0. Clone the repository | ||
|
||
```bash | ||
git clone [email protected]:githedgehog/dataplane.git | ||
pushd dataplane | ||
``` | ||
|
||
## Step 1. Get the sysroot | ||
|
||
In the source directory, run | ||
|
||
```bash | ||
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. | ||
```bash | ||
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 | ||
|
||
```bash | ||
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`. | ||
|
||
Additionally, you can run | ||
|
||
```bash | ||
just build | ||
``` | ||
|
||
## Step 4. Run the tests | ||
|
||
To run the test suite under glibc | ||
|
||
```bash | ||
cargo test --target x86_64-unknown-linux-gnu | ||
``` | ||
|
||
To run the test suite under musl | ||
|
||
```bash | ||
cargo test --target x86_64-unknown-linux-musl | ||
``` |
Oops, something went wrong.