Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nix-shell environment for building spdk on arm #72

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/pr-code-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ on:
types: ['opened', 'edited', 'reopened', 'synchronize']
jobs:
rust-lint:
runs-on: ubuntu-latest
strategy:
matrix:
os: [github-arm64-2c-8gb, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
Expand Down
16 changes: 6 additions & 10 deletions nix/pkgs/libspdk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
, libtool
, liburing
, libuuid
, llvmPackages
, meson
, nasm
, ncurses
Expand Down Expand Up @@ -69,6 +68,8 @@ let
else
"--without-fio";

# Only set crossPrefix if we're actually cross-compiling
# (which we aren't, but let's keep the logic).
crossPrefix =
if targetPlatform.config != buildPlatform.config then
"--crossPrefix=${targetPlatform.config}"
Expand All @@ -90,13 +91,13 @@ let
version = "24.05-${lib.substring 0 7 rev}";
name = "${pname}-${version}";
};

drvAttrs = rec {
pname = spdk.pname;
version = spdk.version;

src = [
(fetchFromGitHub {
# Note that this would only rebuild if the first 7 chars differ, but in practice should be fine
name = spdk.name;
owner = "openebs";
repo = "spdk";
Expand All @@ -113,16 +114,13 @@ let
cmake
gcc
help2man
llvmPackages.bintools
llvmPackages.clang
llvmPackages.libclang
meson
ninja
pkg-config
procps
udev
utillinux
(python3.withPackages (ps: with ps; [ pyelftools ]))
pkgs.python3Packages.pyelftools
] ++ extraBuildInputs;

buildInputs = [
Expand Down Expand Up @@ -158,9 +156,7 @@ let
enableParallelBuilding = true;
hardeningDisable = [ "all" ];

#
# Phases.
#
# Our phases
prePatch = ''
pushd ..
chmod -R u+w build_scripts
Expand All @@ -181,4 +177,4 @@ let
'';
};
in
llvmPackages.stdenv.mkDerivation drvAttrs
pkgs.stdenv.mkDerivation drvAttrs
13 changes: 11 additions & 2 deletions nix/shell/spdk.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ let
echo "FIO path : $FIO"
'';

# Determine the system architecture
system = builtins.currentSystem;

# Define CFLAGS based on the architecture
cflagsValue =
if system == "aarch64-linux"
then "-march=armv8-a+crypto"
else "-msse4";

# spdk-path argument overrides spdk argument.
spdkCfg = if spdk-path != null then "none" else spdk;

Expand Down Expand Up @@ -63,14 +72,14 @@ let
};

# Do not use Nix libspdk. User must provide SPDK.
# Build environment for development libspdk packahe is provided.
# Build environment for development libspdk package is provided.
none = {
drv = null;

buildInputs = with pkgs; libspdk-dev.nativeBuildInputs ++ libspdk-dev.buildInputs;

shellEnv = {
CFLAGS = "-msse4";
CFLAGS = cflagsValue;
SPDK_RS_BUILD_USE_LOGS = "yes"; # Tells spdk-rs build.rs script to rerun when build_logs dir is updated.
};

Expand Down
Loading