Skip to content

Commit

Permalink
nix: try to make armv8.2-a / cortex-a55 optimised builds if target is…
Browse files Browse the repository at this point in the history
… aarch64

Signed-off-by: strawberry <[email protected]>
  • Loading branch information
girlbossceo committed Jul 14, 2024
1 parent df28359 commit 649e9da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions nix/pkgs/main/cross-compilation-env.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ lib.optionalAttrs stdenv.hostPlatform.isStatic {
++ lib.optionals
stdenv.targetPlatform.isx86_64
[ "-C" "target-cpu=x86-64-v2" ]
++ lib.optionals
stdenv.targetPlatform.isAarch64
[ "-C" "target-cpu=cortex-a55" ] # cortex-a55 == ARMv8.2-a
# This disables PIE for static builds, which isn't great in terms
# of security. Unfortunately, my hand is forced because nixpkgs'
# `libstdc++.a` is built without `-fPIE`, which precludes us from
Expand Down
10 changes: 9 additions & 1 deletion nix/pkgs/main/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ buildDepsOnlyEnv =
"-DHAVE_SSE=1"
"-DHAVE_SSE42=1"
]
else if stdenv.targetPlatform.isAarch64
then lib.subtractLists [ "-DPORTABLE=1" ] old.cmakeFlags
++ lib.optionals stdenv.targetPlatform.isAarch64 [
# cortex-a55 == ARMv8.2-a
"-DPORTABLE=armv8.2-a"
]
else old.cmakeFlags;
});
in
Expand Down Expand Up @@ -116,7 +122,9 @@ buildPackageEnv = {
+ lib.optionalString (enableLiburing && stdenv.hostPlatform.isStatic)
" -L${lib.getLib liburing}/lib -luring"
+ lib.optionalString stdenv.targetPlatform.isx86_64
" -Ctarget-cpu=x86-64-v2";
" -Ctarget-cpu=x86-64-v2"
+ lib.optionalString stdenv.targetPlatform.isAarch64
" -Ctarget-cpu=cortex-a55"; # cortex-a55 == ARMv8.2-a
};


Expand Down

0 comments on commit 649e9da

Please sign in to comment.