You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

111 lines
2.7 KiB

{ lib
, stdenv
, gmp, mpfr, libmpc
, isl, zlib, libelf
, xtensa-elf-binutils
, newlib ? null
}:
let
version = "10.2.0";
target = "xtensa-esp32-elf";
xtensa-overlay-commit = "4d8c98d";
xtensa-overlay = fetchTarball {
url = "https://codeload.github.com/espressif/xtensa-overlays/tar.gz/${xtensa-overlay-commit}";
sha256 = "sha256:16z9028mxfbzy4rmhcldi9rdlhi7lmcdxjhr630m0kr447gq3820";
};
in
with lib; stdenv.mkDerivation {
src = fetchTarball {
url = "https://gcc.gnu.org/pub/gcc/releases/gcc-${version}/gcc-${version}.tar.xz";
sha256 = "sha256:0l1n916az5ygp3jamrd6qj0j5kq3nfl8n79rvj94g3rj85jdpi64";
};
inherit version;
name = "${target}-gcc";
buildInputs = [
gmp mpfr libmpc
isl zlib
xtensa-elf-binutils
];
hardeningDisable = [ "format" "pie" ];
enableParallelBuilding = true;
configureFlags = [
"--target=${target}"
"--with-as=${xtensa-elf-binutils}/bin/${target}-as"
"--with-gnu-as"
"--with-ld=${xtensa-elf-binutils}/bin/${target}-ld"
"--with-gnu-ld"
"--with-host-libstdcxx=-static-libgcc,-Wl,-Bstatic,-lstdc++,-Bdynamic,-lm"
"--with-gmp-include=${gmp.dev}/include"
"--with-gmp-lib=${gmp.out}/lib"
"--with-mpfr-include=${mpfr.dev}/include"
"--with-mpfr-lib=${mpfr.out}/lib"
"--with-mpc=${libmpc}"
"--with-isl=${isl}"
"--with-libelf=${libelf}"
"--with-native-system-header-dir=/include"
"--with-newlib"
"--without-headers"
"--with-headers=$out/include"
"--with-sysroot=$out"
"--with-system-zlib"
"--without-libffi"
"--disable-__cxa_atexit"
"--disable-decimal-float"
"--disable-libgomp"
"--disable-libmpx"
"--disable-libmudflap"
"--disable-libquadmath"
"--disable-libquadmath-support"
"--disable-libssp"
"--disable-libstdcxx-pch"
"--disable-libstdcxx-verbose"
"--disable-nls"
"--disable-shared"
"--disable-threads"
"--disable-tls"
"--enable-gnu-indirect-function"
"--enable-languages=c,c++"
"--enable-lto"
"--enable-target-optspace"
# --with-python-dir=share/gcc-$_target \
# --with-sysroot=/usr/$_target \
# --with-native-system-header-dir=/include \
# --with-headers=/usr/$_target/include \
# --libexecdir=/usr/lib \
# --prefix=/usr \
];
preConfigure = ''
cp -r ${xtensa-overlay}/xtensa_esp32/gcc/* .
mkdir -p ./build && cd ./build
'';
configureScript = "../configure";
preBuild = ''
mkdir -p ./build && cd ./build
'';
buildPhase = ''
export CFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -mlongcalls'
export CXXFLAGS_FOR_TARGET='-g -Os -ffunction-sections -fdata-sections -mlongcalls'
make all-gcc
make all-target-libgcc
'';
installPhase = ''
make install-gcc
make install-target-libgcc
'';
}