From 4aa1ffae041bb9c65eb3067e9dbaaa70710ed100 Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Sat, 2 Nov 2019 12:47:38 -0300 Subject: initial implementation of vc4 cross-compile --- pkgs/build-support/bintools-wrapper/default.nix | 1 + pkgs/development/compilers/gcc/6/default.nix | 13 ++++++++--- pkgs/development/misc/vc4/newlib.nix | 28 ++++++++++++++++++++++++ pkgs/development/tools/misc/binutils/default.nix | 27 ++++++++++++++++------- pkgs/misc/emulators/resim/default.nix | 18 +++++++++++++++ pkgs/top-level/all-packages.nix | 8 +++++-- 6 files changed, 82 insertions(+), 13 deletions(-) create mode 100644 pkgs/development/misc/vc4/newlib.nix create mode 100644 pkgs/misc/emulators/resim/default.nix (limited to 'pkgs') diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index e02e77de45e..2c278cf1186 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -190,6 +190,7 @@ stdenv.mkDerivation { else if targetPlatform.isMsp430 then "msp430" else if targetPlatform.isAvr then "avr" else if targetPlatform.isAlpha then "alpha" + else if targetPlatform.isVc4 then "vc4" else throw "unknown emulation for platform: ${targetPlatform.config}"; in if targetPlatform.useLLVM or false then "" else targetPlatform.platform.bfdEmulation or (fmt + sep + arch); diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 4ec24dbe88e..947d1e1f7e7 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -1,4 +1,4 @@ -{ stdenv, targetPackages, fetchurl, fetchpatch, noSysDirs +{ stdenv, targetPackages, fetchurl, fetchpatch, fetchFromGitHub, noSysDirs , langC ? true, langCC ? true, langFortran ? false , langObjC ? stdenv.targetPlatform.isDarwin , langObjCpp ? stdenv.targetPlatform.isDarwin @@ -9,6 +9,7 @@ , enableShared ? true , enableLTO ? true , texinfo ? null +, flex , perl ? null # optional, for texi2pod (then pod2man); required for Java , gmp, mpfr, libmpc, gettext, which , libelf # optional, for link-time optimizations (LTO) @@ -107,7 +108,12 @@ stdenv.mkDerivation ({ builder = ../builder.sh; - src = fetchurl { + src = if stdenv.targetPlatform.isVc4 then fetchFromGitHub { + owner = "itszor"; + repo = "gcc-vc4"; + rev = "e90ff43f9671c760cf0d1dd62f569a0fb9bf8918"; + sha256 = "0gxf66hwqk26h8f853sybphqa5ca0cva2kmrw5jsiv6139g0qnp8"; + } else fetchurl { url = "mirror://gnu/gcc/gcc-${version}/gcc-${version}.tar.xz"; sha256 = "0i89fksfp6wr1xg9l8296aslcymv2idn60ip31wr9s4pwin7kwby"; }; @@ -172,7 +178,8 @@ stdenv.mkDerivation ({ depsBuildBuild = [ buildPackages.stdenv.cc ]; nativeBuildInputs = [ texinfo which gettext ] ++ (optional (perl != null) perl) - ++ (optional javaAwtGtk pkgconfig); + ++ (optional javaAwtGtk pkgconfig) + ++ (optional (stdenv.targetPlatform.isVc4) flex); # For building runtime libs depsBuildTarget = diff --git a/pkgs/development/misc/vc4/newlib.nix b/pkgs/development/misc/vc4/newlib.nix new file mode 100644 index 00000000000..e1a8b2eeaa6 --- /dev/null +++ b/pkgs/development/misc/vc4/newlib.nix @@ -0,0 +1,28 @@ +{ stdenv, texinfo, flex, bison, fetchFromGitHub, crossLibcStdenv, buildPackages }: + +crossLibcStdenv.mkDerivation { + name = "newlib"; + src = fetchFromGitHub { + owner = "itszor"; + repo = "newlib-vc4"; + rev = "89abe4a5263d216e923fbbc80495743ff269a510"; + sha256 = "131r4v0nn68flnqibjcvhsrys3hs89bn0i4vwmrzgjd7v1rbgqav"; + }; + dontUpdateAutotoolsGnuConfigScripts = true; + configurePlatforms = [ "target" ]; + enableParallelBuilding = true; + + nativeBuildInputs = [ texinfo flex bison ]; + depsBuildBuild = [ buildPackages.stdenv.cc ]; + # newlib expects CC to build for build platform, not host platform + preConfigure = '' + export CC=cc + ''; + + dontStrip = true; + + passthru = { + incdir = "/${stdenv.targetPlatform.config}/include"; + libdir = "/${stdenv.targetPlatform.config}/lib"; + }; +} diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 210659289d1..4b3e2cc3bed 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -1,11 +1,13 @@ { stdenv, lib, buildPackages -, fetchurl, zlib, autoreconfHook, gettext +, fetchFromGitHub, fetchurl, zlib, autoreconfHook, gettext # Enabling all targets increases output size to a multiple. , withAllTargets ? false, libbfd, libopcodes , enableShared ? true , noSysDirs , gold ? !stdenv.buildPlatform.isDarwin || stdenv.hostPlatform == stdenv.targetPlatform , bison ? null +, flex +, texinfo }: let @@ -20,16 +22,23 @@ let # PATH to both be usable. targetPrefix = lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) "${stdenv.targetPlatform.config}-"; + vc4-binutils-src = fetchFromGitHub { + owner = "itszor"; + repo = "binutils-vc4"; + rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36"; + sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"; + }; + # HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM + normal-src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl { + url = "mirror://gnu/binutils/${basename}.tar.bz2"; + sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z"; + }); in stdenv.mkDerivation { name = targetPrefix + basename; - # HACK to ensure that we preserve source from bootstrap binutils to not rebuild LLVM - src = stdenv.__bootPackages.binutils-unwrapped.src or (fetchurl { - url = "mirror://gnu/binutils/${basename}.tar.bz2"; - sha256 = "1l34hn1zkmhr1wcrgf0d4z7r3najxnw3cx2y2fk7v55zjlk3ik7z"; - }); + src = if stdenv.targetPlatform.isVc4 then vc4-binutils-src else normal-src; patches = [ # Make binutils output deterministic by default. @@ -54,6 +63,8 @@ stdenv.mkDerivation { # cross-compiling. ./always-search-rpath.patch + ] ++ lib.optionals (!stdenv.targetPlatform.isVc4) + [ # https://sourceware.org/bugzilla/show_bug.cgi?id=22868 ./gold-symbol-visibility.patch @@ -69,9 +80,9 @@ stdenv.mkDerivation { depsBuildBuild = [ buildPackages.stdenv.cc ]; nativeBuildInputs = [ bison - ] ++ lib.optionals stdenv.targetPlatform.isiOS [ + ] ++ (lib.optionals stdenv.targetPlatform.isiOS [ autoreconfHook - ]; + ]) ++ lib.optionals stdenv.targetPlatform.isVc4 [ texinfo flex ]; buildInputs = [ zlib gettext ]; inherit noSysDirs; diff --git a/pkgs/misc/emulators/resim/default.nix b/pkgs/misc/emulators/resim/default.nix new file mode 100644 index 00000000000..81acdf81f2e --- /dev/null +++ b/pkgs/misc/emulators/resim/default.nix @@ -0,0 +1,18 @@ +{ fetchFromGitHub, stdenv, cmake, qt4 }: + +stdenv.mkDerivation { + name = "resim"; + src = fetchFromGitHub { + owner = "itszor"; + repo = "resim"; + rev = "cdc7808ceb7ba4ac00d0d08ca646b58615059150"; + sha256 = "1743lngqxd7ai4k6cd4d1cf9h60z2pnvr2iynfs1zlpcj3w1hx0c"; + }; + nativeBuildInputs = [ cmake ]; + buildInputs = [ qt4 ]; + installPhase = '' + mkdir -pv $out/{lib,bin} + cp -v libresim/libarmsim.so $out/lib/libarmsim.so + cp -v vc4emul/vc4emul $out/bin/vc4emul + ''; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 06a01805ceb..757ba2ad525 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7765,8 +7765,8 @@ in gerbil = callPackage ../development/compilers/gerbil { stdenv = gccStdenv; }; gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { stdenv = gccStdenv; }; - gccFun = callPackage ../development/compilers/gcc/8; - gcc = gcc8; + gccFun = callPackage (if stdenv.targetPlatform.isVc4 then ../development/compilers/gcc/6 else ../development/compilers/gcc/8); + gcc = if stdenv.targetPlatform.isVc4 then gcc6 else gcc8; gcc-unwrapped = gcc.cc; gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override { @@ -9390,6 +9390,9 @@ in mspdebug = callPackage ../development/misc/msp430/mspdebug.nix { }; + vc4-newlib = callPackage ../development/misc/vc4/newlib.nix {}; + resim = callPackage ../misc/emulators/resim {}; + rappel = callPackage ../development/misc/rappel/default.nix { }; pharo-vms = callPackage ../development/pharo/vm { }; @@ -11336,6 +11339,7 @@ in else if name == "uclibc" then targetPackages.uclibcCross or uclibcCross else if name == "avrlibc" then targetPackages.avrlibcCross or avrlibcCross else if name == "newlib" && stdenv.targetPlatform.isMsp430 then targetPackages.msp430NewlibCross or msp430NewlibCross + else if name == "newlib" && stdenv.targetPlatform.isVc4 then targetPackages.vc4-newlib or vc4-newlib else if name == "newlib" then targetPackages.newlibCross or newlibCross else if name == "musl" then targetPackages.muslCross or muslCross else if name == "msvcrt" then targetPackages.windows.mingw_w64 or windows.mingw_w64 -- cgit 1.4.1