diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 0d51be4b23bc..026117cc34fd 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -37,6 +37,7 @@ rec { else if final.isAndroid then "bionic" else if final.isLinux /* default */ then "glibc" else if final.isMsp430 then "newlib" + else if final.isVc4 then "newlib" else if final.isAvr then "avrlibc" else if final.isNetBSD then "nblibc" # TODO(@Ericson2314) think more about other operating systems diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index 58cff18e6488..700c895b3aba 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -26,7 +26,7 @@ let "riscv32-linux" "riscv64-linux" - "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" + "aarch64-none" "avr-none" "arm-none" "i686-none" "x86_64-none" "powerpc-none" "msp430-none" "riscv64-none" "riscv32-none" "vc4-none" ]; allParsed = map parse.mkSystemFromString all; @@ -45,6 +45,7 @@ in { x86_64 = filterDoubles predicates.isx86_64; mips = filterDoubles predicates.isMips; riscv = filterDoubles predicates.isRiscV; + vc4 = filterDoubles predicates.isVc4; cygwin = filterDoubles predicates.isCygwin; darwin = filterDoubles predicates.isDarwin; diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 585156c24759..cb8bc3de6c48 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -118,6 +118,12 @@ rec { config = "avr"; }; + vc4 = { + config = "vc4-elf"; + libc = "newlib"; + platform = {}; + }; + arm-embedded = { config = "arm-none-eabi"; libc = "newlib"; diff --git a/lib/systems/inspect.nix b/lib/systems/inspect.nix index 8a983b3d3637..d1980c6dff81 100644 --- a/lib/systems/inspect.nix +++ b/lib/systems/inspect.nix @@ -21,6 +21,7 @@ rec { isSparc = { cpu = { family = "sparc"; }; }; isWasm = { cpu = { family = "wasm"; }; }; isMsp430 = { cpu = { family = "msp430"; }; }; + isVc4 = { cpu = { family = "vc4"; }; }; isAvr = { cpu = { family = "avr"; }; }; isAlpha = { cpu = { family = "alpha"; }; }; isJavaScript = { cpu = cpuTypes.js; }; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 362357446025..6a02dbb51528 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -112,6 +112,8 @@ rec { msp430 = { bits = 16; significantByte = littleEndian; family = "msp430"; }; avr = { bits = 8; family = "avr"; }; + vc4 = { bits = 32; significantByte = littleEndian; family = "vc4"; }; + js = { bits = 32; significantByte = littleEndian; family = "js"; }; }; diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index e02e77de45e4..2c278cf11868 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 4ec24dbe88e7..947d1e1f7e71 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 000000000000..e1a8b2eeaa6a --- /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 210659289d1e..4b3e2cc3bede 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 000000000000..81acdf81f2ec --- /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 06a01805cebd..757ba2ad5257 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