query
On this page

mkSystemFromSkeleton

lib.systems.parse.mkSystemFromSkeleton

Docs pulled from | This Revision | about 1 hour ago


This should revert the job done by config.guess from the gcc compiler.


Noogle detected

Implementation

The following is the current implementation of this function.

mkSystemFromSkeleton = { cpu
                         , # Optional, but fallback too complex for here.
                           # Inferred below instead.
                           vendor ? assert false; null
                         , kernel
                         , # Also inferred below
                           abi    ? assert false; null
                         } @ args: let
    getCpu    = name: cpuTypes.${name} or (throw "Unknown CPU type: ${name}");
    getVendor = name:  vendors.${name} or (throw "Unknown vendor: ${name}");
    getKernel = name:  kernels.${name} or (throw "Unknown kernel: ${name}");
    getAbi    = name:     abis.${name} or (throw "Unknown ABI: ${name}");

    parsed = {
      cpu = getCpu args.cpu;
      vendor =
        /**/ if args ? vendor    then getVendor args.vendor
        else if isDarwin  parsed then vendors.apple
        else if isWindows parsed then vendors.pc
        else                     vendors.unknown;
      kernel = if hasPrefix "darwin" args.kernel      then getKernel "darwin"
               else if hasPrefix "netbsd" args.kernel then getKernel "netbsd"
               else                                   getKernel (removeAbiSuffix args.kernel);
      abi =
        /**/ if args ? abi       then getAbi args.abi
        else if isLinux parsed || isWindows parsed then
          if isAarch32 parsed then
            if versionAtLeast (parsed.cpu.version or "0") "6"
            then abis.gnueabihf
            else abis.gnueabi
          # Default ppc64 BE to ELFv2
          else if isPower64 parsed && isBigEndian parsed then abis.gnuabielfv2
          else abis.gnu
        else                     abis.unknown;
    };

  in mkSystem parsed;