initial implementation of vc4 cross-compile

+94 -14
+1
lib/systems/default.nix
··· 37 else if final.isAndroid then "bionic" 38 else if final.isLinux /* default */ then "glibc" 39 else if final.isMsp430 then "newlib" 40 else if final.isAvr then "avrlibc" 41 else if final.isNetBSD then "nblibc" 42 # TODO(@Ericson2314) think more about other operating systems
··· 37 else if final.isAndroid then "bionic" 38 else if final.isLinux /* default */ then "glibc" 39 else if final.isMsp430 then "newlib" 40 + else if final.isVc4 then "newlib" 41 else if final.isAvr then "avrlibc" 42 else if final.isNetBSD then "nblibc" 43 # TODO(@Ericson2314) think more about other operating systems
+2 -1
lib/systems/doubles.nix
··· 26 27 "riscv32-linux" "riscv64-linux" 28 29 - "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" 30 ]; 31 32 allParsed = map parse.mkSystemFromString all; ··· 45 x86_64 = filterDoubles predicates.isx86_64; 46 mips = filterDoubles predicates.isMips; 47 riscv = filterDoubles predicates.isRiscV; 48 49 cygwin = filterDoubles predicates.isCygwin; 50 darwin = filterDoubles predicates.isDarwin;
··· 26 27 "riscv32-linux" "riscv64-linux" 28 29 + "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" "vc4-none" 30 ]; 31 32 allParsed = map parse.mkSystemFromString all; ··· 45 x86_64 = filterDoubles predicates.isx86_64; 46 mips = filterDoubles predicates.isMips; 47 riscv = filterDoubles predicates.isRiscV; 48 + vc4 = filterDoubles predicates.isVc4; 49 50 cygwin = filterDoubles predicates.isCygwin; 51 darwin = filterDoubles predicates.isDarwin;
+6
lib/systems/examples.nix
··· 118 config = "avr"; 119 }; 120 121 arm-embedded = { 122 config = "arm-none-eabi"; 123 libc = "newlib";
··· 118 config = "avr"; 119 }; 120 121 + vc4 = { 122 + config = "vc4-elf"; 123 + libc = "newlib"; 124 + platform = {}; 125 + }; 126 + 127 arm-embedded = { 128 config = "arm-none-eabi"; 129 libc = "newlib";
+1
lib/systems/inspect.nix
··· 21 isSparc = { cpu = { family = "sparc"; }; }; 22 isWasm = { cpu = { family = "wasm"; }; }; 23 isMsp430 = { cpu = { family = "msp430"; }; }; 24 isAvr = { cpu = { family = "avr"; }; }; 25 isAlpha = { cpu = { family = "alpha"; }; }; 26 isJavaScript = { cpu = cpuTypes.js; };
··· 21 isSparc = { cpu = { family = "sparc"; }; }; 22 isWasm = { cpu = { family = "wasm"; }; }; 23 isMsp430 = { cpu = { family = "msp430"; }; }; 24 + isVc4 = { cpu = { family = "vc4"; }; }; 25 isAvr = { cpu = { family = "avr"; }; }; 26 isAlpha = { cpu = { family = "alpha"; }; }; 27 isJavaScript = { cpu = cpuTypes.js; };
+2
lib/systems/parse.nix
··· 112 msp430 = { bits = 16; significantByte = littleEndian; family = "msp430"; }; 113 avr = { bits = 8; family = "avr"; }; 114 115 js = { bits = 32; significantByte = littleEndian; family = "js"; }; 116 }; 117
··· 112 msp430 = { bits = 16; significantByte = littleEndian; family = "msp430"; }; 113 avr = { bits = 8; family = "avr"; }; 114 115 + vc4 = { bits = 32; significantByte = littleEndian; family = "vc4"; }; 116 + 117 js = { bits = 32; significantByte = littleEndian; family = "js"; }; 118 }; 119
+1
pkgs/build-support/bintools-wrapper/default.nix
··· 190 else if targetPlatform.isMsp430 then "msp430" 191 else if targetPlatform.isAvr then "avr" 192 else if targetPlatform.isAlpha then "alpha" 193 else throw "unknown emulation for platform: ${targetPlatform.config}"; 194 in if targetPlatform.useLLVM or false then "" 195 else targetPlatform.platform.bfdEmulation or (fmt + sep + arch);
··· 190 else if targetPlatform.isMsp430 then "msp430" 191 else if targetPlatform.isAvr then "avr" 192 else if targetPlatform.isAlpha then "alpha" 193 + else if targetPlatform.isVc4 then "vc4" 194 else throw "unknown emulation for platform: ${targetPlatform.config}"; 195 in if targetPlatform.useLLVM or false then "" 196 else targetPlatform.platform.bfdEmulation or (fmt + sep + arch);
+10 -3
pkgs/development/compilers/gcc/6/default.nix
··· 1 - { stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs 2 , langC ? true, langCC ? true, langFortran ? false 3 , langObjC ? stdenv.targetPlatform.isDarwin 4 , langObjCpp ? stdenv.targetPlatform.isDarwin ··· 9 , enableShared ? true 10 , enableLTO ? true 11 , texinfo ? null 12 , perl ? null # optional, for texi2pod (then pod2man); required for Java 13 , gmp, mpfr, libmpc, gettext, which 14 , libelf # optional, for link-time optimizations (LTO) ··· 107 108 builder = ../builder.sh; 109 110 - src = fetchurl { 111 url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; 112 sha256 = "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"; 113 }; ··· 172 depsBuildBuild = [ buildPackages.stdenv.cc ]; 173 nativeBuildInputs = [ texinfo which gettext ] 174 ++ (optional (perl != null) perl) 175 - ++ (optional javaAwtGtk pkgconfig); 176 177 # For building runtime libs 178 depsBuildTarget =
··· 1 + { stdenv, targetPackages, fetchurl, fetchpatch, fetchFromGitHub, noSysDirs 2 , langC ? true, langCC ? true, langFortran ? false 3 , langObjC ? stdenv.targetPlatform.isDarwin 4 , langObjCpp ? stdenv.targetPlatform.isDarwin ··· 9 , enableShared ? true 10 , enableLTO ? true 11 , texinfo ? null 12 + , flex 13 , perl ? null # optional, for texi2pod (then pod2man); required for Java 14 , gmp, mpfr, libmpc, gettext, which 15 , libelf # optional, for link-time optimizations (LTO) ··· 108 109 builder = ../builder.sh; 110 111 + src = if stdenv.targetPlatform.isVc4 then fetchFromGitHub { 112 + owner = "itszor"; 113 + repo = "gcc-vc4"; 114 + rev = "e90ff43f9671c760cf0d1dd62f569a0fb9bf8918"; 115 + sha256 = "0gxf66hwqk26h8f853sybphqa5ca0cva2kmrw5jsiv6139g0qnp8"; 116 + } else fetchurl { 117 url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; 118 sha256 = "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"; 119 }; ··· 178 depsBuildBuild = [ buildPackages.stdenv.cc ]; 179 nativeBuildInputs = [ texinfo which gettext ] 180 ++ (optional (perl != null) perl) 181 + ++ (optional javaAwtGtk pkgconfig) 182 + ++ (optional (stdenv.targetPlatform.isVc4) flex); 183 184 # For building runtime libs 185 depsBuildTarget =
+28
pkgs/development/misc/vc4/newlib.nix
···
··· 1 + { stdenv, texinfo, flex, bison, fetchFromGitHub, crossLibcStdenv, buildPackages }: 2 + 3 + crossLibcStdenv.mkDerivation { 4 + name = "newlib"; 5 + src = fetchFromGitHub { 6 + owner = "itszor"; 7 + repo = "newlib-vc4"; 8 + rev = "89abe4a5263d216e923fbbc80495743ff269a510"; 9 + sha256 = "131r4v0nn68flnqibjcvhsrys3hs89bn0i4vwmrzgjd7v1rbgqav"; 10 + }; 11 + dontUpdateAutotoolsGnuConfigScripts = true; 12 + configurePlatforms = [ "target" ]; 13 + enableParallelBuilding = true; 14 + 15 + nativeBuildInputs = [ texinfo flex bison ]; 16 + depsBuildBuild = [ buildPackages.stdenv.cc ]; 17 + # newlib expects CC to build for build platform, not host platform 18 + preConfigure = '' 19 + export CC=cc 20 + ''; 21 + 22 + dontStrip = true; 23 + 24 + passthru = { 25 + incdir = "/${stdenv.targetPlatform.config}/include"; 26 + libdir = "/${stdenv.targetPlatform.config}/lib"; 27 + }; 28 + }
+19 -8
pkgs/development/tools/misc/binutils/default.nix
··· 1 { stdenv, lib, buildPackages 2 - , fetchurl, zlib, autoreconfHook, gettext 3 # Enabling all targets increases output size to a multiple. 4 , withAllTargets ? false, libbfd, libopcodes 5 , enableShared ? true 6 , noSysDirs 7 , gold ? !stdenv.buildPlatform.isDarwin || stdenv.hostPlatform == stdenv.targetPlatform 8 , bison ? null 9 }: 10 11 let ··· 20 # PATH to both be usable. 21 targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) 22 "${stdenv.targetPlatform.config}-"; 23 in 24 25 stdenv.mkDerivation { 26 name = targetPrefix + basename; 27 28 - # HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM 29 - src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl { 30 - url = "mirror://gnu/binutils/${basename}.tar.bz2"; 31 - sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z"; 32 - }); 33 34 patches = [ 35 # Make binutils output deterministic by default. ··· 54 # cross-compiling. 55 ./always-search-rpath.patch 56 57 # https://sourceware.org/bugzilla/show_bug.cgi?id=22868 58 ./gold-symbol-visibility.patch 59 ··· 69 depsBuildBuild = [ buildPackages.stdenv.cc ]; 70 nativeBuildInputs = [ 71 bison 72 - ] ++ lib.optionals stdenv.targetPlatform.isiOS [ 73 autoreconfHook 74 - ]; 75 buildInputs = [ zlib gettext ]; 76 77 inherit noSysDirs;
··· 1 { stdenv, lib, buildPackages 2 + , fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext 3 # Enabling all targets increases output size to a multiple. 4 , withAllTargets ? false, libbfd, libopcodes 5 , enableShared ? true 6 , noSysDirs 7 , gold ? !stdenv.buildPlatform.isDarwin || stdenv.hostPlatform == stdenv.targetPlatform 8 , bison ? null 9 + , flex 10 + , texinfo 11 }: 12 13 let ··· 22 # PATH to both be usable. 23 targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) 24 "${stdenv.targetPlatform.config}-"; 25 + vc4-binutils-src = fetchFromGitHub { 26 + owner = "itszor"; 27 + repo = "binutils-vc4"; 28 + rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36"; 29 + sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"; 30 + }; 31 + # HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM 32 + normal-src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl { 33 + url = "mirror://gnu/binutils/${basename}.tar.bz2"; 34 + sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z"; 35 + }); 36 in 37 38 stdenv.mkDerivation { 39 name = targetPrefix + basename; 40 41 + src = if stdenv.targetPlatform.isVc4 then vc4-binutils-src else normal-src; 42 43 patches = [ 44 # Make binutils output deterministic by default. ··· 63 # cross-compiling. 64 ./always-search-rpath.patch 65 66 + ] ++ lib.optionals (!stdenv.targetPlatform.isVc4) 67 + [ 68 # https://sourceware.org/bugzilla/show_bug.cgi?id=22868 69 ./gold-symbol-visibility.patch 70 ··· 80 depsBuildBuild = [ buildPackages.stdenv.cc ]; 81 nativeBuildInputs = [ 82 bison 83 + ] ++ (lib.optionals stdenv.targetPlatform.isiOS [ 84 autoreconfHook 85 + ]) ++ lib.optionals stdenv.targetPlatform.isVc4 [ texinfo flex ]; 86 buildInputs = [ zlib gettext ]; 87 88 inherit noSysDirs;
+18
pkgs/misc/emulators/resim/default.nix
···
··· 1 + { fetchFromGitHub, stdenv, cmake, qt4 }: 2 + 3 + stdenv.mkDerivation { 4 + name = "resim"; 5 + src = fetchFromGitHub { 6 + owner = "itszor"; 7 + repo = "resim"; 8 + rev = "cdc7808ceb7ba4ac00d0d08ca646b58615059150"; 9 + sha256 = "1743lngqxd7ai4k6cd4d1cf9h60z2pnvr2iynfs1zlpcj3w1hx0c"; 10 + }; 11 + nativeBuildInputs = [ cmake ]; 12 + buildInputs = [ qt4 ]; 13 + installPhase = '' 14 + mkdir -pv $out/{lib,bin} 15 + cp -v libresim/libarmsim.so $out/lib/libarmsim.so 16 + cp -v vc4emul/vc4emul $out/bin/vc4emul 17 + ''; 18 + }
+6 -2
pkgs/top-level/all-packages.nix
··· 7765 gerbil = callPackage ../development/compilers/gerbil { stdenv = gccStdenv; }; 7766 gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { stdenv = gccStdenv; }; 7767 7768 - gccFun = callPackage ../development/compilers/gcc/8; 7769 - gcc = gcc8; 7770 gcc-unwrapped = gcc.cc; 7771 7772 gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override { ··· 9389 }; 9390 9391 mspdebug = callPackage ../development/misc/msp430/mspdebug.nix { }; 9392 9393 rappel = callPackage ../development/misc/rappel/default.nix { }; 9394 ··· 11336 else if name == "uclibc" then targetPackages.uclibcCross or uclibcCross 11337 else if name == "avrlibc" then targetPackages.avrlibcCross or avrlibcCross 11338 else if name == "newlib" && stdenv.targetPlatform.isMsp430 then targetPackages.msp430NewlibCross or msp430NewlibCross 11339 else if name == "newlib" then targetPackages.newlibCross or newlibCross 11340 else if name == "musl" then targetPackages.muslCross or muslCross 11341 else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64
··· 7765 gerbil = callPackage ../development/compilers/gerbil { stdenv = gccStdenv; }; 7766 gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { stdenv = gccStdenv; }; 7767 7768 + gccFun = callPackage (if stdenv.targetPlatform.isVc4 then ../development/compilers/gcc/6 else ../development/compilers/gcc/8); 7769 + gcc = if stdenv.targetPlatform.isVc4 then gcc6 else gcc8; 7770 gcc-unwrapped = gcc.cc; 7771 7772 gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override { ··· 9389 }; 9390 9391 mspdebug = callPackage ../development/misc/msp430/mspdebug.nix { }; 9392 + 9393 + vc4-newlib = callPackage ../development/misc/vc4/newlib.nix {}; 9394 + resim = callPackage ../misc/emulators/resim {}; 9395 9396 rappel = callPackage ../development/misc/rappel/default.nix { }; 9397 ··· 11339 else if name == "uclibc" then targetPackages.uclibcCross or uclibcCross 11340 else if name == "avrlibc" then targetPackages.avrlibcCross or avrlibcCross 11341 else if name == "newlib" && stdenv.targetPlatform.isMsp430 then targetPackages.msp430NewlibCross or msp430NewlibCross 11342 + else if name == "newlib" && stdenv.targetPlatform.isVc4 then targetPackages.vc4-newlib or vc4-newlib 11343 else if name == "newlib" then targetPackages.newlibCross or newlibCross 11344 else if name == "musl" then targetPackages.muslCross or muslCross 11345 else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64