Skip to content
Snippets Groups Projects
Commit 87e570ce authored by test_nonet's avatar test_nonet
Browse files

try using wrapped gcc without prefix

parent 12450142
No related branches found
No related tags found
No related merge requests found
......@@ -3,17 +3,11 @@
let
srcs = import ./sources.nix { inherit fetchFromGitHub; };
srcs2 = import ./sources2.nix { inherit fetchurl fetchgit fetchFromGitHub; };
wrapIt = pkg: runCommandLocal "wrapped-gcc" { preferLocalBuild = true; allowSubstitutes = false; } ''
mkdir -p $out/bin
ln -s ${pkg}/bin/gcc $out/bin/${pkg.stdenv.targetPlatform.config}-gcc
ln -s ${pkg}/bin/gcc $out/bin/${pkg.stdenv.targetPlatform.config}-wrapped-gcc
'';
# If Nix is cross-compiling this package, we have build!=host!=target (but Nix doesn't know about target, which is ESP32).
# This is called "canadian cross" for GCC builds and it needs some special care with crosstool-NG:
# 1. We need a working compiler for build-build. We cannot simply use the prefixed gcc name because that would
# directly go to the gcc binary and skip the wrapper script. We create a prefixed variant of the wrapper script
# with `wrapIt` and add this to depsBuildBuild.
# 1. We need a working compiler for build-build so we have to add it to depsBuildBuild and make sure that we are using it
# without prefix (because the one with prefix doesn't go through the wrapper script).
# 2. We must tell crosstool-NG that we are building a canadian cross.
canadian = stdenv.buildPlatform != stdenv.hostPlatform;
in stdenv.mkDerivation {
......@@ -24,7 +18,7 @@ in stdenv.mkDerivation {
(lib.attrsets.mapAttrsToList (name: drv: if drv ? outPath then "${name} ${drv.outPath}" else "") srcs2);
buildInputs = [ ncurses python3 ];
depsBuildBuild = if canadian then [ gcc binutils (wrapIt gcc.__spliced.buildBuild) ] else [ ];
depsBuildBuild = if canadian then [ gcc binutils ] else [ ];
nativeBuildInputs = [ espressif-crosstool-ng autoconf automake bison flex unzip help2man libtool which texinfo file wget gnum4 perl python3 ]
++ [ breakpointHook ];
......@@ -58,7 +52,7 @@ in stdenv.mkDerivation {
unset CT_CROSS
CT_CANADIAN=y
CT_BUILD="${stdenv.buildPlatform.config}"
CT_BUILD_PREFIX="${stdenv.buildPlatform.config}-wrapped-"
CT_BUILD_PREFIX=""
CT_HOST="${stdenv.hostPlatform.config}"
CT_HOST_PREFIX="${stdenv.hostPlatform.config}-"
EOF
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment