uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,53 @@
# This derivation is a reduced-functionality variant of Gambit stable,
# used to compile the full version of Gambit stable *and* unstable.
{ gccStdenv, lib, fetchurl, autoconf, gcc, coreutils, gambit-support, ... }:
# As explained in build.nix, GCC compiles Gambit 10x faster than Clang, for code 3x better
gccStdenv.mkDerivation {
pname = "gambit-bootstrap";
version = "4.9.3";
src = fetchurl {
url = "http://www.iro.umontreal.ca/~gambit/download/gambit/v4.9/source/gambit-v4_9_3.tgz";
sha256 = "1p6172vhcrlpjgia6hsks1w4fl8rdyjf9xjh14wxfkv7dnx8a5hk";
};
buildInputs = [ autoconf ];
# disable stackprotector on aarch64-darwin for now
# build error:
# ```
# /private/tmp/nix-build-gambit-bootstrap-4.9.3.drv-0/ccbOVwnF.s:207:15: error: index must be an integer in range [-256, 255].
# ldr x2, [x2, ___stack_chk_guard];momd
# ^
# ```
hardeningDisable = lib.optionals (gccStdenv.isAarch64 && gccStdenv.isDarwin) [ "stackprotector" ];
configurePhase = ''
export CC=${gcc}/bin/gcc CXX=${gcc}/bin/g++ \
CPP=${gcc}/bin/cpp CXXCPP=${gcc}/bin/cpp LD=${gcc}/bin/ld \
XMKMF=${coreutils}/bin/false
unset CFLAGS LDFLAGS LIBS CPPFLAGS CXXFLAGS
./configure --prefix=$out/gambit
'';
buildPhase = ''
# Copy the (configured) sources now, not later, so we don't have to filter out
# all the intermediate build products.
mkdir -p $out/gambit ; cp -rp . $out/gambit/
# build the gsc-boot* compiler
make -j$NIX_BUILD_CORES bootstrap
'';
installPhase = ''
cp -fa ./gsc-boot $out/gambit/
'';
forceShare = [ "info" ];
meta = gambit-support.meta // {
description = "Optimizing Scheme to C compiler, bootstrap step";
};
}

View file

@ -0,0 +1,121 @@
{ gccStdenv, lib, git, openssl, autoconf, pkgs, makeStaticLibraries, gcc, coreutils, gnused, gnugrep,
src, version, git-version,
gambit-support, optimizationSetting ? "-O1", gambit-params ? pkgs.gambit-support.stable-params }:
# Note that according to a benchmark run by Marc Feeley on May 2018,
# clang is 10x (with default settings) to 15% (with -O2) slower than GCC at compiling
# Gambit output, producing code that is 3x slower. IIRC the benchmarks from Gambit@30,
# the numbers were still heavily in favor of GCC in October 2019.
# Thus we use GCC over clang, even on macOS.
#
# Also note that I (fare) just ran benchmarks from https://github.com/ecraven/r7rs-benchmarks
# with Gambit 4.9.3 with -O1 vs -O2 vs -Os on Feb 2020. Which wins depends on the benchmark.
# The fight is unclear between -O1 and -O2, where -O1 wins more often, by up to 17%,
# but sometimes -O2 wins, once by up to 43%, so that overall -O2 is 5% faster.
# However, -Os seems more consistent in winning slightly against both -O1 and -O2,
# and is overall 15% faster than -O2. As for compile times, -O1 is fastest,
# -Os is about 29%-33% slower than -O1, while -O2 is about 40%-50% slower than -O1.
#
# Overall, -Os seems like the best choice, but I care more about compile-time,
# so I stick with -O1 (in the defaults above), which is also the default for Gambit.
gccStdenv.mkDerivation rec {
pname = "gambit";
inherit src version git-version;
bootstrap = gambit-support.gambit-bootstrap;
nativeBuildInputs = [ git autoconf ];
# TODO: if/when we can get all the library packages we depend on to have static versions,
# we could use something like (makeStaticLibraries openssl) to enable creation
# of statically linked binaries by gsc.
buildInputs = [ openssl ];
# TODO: patch gambit's source so it has the full path to sed, grep, fgrep? Is there more?
# Or wrap relevant programs to add a suitable PATH ?
#runtimeDeps = [ gnused gnugrep ];
# disable stackprotector on aarch64-darwin for now
# build error:
# ```
# /private/tmp/nix-build-gambit-unstable-2020-09-20.drv-0/ccIjyeeb.s:207:15: error: index must be an integer in range [-256, 255].
# ldr x2, [x2, ___stack_chk_guard];momd
# ^
# ```
hardeningDisable = lib.optionals (gccStdenv.isAarch64 && gccStdenv.isDarwin) [ "stackprotector" ];
configureFlags = [
"--enable-targets=${gambit-params.targets}"
"--enable-single-host"
"--enable-c-opt=${optimizationSetting}"
"--enable-gcc-opts"
"--enable-shared"
"--enable-absolute-shared-libs" # Yes, NixOS will want an absolute path, and fix it.
"--enable-openssl"
"--enable-default-runtime-options=${gambit-params.defaultRuntimeOptions}"
# "--enable-debug" # Nope: enables plenty of good stuff, but also the costly console.log
# "--enable-multiple-versions" # Nope, NixOS already does version multiplexing
# "--enable-guide"
# "--enable-track-scheme"
# "--enable-high-res-timing"
# "--enable-max-processors=4"
# "--enable-multiple-vms"
# "--enable-dynamic-tls"
# "--enable-multiple-threaded-vms" # when SMP branch is merged in
# "--enable-thread-system=posix" # default when --enable-multiple-vms is on.
# "--enable-profile"
# "--enable-coverage"
# "--enable-inline-jumps"
# "--enable-char-size=1" # default is 4
] ++
# due not enable poll on darwin due to https://github.com/gambit/gambit/issues/498
lib.optional (!gccStdenv.isDarwin) "--enable-poll";
configurePhase = ''
export CC=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc \
CXX=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}g++ \
CPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
CXXCPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
LD=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}ld \
XMKMF=${coreutils}/bin/false
unset CFLAGS LDFLAGS LIBS CPPFLAGS CXXFLAGS
${gambit-params.fix-stamp git-version}
./configure --prefix=$out/gambit ${builtins.concatStringsSep " " configureFlags}
# OS-specific paths are hardcoded in ./configure
substituteInPlace config.status \
--replace "/usr/local/opt/openssl@1.1" "${lib.getLib openssl}" \
--replace "/usr/local/opt/openssl" "${lib.getLib openssl}"
./config.status
'';
buildPhase = ''
# Make bootstrap compiler, from release bootstrap
mkdir -p boot
cp -rp ${bootstrap}/gambit/. boot/.
chmod -R u+w boot
cd boot
cp ../gsc/makefile.in ../gsc/*.scm gsc/
./configure
for i in lib gsi gsc ; do (cd $i ; make -j$NIX_BUILD_CORES) ; done
cd ..
cp boot/gsc/gsc gsc-boot
# Now use the bootstrap compiler to build the real thing!
make -j$NIX_BUILD_CORES from-scratch
${lib.optionalString gambit-params.modules "make -j$NIX_BUILD_CORES modules"}
'';
postInstall = ''
mkdir $out/bin
cd $out/bin
ln -s ../gambit/bin/* .
'';
doCheck = true;
meta = gambit-support.meta;
}

View file

@ -0,0 +1,10 @@
{ callPackage, fetchurl }:
callPackage ./build.nix rec {
version = "4.9.3";
git-version = version;
src = fetchurl {
url = "http://www.iro.umontreal.ca/~gambit/download/gambit/v4.9/source/gambit-v4_9_3.tgz";
sha256 = "1p6172vhcrlpjgia6hsks1w4fl8rdyjf9xjh14wxfkv7dnx8a5hk";
};
}

View file

@ -0,0 +1,39 @@
{ pkgs, lib }:
rec {
stable-params = {
stable = true;
defaultRuntimeOptions = "f8,-8,t8";
buildRuntimeOptions = "f8,-8,t8";
fix-stamp = git-version : "";
targets = "java,js,php,python,ruby";
modules = false;
};
unstable-params = {
stable = false;
defaultRuntimeOptions = "iL,fL,-L,tL";
buildRuntimeOptions = "i8,f8,-8,t8";
fix-stamp = git-version : ''
substituteInPlace configure \
--replace "$(grep '^PACKAGE_VERSION=.*$' configure)" 'PACKAGE_VERSION="v${git-version}"' \
--replace "$(grep '^PACKAGE_STRING=.*$' configure)" 'PACKAGE_STRING="Gambit v${git-version}"' ;
'';
targets = "arm,java,js,php,python,riscv-32,riscv-64,ruby,x86,x86-64"; # eats 100% cpu on _digest
modules = false;
};
export-gambopt = params : "export GAMBOPT=${params.buildRuntimeOptions} ;";
gambit-bootstrap = import ./bootstrap.nix ( pkgs );
meta = {
description = "Optimizing Scheme to C compiler";
homepage = "http://gambitscheme.org";
license = lib.licenses.lgpl21; # dual, also asl20
# NB regarding platforms: continuously tested on Linux,
# tested on macOS once in a while, *should* work everywhere.
platforms = lib.platforms.unix;
maintainers = with lib.maintainers; [ thoughtpolice raskin fare ];
};
}

View file

@ -0,0 +1,13 @@
{ callPackage, fetchFromGitHub, gambit-support }:
callPackage ./build.nix {
version = "unstable-2020-09-20";
git-version = "4.9.3-1234-g6acd87df";
src = fetchFromGitHub {
owner = "feeley";
repo = "gambit";
rev = "6acd87dfa95bfca33082a431e72f023345dc07ee";
sha256 = "0a3dy4ij8hzlp3sjam4b6dp6yvyz5d7g2x784qm3gp89fi2ck56r";
};
gambit-params = gambit-support.unstable-params;
}