diff options
Diffstat (limited to 'lib/systems/default.nix')
-rw-r--r-- | lib/systems/default.nix | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/lib/systems/default.nix b/lib/systems/default.nix index c929781dd8f..70ec98b03c1 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -7,6 +7,7 @@ rec { inspect = import ./inspect.nix { inherit lib; }; platforms = import ./platforms.nix { inherit lib; }; examples = import ./examples.nix { inherit lib; }; + architectures = import ./architectures.nix { inherit lib; }; # Elaborate a `localSystem` or `crossSystem` so that it contains everything # necessary. @@ -23,8 +24,6 @@ rec { # Either of these can be losslessly-extracted from `parsed` iff parsing succeeds. system = parse.doubleFromSystem final.parsed; config = parse.tripleFromSystem final.parsed; - # Just a guess, based on `system` - platform = platforms.selectBySystem final.system; # Determine whether we are compatible with the provided CPU isCompatible = platform: parse.isCompatible final.parsed.cpu platform.parsed.cpu; # Derived meta-data @@ -42,6 +41,19 @@ rec { 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 + # choose the C compiler, runtime library, C++ standard library, etc. in + # this way, nice and orthogonally, and deprecate `useLLVM`. But due to + # the monolithic GCC build we cannot actually make those choices + # independently, so we are just doing `linker` and keeping `useLLVM` for + # now. + linker = + /**/ if final.useLLVM or false then "lld" + else if final.isDarwin then "cctools" + # "bfd" and "gold" both come from GNU binutils. The existance of Gold + # is why we use the more obscure "bfd" and not "binutils" for this + # choice. + else "bfd"; extensions = { sharedLibrary = /**/ if final.isDarwin then ".dylib" @@ -76,13 +88,25 @@ rec { # uname -r release = null; }; + isStatic = final.isWasm || final.isRedox; + + # Just a guess, based on `system` + inherit + ({ + linux-kernel = args.linux-kernel or {}; + gcc = args.gcc or {}; + rustc = args.rust or {}; + } // platforms.select final) + linux-kernel gcc rustc; - kernelArch = + linuxArch = if final.isAarch32 then "arm" else if final.isAarch64 then "arm64" - else if final.isx86_32 then "x86" - else if final.isx86_64 then "ia64" + else if final.isx86_32 then "i386" + else if final.isx86_64 then "x86_64" else if final.isMips then "mips" + else if final.isPower then "powerpc" + else if final.isRiscV then "riscv" else final.parsed.cpu.name; qemuArch = @@ -96,6 +120,24 @@ rec { powerpc64le = "ppc64le"; }.${final.parsed.cpu.name} or final.parsed.cpu.name; + darwinArch = { + armv7a = "armv7"; + aarch64 = "arm64"; + }.${final.parsed.cpu.name} or final.parsed.cpu.name; + + darwinPlatform = + if final.isMacOS then "macos" + else if final.isiOS then "ios" + else null; + # The canonical name for this attribute is darwinSdkVersion, but some + # platforms define the old name "sdkVer". + darwinSdkVersion = final.sdkVer or (if final.isAarch64 then "11.0" else "10.12"); + darwinMinVersion = final.darwinSdkVersion; + darwinMinVersionVariable = + if final.isMacOS then "MACOSX_DEPLOYMENT_TARGET" + else if final.isiOS then "IPHONEOS_DEPLOYMENT_TARGET" + else null; + emulator = pkgs: let qemu-user = pkgs.qemu.override { smartcardSupport = false; @@ -122,9 +164,12 @@ rec { then "${qemu-user}/bin/qemu-${final.qemuArch}" else if final.isWasi then "${pkgs.wasmtime}/bin/wasmtime" + else if final.isMmix + then "${pkgs.mmixware}/bin/mmix" else throw "Don't know how to run ${final.config} executables."; } // mapAttrs (n: v: v final.parsed) inspect.predicates + // mapAttrs (n: v: v final.gcc.arch or "default") architectures.predicates // args; in assert final.useAndroidPrebuilt -> final.isAndroid; assert lib.foldl |