diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2022-10-31 08:35:51 -0400 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2022-11-04 16:49:28 -0400 |
commit | 66aa02f190d17b4e7c4bf0f7f891984647a38234 (patch) | |
tree | c18caf98baa04b8cb57a6287847eae1789a872a5 /lib/systems | |
parent | f172d86a4e1bd84e6d2f4de3bceba36f58095484 (diff) |
lib/systems: Support FreeBSD
A tricky thing about FreeBSD is that there is no stable ABI across versions. That means that putting in the version as part of the config string is paramount. We have a parsed represenation that separates name versus version to accomplish this. We include FreeBSD versions 12 and 13 to demonstrate how it works.
Diffstat (limited to 'lib/systems')
-rw-r--r-- | lib/systems/default.nix | 3 | ||||
-rw-r--r-- | lib/systems/doubles.nix | 2 | ||||
-rw-r--r-- | lib/systems/examples.nix | 5 | ||||
-rw-r--r-- | lib/systems/inspect.nix | 2 | ||||
-rw-r--r-- | lib/systems/parse.nix | 15 |
5 files changed, 21 insertions, 6 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 233174d40831c..24f90b4565eff 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -47,9 +47,10 @@ rec { else if final.isUClibc then "uclibc" else if final.isAndroid then "bionic" else if final.isLinux /* default */ then "glibc" + else if final.isFreeBSD then "fblibc" + else if final.isNetBSD then "nblibc" else if final.isAvr then "avrlibc" else if final.isNone then "newlib" - else if final.isNetBSD then "nblibc" # TODO(@Ericson2314) think more about other operating systems else "native/impure"; # Choose what linker we wish to use by default. Someday we might also diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index 709b67607f7b4..23a44d02e85e4 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-freebsd13" "x86_64-freebsd13" # Genode "aarch64-genode" "i686-genode" "x86_64-genode" diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 61a67072a8516..de5adad3ca52c 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -303,6 +303,11 @@ rec { # BSDs + x86_64-freebsd = { + config = "x86_64-unknown-freebsd13"; + useLLVM = true; + }; + x86_64-netbsd = { config = "x86_64-unknown-netbsd"; }; diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index ee213438e0485..4e0bb8e672e9a 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -59,7 +59,7 @@ rec { isiOS = { kernel = kernels.ios; }; isLinux = { kernel = kernels.linux; }; isSunOS = { kernel = kernels.solaris; }; - isFreeBSD = { kernel = kernels.freebsd; }; + isFreeBSD = { kernel = { name = "freebsd"; }; }; isNetBSD = { kernel = kernels.netbsd; }; isOpenBSD = { kernel = kernels.openbsd; }; isWindows = { kernel = kernels.windows; }; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index ac450534fe1e8..d8ba251503a63 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -290,7 +290,11 @@ rec { # the normalized name for macOS. macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; }; ios = { execFormat = macho; families = { inherit darwin; }; }; - freebsd = { execFormat = elf; families = { inherit bsd; }; }; + # A tricky thing about FreeBSD is that there is no stable ABI across + # versions. That means that putting in the version as part of the + # config string is paramount. + freebsd12 = { execFormat = elf; families = { inherit bsd; }; name = "freebsd"; version = 12; }; + freebsd13 = { execFormat = elf; families = { inherit bsd; }; name = "freebsd"; version = 13; }; linux = { execFormat = elf; families = { }; }; netbsd = { execFormat = elf; families = { inherit bsd; }; }; none = { execFormat = unknown; families = { }; }; @@ -431,6 +435,8 @@ rec { then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "redox"; } else if (elemAt l 2 == "mmixware") then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "mmixware"; } + else if hasPrefix "freebsd" (elemAt l 2) + then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; } else if hasPrefix "netbsd" (elemAt l 2) then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; } else if (elem (elemAt l 2) ["eabi" "eabihf" "elf"]) @@ -485,10 +491,13 @@ rec { mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s)); + kernelName = kernel: + kernel.name + toString (kernel.version or ""); + doubleFromSystem = { cpu, kernel, abi, ... }: /**/ if abi == abis.cygnus then "${cpu.name}-cygwin" else if kernel.families ? darwin then "${cpu.name}-darwin" - else "${cpu.name}-${kernel.name}"; + else "${cpu.name}-${kernelName kernel}"; tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let optExecFormat = @@ -496,7 +505,7 @@ rec { gnuNetBSDDefaultExecFormat cpu != kernel.execFormat) kernel.execFormat.name; optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}"; - in "${cpu.name}-${vendor.name}-${kernel.name}${optExecFormat}${optAbi}"; + in "${cpu.name}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}"; ################################################################################ |