* A function `useDietLibC' that returns a modified stdenv that uses
dietlibc to produce small, statically linked binaries. This stdenv also passes `-Os' to GCC automatically to optimise for size. It also tries to prevent builders from linking against dynamic libraries (which dietlibc doesn't support). * A function `addAttrsToDerivation' that returns a modified stdenv that always adds the specified attributes to the derivations that it produces. Example (from curl): curlDiet = import ../tools/networking/curl { inherit fetchurl zlib; stdenv = addAttrsToDerivation { CFLAGS = "-DHAVE_INET_NTOA_R_2_ARGS=1"; } (useDietLibC stdenv); }; (This is needed to get curl to build with dietlibc. Also note the stacking of stdenv-modifying functions.) * curl-diet: no longer necessary. svn path=/nixpkgs/trunk/; revision=6761
This commit is contained in:
parent
20d42ae673
commit
501ceef268
@ -1,13 +0,0 @@
|
|||||||
source $stdenv/setup
|
|
||||||
|
|
||||||
ensureDir "$(dirname $out/bin/diet)"
|
|
||||||
|
|
||||||
cat > $out/bin/gcc << END
|
|
||||||
#! $SHELL -e
|
|
||||||
export NIX_GLIBC_FLAGS_SET=1
|
|
||||||
exec $dietlibc/bin/diet $gcc/bin/gcc "\$@"
|
|
||||||
END
|
|
||||||
|
|
||||||
chmod +x $out/bin/gcc
|
|
||||||
|
|
||||||
ln -s $out/bin/gcc $out/bin/cc
|
|
@ -1,11 +0,0 @@
|
|||||||
{stdenv, dietlibc, gcc, langC ? true, langCC ? true, langF77 ? false}:
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = dietlibc.name;
|
|
||||||
|
|
||||||
builder = ./builder.sh;
|
|
||||||
|
|
||||||
inherit dietlibc gcc langC langCC langF77;
|
|
||||||
#NIX_GLIBC_FLAGS_SET=1;
|
|
||||||
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
diff -ruN curl-7.12.2/configure curl-7.12.2-new/configure
|
|
||||||
--- curl-7.12.2/configure 2004-10-18 00:22:10.000000000 +0200
|
|
||||||
+++ curl-7.12.2-new/configure 2004-12-09 13:58:57.670095179 +0100
|
|
||||||
@@ -6835,11 +6835,12 @@
|
|
||||||
if $ac_preproc_ok; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
- { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
|
|
||||||
-See \`config.log' for more details." >&5
|
|
||||||
-echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
|
|
||||||
-See \`config.log' for more details." >&2;}
|
|
||||||
- { (exit 1); exit 1; }; }
|
|
||||||
+ #{ { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check
|
|
||||||
+#See \`config.log' for more details." >&5
|
|
||||||
+#echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check
|
|
||||||
+#See \`config.log' for more details." >&2;}
|
|
||||||
+ #{ (exit 1); exit 1; }; }
|
|
||||||
+ :
|
|
||||||
fi
|
|
||||||
|
|
||||||
ac_ext=cc
|
|
@ -1,17 +0,0 @@
|
|||||||
{stdenv, fetchurl, zlib, sslSupport ? false, openssl ? null, dietgcc}:
|
|
||||||
|
|
||||||
assert sslSupport -> openssl != null;
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "curl-7.15.5";
|
|
||||||
src = fetchurl {
|
|
||||||
url = http://nix.cs.uu.nl/dist/tarballs/curl-7.15.5.tar.bz2;
|
|
||||||
md5 = "594142c7d53bbdd988e8cef6354eeeff";
|
|
||||||
};
|
|
||||||
buildInputs = [zlib (if sslSupport then openssl else null)];
|
|
||||||
patches = [./configure-cxxcpp.patch];
|
|
||||||
configureFlags = "--enable-shared=no" + (if sslSupport then "--with-ssl" else "--without-ssl");
|
|
||||||
NIX_GCC = dietgcc;
|
|
||||||
NIX_GLIBC_FLAGS_SET=1;
|
|
||||||
NIX_CFLAGS_COMPILE="-D_BSD_SOURCE=1 -DHAVE_INET_NTOA_R_2_ARGS=1";
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
source $stdenv/setup
|
|
||||||
|
|
||||||
if test "$sslSupport"; then
|
|
||||||
configureFlags="--with-ssl=$openssl"
|
|
||||||
else
|
|
||||||
configureFlags="--without-ssl"
|
|
||||||
fi
|
|
||||||
|
|
||||||
genericBuild
|
|
@ -4,12 +4,14 @@ assert sslSupport -> openssl != null;
|
|||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "curl-7.15.5";
|
name = "curl-7.15.5";
|
||||||
builder = ./builder.sh;
|
|
||||||
src = fetchurl {
|
src = fetchurl {
|
||||||
url = http://nix.cs.uu.nl/dist/tarballs/curl-7.15.5.tar.bz2;
|
url = http://nix.cs.uu.nl/dist/tarballs/curl-7.15.5.tar.bz2;
|
||||||
md5 = "594142c7d53bbdd988e8cef6354eeeff";
|
md5 = "594142c7d53bbdd988e8cef6354eeeff";
|
||||||
};
|
};
|
||||||
buildInputs = [zlib (if sslSupport then openssl else null)];
|
buildInputs = [zlib (if sslSupport then openssl else null)];
|
||||||
patches = [./configure-cxxcpp.patch];
|
patches = [./configure-cxxcpp.patch];
|
||||||
|
configureFlags = "
|
||||||
|
${if sslSupport then "--with-ssl=${openssl}" else "--without-ssl"}
|
||||||
|
";
|
||||||
inherit sslSupport openssl;
|
inherit sslSupport openssl;
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,9 @@ rec {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
addAttrsToDerivation = extraAttrs: stdenv: stdenv //
|
||||||
|
{ mkDerivation = args: stdenv.mkDerivation (args // extraAttrs); };
|
||||||
|
|
||||||
# Override the setup script of stdenv. Useful for testing new
|
# Override the setup script of stdenv. Useful for testing new
|
||||||
# versions of the setup script without causing a rebuild of
|
# versions of the setup script without causing a rebuild of
|
||||||
# everything.
|
# everything.
|
||||||
@ -71,6 +74,30 @@ rec {
|
|||||||
# };
|
# };
|
||||||
overrideSetup = stdenv: setup: stdenv.regenerate setup;
|
overrideSetup = stdenv: setup: stdenv.regenerate setup;
|
||||||
|
|
||||||
|
# Return a modified stdenv that uses dietlibc to create small
|
||||||
|
# statically linked binaries.
|
||||||
|
useDietLibC = stdenv: stdenv //
|
||||||
|
{ mkDerivation = args: stdenv.mkDerivation (args // {
|
||||||
|
NIX_CFLAGS_LINK = "-static";
|
||||||
|
|
||||||
|
# These are added *after* the command-line flags, so we'll
|
||||||
|
# always optimise for size.
|
||||||
|
NIX_CFLAGS_COMPILE = "-Os -s";
|
||||||
|
|
||||||
|
configureFlags =
|
||||||
|
(if args ? configureFlags then args.configureFlags else "")
|
||||||
|
+ " --disable-shared"; # brrr...
|
||||||
|
|
||||||
|
NIX_GCC = import ../build-support/gcc-wrapper {
|
||||||
|
inherit stdenv binutils;
|
||||||
|
gcc = gcc.gcc;
|
||||||
|
glibc = dietlibc;
|
||||||
|
nativeTools = false;
|
||||||
|
nativeGlibc = false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
# Applying this to an attribute set will cause nix-env to look
|
# Applying this to an attribute set will cause nix-env to look
|
||||||
# inside the set for derivations.
|
# inside the set for derivations.
|
||||||
recurseIntoAttrs = attrs: attrs // {recurseForDerivations = true;};
|
recurseIntoAttrs = attrs: attrs // {recurseForDerivations = true;};
|
||||||
@ -196,8 +223,9 @@ rec {
|
|||||||
|
|
||||||
curl = if stdenv ? curl then stdenv.curl else (assert false; null);
|
curl = if stdenv ? curl then stdenv.curl else (assert false; null);
|
||||||
|
|
||||||
curlDiet = import ../tools/networking/curl-diet {
|
curlDiet = import ../tools/networking/curl {
|
||||||
inherit fetchurl stdenv zlib dietgcc;
|
inherit fetchurl zlib;
|
||||||
|
stdenv = addAttrsToDerivation {CFLAGS = "-DHAVE_INET_NTOA_R_2_ARGS=1";} (useDietLibC stdenv);
|
||||||
};
|
};
|
||||||
|
|
||||||
dhcp = import ../tools/networking/dhcp {
|
dhcp = import ../tools/networking/dhcp {
|
||||||
@ -1988,11 +2016,6 @@ rec {
|
|||||||
# arch = "arm";
|
# arch = "arm";
|
||||||
#};
|
#};
|
||||||
|
|
||||||
dietlibcWrapper = import ../os-specific/linux/dietlibc-wrapper {
|
|
||||||
inherit stdenv dietlibc;
|
|
||||||
gcc = stdenv.gcc;
|
|
||||||
};
|
|
||||||
|
|
||||||
e2fsprogs = import ../os-specific/linux/e2fsprogs {
|
e2fsprogs = import ../os-specific/linux/e2fsprogs {
|
||||||
inherit fetchurl stdenv gettext;
|
inherit fetchurl stdenv gettext;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user