Skip to content

Commit 57c4a43

Browse files
committed
fix(arm): improve ARM build process and compatibility
spdk-rs used to not build on arm solely due to the nix environment setup. There were issues with compiler flags (-msse4 is x86 only) and some base environment configuration. By fixing the environment we were able to get a successful build of spdk-rs. On top of these fixes we are able to test them in the github action runner which runs nix-shell. This in turn compiles spdk from source (openebs/spdk). Signed-off-by: Max Newcomer <maxwnewcomer@gmail.com>
1 parent 93d0d20 commit 57c4a43

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

.github/workflows/pr-code-lint.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ on:
55
types: ['opened', 'edited', 'reopened', 'synchronize']
66
jobs:
77
rust-lint:
8-
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
os: [github-arm64-2c-8gb, ubuntu-latest]
11+
runs-on: ${{ matrix.os }}
912
steps:
1013
- uses: actions/checkout@v4
1114
with:

nix/pkgs/libspdk/default.nix

+6-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
, libtool
3232
, liburing
3333
, libuuid
34-
, llvmPackages
3534
, meson
3635
, nasm
3736
, ncurses
@@ -69,6 +68,8 @@ let
6968
else
7069
"--without-fio";
7170

71+
# Only set crossPrefix if we're actually cross-compiling
72+
# (which we aren't, but let's keep the logic).
7273
crossPrefix =
7374
if targetPlatform.config != buildPlatform.config then
7475
"--crossPrefix=${targetPlatform.config}"
@@ -90,13 +91,13 @@ let
9091
version = "24.05-${lib.substring 0 7 rev}";
9192
name = "${pname}-${version}";
9293
};
94+
9395
drvAttrs = rec {
9496
pname = spdk.pname;
9597
version = spdk.version;
9698

9799
src = [
98100
(fetchFromGitHub {
99-
# Note that this would only rebuild if the first 7 chars differ, but in practice should be fine
100101
name = spdk.name;
101102
owner = "openebs";
102103
repo = "spdk";
@@ -113,16 +114,13 @@ let
113114
cmake
114115
gcc
115116
help2man
116-
llvmPackages.bintools
117-
llvmPackages.clang
118-
llvmPackages.libclang
119117
meson
120118
ninja
121119
pkg-config
122120
procps
123121
udev
124122
utillinux
125-
(python3.withPackages (ps: with ps; [ pyelftools ]))
123+
pkgs.python3Packages.pyelftools
126124
] ++ extraBuildInputs;
127125

128126
buildInputs = [
@@ -158,9 +156,7 @@ let
158156
enableParallelBuilding = true;
159157
hardeningDisable = [ "all" ];
160158

161-
#
162-
# Phases.
163-
#
159+
# Our phases
164160
prePatch = ''
165161
pushd ..
166162
chmod -R u+w build_scripts
@@ -181,4 +177,4 @@ let
181177
'';
182178
};
183179
in
184-
llvmPackages.stdenv.mkDerivation drvAttrs
180+
pkgs.stdenv.mkDerivation drvAttrs

nix/shell/spdk.nix

+11-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ let
1818
echo "FIO path : $FIO"
1919
'';
2020

21+
# Determine the system architecture
22+
system = builtins.currentSystem;
23+
24+
# Define CFLAGS based on the architecture
25+
cflagsValue =
26+
if system == "aarch64-linux"
27+
then "-march=armv8-a+crypto"
28+
else "-msse4";
29+
2130
# spdk-path argument overrides spdk argument.
2231
spdkCfg = if spdk-path != null then "none" else spdk;
2332

@@ -63,14 +72,14 @@ let
6372
};
6473

6574
# Do not use Nix libspdk. User must provide SPDK.
66-
# Build environment for development libspdk packahe is provided.
75+
# Build environment for development libspdk package is provided.
6776
none = {
6877
drv = null;
6978

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

7281
shellEnv = {
73-
CFLAGS = "-msse4";
82+
CFLAGS = cflagsValue;
7483
SPDK_RS_BUILD_USE_LOGS = "yes"; # Tells spdk-rs build.rs script to rerun when build_logs dir is updated.
7584
};
7685

0 commit comments

Comments
 (0)