-
-
Save cleverca22/8a8958521dd57995b32a40ac2c4e1628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
lib.fix (self: { | |
binutils-vc4 = stdenv.mkDerivation { | |
name = "binutils-vc4"; | |
src = fetchFromGitHub { | |
owner = "itszor"; | |
repo = "binutils-vc4"; | |
rev = "708acc851880dbeda1dd18aca4fd0a95b2573b36"; | |
sha256 = "1kdrz6fki55lm15rwwamn74fnqpy0zlafsida2zymk76n3656c63"; | |
}; | |
nativeBuildInputs = [ texinfo flex bison ]; | |
configureFlags = [ "--target=vc4-elf" "--disable-werror" ]; | |
}; | |
gcc-vc4-stage1 = stdenv.mkDerivation { | |
name = "gcc-vc4-stage1"; | |
src = fetchFromGitHub { | |
owner = "itszor"; | |
repo = "gcc-vc4"; | |
rev = "e90ff43f9671c760cf0d1dd62f569a0fb9bf8918"; | |
sha256 = "0gxf66hwqk26h8f853sybphqa5ca0cva2kmrw5jsiv6139g0qnp8"; | |
}; | |
nativeBuildInputs = [ flex self.binutils-vc4 ]; | |
buildInputs = [ gmp mpfr libmpc ]; | |
preConfigure = '' | |
mkdir ../gcc-build | |
cd ../gcc-build | |
export configureScript=../$sourceRoot/configure | |
''; | |
enableParallelBuilding = true; | |
configureFlags = [ | |
"--target=vc4-elf" "--disable-nls" "--disable-ssp" "--enable-languages=c" | |
"--without-headers" "--with-newlib" "--disable-decimal-float" "--disable-threads" | |
"--disable-libatomic" "--disable-libitm" "--disable-libsanitizer" | |
"--disable-libquadmath" "--disable-lto" "--enable-sjlj-exceptions" | |
"--with-as=${self.binutils-vc4}/bin/vc4-elf-as" | |
"--with-ld=${self.binutils-vc4}/bin/vc4-elf-ld" | |
]; | |
NIX_CFLAGS_COMPILE = [ "-Wno-error=format-security" ]; | |
}; | |
newlib-vc4 = stdenv.mkDerivation { | |
name = "newlib-vc4"; | |
src = fetchFromGitHub { | |
owner = "itszor"; | |
repo = "newlib-vc4"; | |
rev = "89abe4a5263d216e923fbbc80495743ff269a510"; | |
sha256 = "131r4v0nn68flnqibjcvhsrys3hs89bn0i4vwmrzgjd7v1rbgqav"; | |
}; | |
nativeBuildInputs = [ texinfo self.gcc-vc4-stage1 self.binutils-vc4 flex bison ]; | |
configureFlags = [ "--target=vc4-elf" ]; | |
enableParallelBuilding = true; | |
}; | |
gcc-vc4-stage2 = stdenv.mkDerivation { | |
name = "gcc-vc4-stage2"; | |
src = fetchFromGitHub { | |
owner = "itszor"; | |
repo = "gcc-vc4"; | |
rev = "e90ff43f9671c760cf0d1dd62f569a0fb9bf8918"; | |
sha256 = "0gxf66hwqk26h8f853sybphqa5ca0cva2kmrw5jsiv6139g0qnp8"; | |
}; | |
nativeBuildInputs = [ flex self.binutils-vc4 self.gcc-vc4-stage1 ]; | |
buildInputs = [ gmp mpfr libmpc self.newlib-vc4 ]; | |
preConfigure = '' | |
mkdir ../gcc-build | |
cd ../gcc-build | |
export configureScript=../$sourceRoot/configure | |
''; | |
#enableParallelBuilding = true; | |
configureFlags = [ | |
"--target=vc4-elf" "--disable-nls" | |
"--disable-ssp" "--enable-languages=c" "--disable-decimal-float" "--with-newlib" | |
"--enable-threads" "--disable-libatomic" "--disable-libsanitizer" | |
"--disable-libquadmath" "--disable-lto" "--enable-sjlj-exceptions" | |
"--with-as=${self.binutils-vc4}/bin/vc4-elf-as" | |
"--with-ld=${self.binutils-vc4}/bin/vc4-elf-ld" | |
"--with-headers=${self.newlib-vc4}/vc4-elf/include" | |
"--prefix=${builtins.placeholder "out"}" | |
]; | |
NIX_CFLAGS_COMPILE = [ "-Wno-error=format-security" ]; | |
}; | |
examples = fetchFromGitHub { | |
owner = "itszor"; | |
repo = "vc4-toolchain"; | |
rev = "e1c295a6e92483b5898995a601300e4e0acd007d"; | |
sha256 = "1hxc715qbixb6qr1mnvjvj1b62xxqz33a2mq36gybcyppqq23gw6"; | |
}; | |
helloworld = runCommand "helloworld" { buildInputs = [ self.gcc-vc4-stage2 ]; } '' | |
mkdir $out | |
vc4-elf-gcc ${self.examples}/helloworld/helloworld.c -O2 -T ${self.newlib-vc4}/vc4-elf/lib/vc4-sim.ld -o hello -L${self.newlib-vc4}/vc4-elf/lib/ -L${self.gcc-vc4-stage2}/lib/gcc/vc4-elf/6.2.1/sf/ | |
vc4-elf-objcopy -O binary hello hello.bin | |
cp hello hello.bin $out | |
''; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment