Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gcc-arm-embedded-11: Fixed hydra build issue due to large derivation size. #270752

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions pkgs/development/compilers/gcc-arm-embedded/11/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib
, stdenv
, fetchurl
, ncurses5
, python38
, libxcrypt-legacy
Expand All @@ -14,47 +13,59 @@ stdenv.mkDerivation rec {
platform = {
aarch64-linux = "aarch64";
x86_64-darwin = "darwin-x86_64";
x86_64-linux = "x86_64";
x86_64-linux = "x86_64";
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

src = fetchurl {
outputs = [ "out" "arm_none_eabi" ];

src = builtins.fetchTarball {
url = "https://developer.arm.com/-/media/Files/downloads/gnu/${version}/binrel/arm-gnu-toolchain-${version}-${platform}-arm-none-eabi.tar.xz";
sha256 = {
aarch64-linux = "0pmm5r0k5mxd5drbn2s8a7qkm8c4fi8j5y31c70yrp0qs08kqwbc";
x86_64-darwin = "1kr9kd9p2xk84fa99zf3gz5lkww2i9spqkjigjwakfkzbva56qw2";
x86_64-linux = "08b1w1zmj4z80k59zmlc1bf34lg8d7z65fwvp5ir2pb1d1zxh86l";
x86_64-linux = "0zg754z0s8fx3qwh8jssf6rslnx9xmgcd2va6lykc8vlk8v5r19y";
}.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
};

dontConfigure = true;
dontBuild = true;
dontPatchELF = true;
dontStrip = true;
# this works, but automatic patchelf is run (and fails on 32-bit, relocatable files)
# when running auditTmpdir. noAuditTmpdir disables it, but it's not a good idea.
# This needs either a fix for patchelf or the script that feeds it the "wrong" ELF.
dontPatchELF = true;

installPhase = ''
mkdir -p $out
cp -r * $out
# arm-none-eabi is a big boy and the complete outputs exceeds hydra's max_output_size.
moveToOutput "arm-none-eabi" "$arm_none_eabi"
# Link to it here in case anyone refers to it.
ln -s "$arm_none_eabi" "$out/arm-none-eabi"

# Wrap gdb with correct Python path.
mv $out/bin/arm-none-eabi-gdb $out/bin/arm-none-eabi-gdb-unwrapped
cat <<EOF > $out/bin/arm-none-eabi-gdb
#!${runtimeShell}
export PYTHONPATH=${python38}/lib/python3.8
export PYTHONHOME=${python38}/bin/python3.8
exec $out/bin/arm-none-eabi-gdb-unwrapped "\$@"
EOF
chmod +x $out/bin/arm-none-eabi-gdb
'';

# Fix rpath for pre-compiled native binaries.
# WARNING: The target bineries in arm-none-eabi are not patched and may not work.
preFixup = ''
find $out -type f | while read f; do
# We find all ELF files that are not for 32-bit (target files).
# This package only serves 64 bit systems anyways.
for f in $(find $out -type f -exec file {} \; | awk -F: '$2 ~ /ELF/ && ! /32-bit/ {print $1}'); do
patchelf "$f" > /dev/null 2>&1 || continue
patchelf --set-interpreter $(cat ${stdenv.cc}/nix-support/dynamic-linker) "$f" || true
patchelf --set-rpath ${lib.makeLibraryPath [ "$out" stdenv.cc.cc ncurses5 python38 libxcrypt-legacy ]} "$f" || true
done
'';

postFixup = ''
mv $out/bin/arm-none-eabi-gdb $out/bin/arm-none-eabi-gdb-unwrapped
cat <<EOF > $out/bin/arm-none-eabi-gdb
#!${runtimeShell}
export PYTHONPATH=${python38}/lib/python3.8
export PYTHONHOME=${python38}/bin/python3.8
exec $out/bin/arm-none-eabi-gdb-unwrapped "\$@"
EOF
chmod +x $out/bin/arm-none-eabi-gdb
'';

meta = with lib; {
description = "Pre-built GNU toolchain from ARM Cortex-M & Cortex-R processors";
homepage = "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm";
Expand Down