git.iko.soy/typeable/nixpkgs
on master help sign in
initial implementation of vc4 cross-compile
commit4aa1ffae041bb9c65eb3067e9dbaaa70710ed100 authorMichael Bishop <cleverca22@gmail.com> dateSat 2 Nov 2019, 12:47 (7 years ago) parent91b02cd
11 files changed+94−14
lib/systems/default.nix+1 lib/systems/doubles.nix+2−1 lib/systems/examples.nix+6 lib/systems/inspect.nix+1 lib/systems/parse.nix+2 pkgs/build-support/bintools-wrapper/default.nix+1 pkgs/development/compilers/gcc/6/default.nix+10−3 pkgs/development/misc/vc4/newlib.nix+28 pkgs/development/tools/misc/binutils/default.nix+19−8 pkgs/misc/emulators/resim/default.nix+18 pkgs/top-level/all-packages.nix+6−2
lib/systems/default.nix+1
@@ -37,6 +37,7 @@ rec {
3737 else if final.isAndroid then "bionic"
3838 else if final.isLinux /* default */ then "glibc"
3939 else if final.isMsp430 then "newlib"
40+ else if final.isVc4 then "newlib"
4041 else if final.isAvr then "avrlibc"
4142 else if final.isNetBSD then "nblibc"
4243 # TODO(@Ericson2314) think more about other operating systems
lib/systems/doubles.nix+2−1
@@ -26,7 +26,7 @@ let
2626
2727 "riscv32-linux" "riscv64-linux"
2828
29− "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none"
29+ "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" "vc4-none"
3030 ];
3131
3232 allParsed = map parse.mkSystemFromString all;
@@ -45,6 +45,7 @@ in {
4545 x86_64 = filterDoubles predicates.isx86_64;
4646 mips = filterDoubles predicates.isMips;
4747 riscv = filterDoubles predicates.isRiscV;
48+ vc4 = filterDoubles predicates.isVc4;
4849
4950 cygwin = filterDoubles predicates.isCygwin;
5051 darwin = filterDoubles predicates.isDarwin;
lib/systems/examples.nix+6
@@ -118,6 +118,12 @@ rec {
118118 config = "avr";
119119 };
120120
121+ vc4 = {
122+ config = "vc4-elf";
123+ libc = "newlib";
124+ platform = {};
125+ };
126+
121127 arm-embedded = {
122128 config = "arm-none-eabi";
123129 libc = "newlib";
lib/systems/inspect.nix+1
@@ -21,6 +21,7 @@ rec {
2121 isSparc = { cpu = { family = "sparc"; }; };
2222 isWasm = { cpu = { family = "wasm"; }; };
2323 isMsp430 = { cpu = { family = "msp430"; }; };
24+ isVc4 = { cpu = { family = "vc4"; }; };
2425 isAvr = { cpu = { family = "avr"; }; };
2526 isAlpha = { cpu = { family = "alpha"; }; };
2627 isJavaScript = { cpu = cpuTypes.js; };
lib/systems/parse.nix+2
@@ -112,6 +112,8 @@ rec {
112112 msp430 = { bits = 16; significantByte = littleEndian; family = "msp430"; };
113113 avr = { bits = 8; family = "avr"; };
114114
115+ vc4 = { bits = 32; significantByte = littleEndian; family = "vc4"; };
116+
115117 js = { bits = 32; significantByte = littleEndian; family = "js"; };
116118 };
117119
pkgs/build-support/bintools-wrapper/default.nix+1
@@ -190,6 +190,7 @@ stdenv.mkDerivation {
190190 else if targetPlatform.isMsp430 then "msp430"
191191 else if targetPlatform.isAvr then "avr"
192192 else if targetPlatform.isAlpha then "alpha"
193+ else if targetPlatform.isVc4 then "vc4"
193194 else throw "unknown emulation for platform: ${targetPlatform.config}";
194195 in if targetPlatform.useLLVM or false then ""
195196 else targetPlatform.platform.bfdEmulation or (fmt + sep + arch);
pkgs/development/compilers/gcc/6/default.nix+10−3
@@ -1,4 +1,4 @@
1−{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs
1+{ stdenv, targetPackages, fetchurl, fetchpatch, fetchFromGitHub, noSysDirs
22, langC ? true, langCC ? true, langFortran ? false
33, langObjC ? stdenv.targetPlatform.isDarwin
44, langObjCpp ? stdenv.targetPlatform.isDarwin
@@ -9,6 +9,7 @@
99, enableShared ? true
1010, enableLTO ? true
1111, texinfo ? null
12+, flex
1213, perl ? null # optional, for texi2pod (then pod2man); required for Java
1314, gmp, mpfr, libmpc, gettext, which
1415, libelf # optional, for link-time optimizations (LTO)
@@ -107,7 +108,12 @@ stdenv.mkDerivation ({
107108
108109 builder = ../builder.sh;
109110
110− src = fetchurl {
111+ src = if stdenv.targetPlatform.isVc4 then fetchFromGitHub {
112+ owner = "itszor";
113+ repo = "gcc-vc4";
114+ rev = "e90ff43f9671c760cf0d1dd62f569a0fb9bf8918";
115+ sha256 = "0gxf66hwqk26h8f853sybphqa5ca0cva2kmrw5jsiv6139g0qnp8";
116+ } else fetchurl {
111117 url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz";
112118 sha256 = "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby";
113119 };
@@ -172,7 +178,8 @@ stdenv.mkDerivation ({
172178 depsBuildBuild = [ buildPackages.stdenv.cc ];
173179 nativeBuildInputs = [ texinfo which gettext ]
174180 ++ (optional (perl != null) perl)
175− ++ (optional javaAwtGtk pkgconfig);
181+ ++ (optional javaAwtGtk pkgconfig)
182+ ++ (optional (stdenv.targetPlatform.isVc4) flex);
176183
177184 # For building runtime libs
178185 depsBuildTarget =
pkgs/development/misc/vc4/newlib.nixnew file+28
@@ -0,0 +1,28 @@
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+}
pkgs/development/tools/misc/binutils/default.nix+19−8
@@ -1,11 +1,13 @@
11{ stdenv, lib, buildPackages
2−, fetchurl, zlib, autoreconfHook, gettext
2+, fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext
33# Enabling all targets increases output size to a multiple.
44, withAllTargets ? false, libbfd, libopcodes
55, enableShared ? true
66, noSysDirs
77, gold ? !stdenv.buildPlatform.isDarwin || stdenv.hostPlatform == stdenv.targetPlatform
88, bison ? null
9+, flex
10+, texinfo
911}:
1012
1113let
@@ -20,16 +22,23 @@ let
2022 # PATH to both be usable.
2123 targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
2224 "${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+ });
2336in
2437
2538stdenv.mkDerivation {
2639 name = targetPrefix + basename;
2740
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− });
41+ src = if stdenv.targetPlatform.isVc4 then vc4-binutils-src else normal-src;
3342
3443 patches = [
3544 # Make binutils output deterministic by default.
@@ -54,6 +63,8 @@ stdenv.mkDerivation {
5463 # cross-compiling.
5564 ./always-search-rpath.patch
5665
66+ ] ++ lib.optionals (!stdenv.targetPlatform.isVc4)
67+ [
5768 # https://sourceware.org/bugzilla/show_bug.cgi?id=22868
5869 ./gold-symbol-visibility.patch
5970
@@ -69,9 +80,9 @@ stdenv.mkDerivation {
6980 depsBuildBuild = [ buildPackages.stdenv.cc ];
7081 nativeBuildInputs = [
7182 bison
72− ] ++ lib.optionals stdenv.targetPlatform.isiOS [
83+ ] ++ (lib.optionals stdenv.targetPlatform.isiOS [
7384 autoreconfHook
74− ];
85+ ]) ++ lib.optionals stdenv.targetPlatform.isVc4 [ texinfo flex ];
7586 buildInputs = [ zlib gettext ];
7687
7788 inherit noSysDirs;
pkgs/misc/emulators/resim/default.nixnew file+18
@@ -0,0 +1,18 @@
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+}
pkgs/top-level/all-packages.nix+6−2
@@ -7765,8 +7765,8 @@ in
77657765 gerbil = callPackage ../development/compilers/gerbil { stdenv = gccStdenv; };
77667766 gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { stdenv = gccStdenv; };
77677767
7768− gccFun = callPackage ../development/compilers/gcc/8;
7769− gcc = gcc8;
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;
77707770 gcc-unwrapped = gcc.cc;
77717771
77727772 gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override {
@@ -9390,6 +9390,9 @@ in
93909390
93919391 mspdebug = callPackage ../development/misc/msp430/mspdebug.nix { };
93929392
9393+ vc4-newlib = callPackage ../development/misc/vc4/newlib.nix {};
9394+ resim = callPackage ../misc/emulators/resim {};
9395+
93939396 rappel = callPackage ../development/misc/rappel/default.nix { };
93949397
93959398 pharo-vms = callPackage ../development/pharo/vm { };
@@ -11336,6 +11339,7 @@ in
1133611339 else if name == "uclibc" then targetPackages.uclibcCross or uclibcCross
1133711340 else if name == "avrlibc" then targetPackages.avrlibcCross or avrlibcCross
1133811341 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
1133911343 else if name == "newlib" then targetPackages.newlibCross or newlibCross
1134011344 else if name == "musl" then targetPackages.muslCross or muslCross
1134111345 else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64