From 2b02a18ef7996f772355ca83227af99b80c46685 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 +++++ lib/tests/systems.nix | 2 +- pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix | 3 +++ pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix | 3 +++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index f60c6a8addef..a753c835c810 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 20f96f0849d1..441f89ba100b 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/lib/tests/systems.nix b/lib/tests/systems.nix index 3a8054ef4bc8..1b50ea223674 100644 --- a/lib/tests/systems.nix +++ b/lib/tests/systems.nix @@ -52,7 +52,7 @@ lib.runTests ( testcygwin = mseteq cygwin [ "i686-cygwin" "x86_64-cygwin" ]; testdarwin = mseteq darwin [ "x86_64-darwin" "i686-darwin" "aarch64-darwin" "armv7a-darwin" ]; - testfreebsd = mseteq freebsd [ "i686-freebsd" "x86_64-freebsd" ]; + testfreebsd = mseteq freebsd [ "aarch64-freebsd" "i686-freebsd" "x86_64-freebsd" ]; testgenode = mseteq genode [ "aarch64-genode" "i686-genode" "x86_64-genode" ]; testredox = mseteq redox [ "x86_64-redox" ]; testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */); diff --git a/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix b/pkgs/os-specific/bsd/freebsd/pkgs/include/package.nix index a7ceb0cdf384..a4a364459daa 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" + # Used for aarch64-freebsd + "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 7ff10d065785..92aa1792a048 100644 --- a/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix +++ b/pkgs/os-specific/bsd/freebsd/pkgs/libc/package.nix @@ -106,6 +106,9 @@ mkDerivation { "include/paths.h" "lib/libdl" + + # Used for aarch64-freebsd + "contrib/arm-optimized-routines" ]; postPatch = ''