From 151028f455a486ea80505b510bd07417f2cdcadd Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Fri, 22 Nov 2024 03:51:40 +0000 Subject: [PATCH] freebsd: Add support for aarch64 Add a new `aarch64-freebsd` double and example system, then fix include and libc to work. This is enough to build packages like `hello`, either static or dynamic. This is useful for testing nix FreeBSD on a Raspberry Pi. --- lib/systems/doubles.nix | 2 +- lib/systems/examples.nix | 5 +++++ pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix | 3 +++ pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index f60c6a8addef21..a753c835c81070 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -13,7 +13,7 @@ let "x86_64-darwin" "i686-darwin" "aarch64-darwin" "armv7a-darwin" # FreeBSD - "i686-freebsd" "x86_64-freebsd" + "i686-freebsd" "x86_64-freebsd" "aarch64-freebsd" # Genode "aarch64-genode" "i686-genode" "x86_64-genode" diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 20f96f0849d168..441f89ba100ba5 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -334,6 +334,11 @@ rec { # BSDs + aarch64-freebsd = { + config = "aarch64-unknown-freebsd"; + useLLVM = true; + }; + x86_64-freebsd = { config = "x86_64-unknown-freebsd"; useLLVM = true; diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix index a7ceb0cdf384fb..27ef73554e4811 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix @@ -1,4 +1,5 @@ { + stdenv, lib, mkDerivation, buildPackages, @@ -14,6 +15,8 @@ mkDerivation { "contrib/libc-vis" "etc/mtree/BSD.include.dist" "sys" + ] ++ lib.optionals stdenv.isAarch64 [ + "lib/msun/arm" ]; extraNativeBuildInputs = [ diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix index 7ff10d065785b8..eb34e96a4f89bf 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix @@ -106,6 +106,8 @@ mkDerivation { "include/paths.h" "lib/libdl" + ] ++ lib.optionals stdenv.hostPlatform.isAarch64 [ + "contrib/arm-optimized-routines" ]; postPatch = ''