Merge pull request #72657 from cleverca22/vc4

Initial implementation of vc4 cross-compile
This commit is contained in:
John Ericson 2019-11-24 16:04:15 -05:00 committed by GitHub
commit 814f9104d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 94 additions and 14 deletions

View file

@ -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

View file

@ -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;

View file

@ -118,6 +118,12 @@ rec {
config = "avr";
};
vc4 = {
config = "vc4-elf";
libc = "newlib";
platform = {};
};
arm-embedded = {
config = "arm-none-eabi";
libc = "newlib";

View file

@ -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; };

View file

@ -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"; };
};

View file

@ -184,6 +184,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);

View file

@ -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 =

View file

@ -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";
};
}

View file

@ -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;

View file

@ -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
'';
}

View file

@ -7766,8 +7766,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 {
@ -9393,6 +9393,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 { };
@ -11341,6 +11344,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