Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

klibc: Update, simplify build

This included adding a trivial kernelHeaders kernelPackage as well.

Signed-off-by: Shea Levy <shea@shealevy.com>
  • Loading branch information...
commit 7c6612cfc0e9e1110c925dfe7d2173231441ed1b 1 parent 5e1e4d0
@shlevy authored
View
21 pkgs/os-specific/linux/kernel-headers/default.nix
@@ -0,0 +1,21 @@
+{ stdenv, kernel, perl }:
+
+stdenv.mkDerivation {
+ name = "linux-headers-${kernel.version}";
+
+ inherit (stdenv.platform) kernelArch;
+
+ nativeBuildInputs = [ perl ];
+
+ crossAttrs = {
+ inherit (stdenv.cross.platform) kernelArch;
+ };
+
+ buildCommand = ''
+ make -C ${kernel.sourceRoot} ARCH=$kernelArch INSTALL_HDR_PATH=$out O=$PWD headers_install
+ find $out \( -name ..install.cmd -o -name .install \) -print0 | xargs -0 rm
+ '';
+
+ # Headers shouldn't reference anything else
+ allowedReferences = [];
+}
View
85 pkgs/os-specific/linux/klibc/default.nix
@@ -1,67 +1,52 @@
-{ stdenv, fetchurl, perl, bison, mktemp, linuxHeaders, linuxHeadersCross, kernelDev ? null }:
-
-assert stdenv.isLinux;
+{ stdenv, fetchurl, kernelHeaders, kernel, perl }:
let
- version = "1.5.24";
- baseMakeFlags = ["V=1" "prefix=$out" "SHLIBDIR=$out/lib"];
-in
+ version = "2.0.2";
-stdenv.mkDerivation {
- name = "klibc-${version}${stdenv.lib.optionalString (kernelDev != null) "-${kernelDev.version}"}";
+ commonMakeFlags = [
+ "prefix=$(out)"
+ "SHLIBDIR=$(out)/lib"
+ ];
+in stdenv.mkDerivation {
+ name = "klibc-${version}-${kernel.version}";
src = fetchurl {
- url = "mirror://kernel/linux/libs/klibc/1.5/klibc-${version}.tar.bz2";
- sha256 = "18lm32dlj9k2ky9wwk274zmc3jndgrb41b6qm82g3lza6wlw3yki";
+ url = "mirror://kernel/linux/libs/klibc/2.0/klibc-${version}.tar.xz";
+ sha256 = "1e9d4ba6fe2aeea0bd27d14a9a674c29fb7cf766ff021e9c5f99256cb409474e";
};
- # Trick to make this build on nix. It expects to have the kernel sources
- # instead of only the linux kernel headers.
- # So it cannot run the 'make headers_install' it wants to run.
- # We don't install the headers, so klibc will not be useful as libc, but
- # usually in nixpkgs we only use the userspace tools comming with klibc.
- prePatch = stdenv.lib.optionalString (kernelDev == null) ''
- sed -i -e /headers_install/d scripts/Kbuild.install
+ nativeBuildInputs = [ perl ];
+
+ inherit kernelHeaders;
+
+ patches = [ ./readonly-kernel-source.patch ];
+
+ configurePhase = ''
+ ln -sv $kernelHeaders linux
'';
-
- makeFlags = baseMakeFlags;
- inherit linuxHeaders;
+ makeFlags = commonMakeFlags ++ [
+ "KLIBCARCH=${stdenv.platform.kernelArch}"
+ ];
+
+ installFlags = [
+ "KLIBCKERNELSRC=${kernel.sourceRoot}"
+ ];
crossAttrs = {
- makeFlags = baseMakeFlags ++ [ "CROSS_COMPILE=${stdenv.cross.config}-"
- "KLIBCARCH=${stdenv.cross.arch}" ];
+ makeFlags = commonMakeFlags ++ [
+ "KLIBCARCH=${stdenv.cross.platform.kernelArch}"
+ "CROSS_COMPILE=${stdenv.cross.config}-"
+ ] ++ stdenv.lib.optional (stdenv.cross.arch == "arm") "CONFIG_AEABI=y";
- patchPhase = ''
- sed -i 's/-fno-pic -mno-abicalls/& -mabi=32/' usr/klibc/arch/mips/MCONFIG
- sed -i /KLIBCKERNELSRC/d scripts/Kbuild.install
- # Wrong check for __mips64 in klibc
- sed -i s/__mips64__/__mips64/ usr/include/fcntl.h
- '';
+ installFlags = [
+ "KLIBCARCH=${stdenv.cross.platform.kernelArch}"
+ "KLIBCKERNELSRC=${kernel.crossDrv.sourceRoot}"
+ ];
- linuxHeaders = linuxHeadersCross;
+ kernelHeaders = kernelHeaders.crossDrv;
};
-
- # The AEABI option concerns only arm systems, and does not affect the build for
- # other systems.
- preBuild = ''
- sed -i /CONFIG_AEABI/d defconfig
- echo "CONFIG_AEABI=y" >> defconfig
- makeFlags=$(eval "echo $makeFlags")
- '' + (if kernelDev == null then ''
- mkdir linux
- cp -prsd $linuxHeaders/include linux/
- chmod -R u+w linux/include/
- '' else ''
- tar xvf ${kernelDev.src}
- mv linux* linux
- cd linux
- ln -sv ${kernelDev}/config .config
- make prepare
- cd ..
- '');
-
# Install static binaries as well.
postInstall = ''
dir=$out/lib/klibc/bin.static
@@ -69,6 +54,4 @@ stdenv.mkDerivation {
cp $(find $(find . -name static) -type f ! -name "*.g" -a ! -name ".*") $dir/
cp usr/dash/sh $dir/
'';
-
- nativeBuildInputs = [ perl bison mktemp ];
}
View
12 pkgs/os-specific/linux/klibc/readonly-kernel-source.patch
@@ -0,0 +1,12 @@
+diff -Naur klibc-2.0.2-orig/scripts/Kbuild.install klibc-2.0.2/scripts/Kbuild.install
+--- klibc-2.0.2-orig/scripts/Kbuild.install 2012-10-03 12:41:43.000000000 -0400
++++ klibc-2.0.2/scripts/Kbuild.install 2013-03-25 19:56:44.287154530 -0400
+@@ -95,7 +95,7 @@
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)lib
+ $(Q)mkdir -p $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)bin
+- $(Q)$(MAKE) -C $(KLIBCKERNELSRC) ARCH=$(KLIBCARCH) INSTALL_HDR_PATH=$(INSTALLROOT)$(INSTALLDIR)/$(KCROSS) headers_install
++ $(Q)$(MAKE) -C $(KLIBCKERNELSRC) ARCH=$(KLIBCARCH) INSTALL_HDR_PATH=$(INSTALLROOT)$(INSTALLDIR)/$(KCROSS) O=$(TMPDIR) headers_install
+ $(Q)cp -rf usr/include/. $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include/.
+ $(Q)chmod -R a+rX $(INSTALLROOT)$(INSTALLDIR)/$(KCROSS)include
+ $(Q)$(install-data) $(srctree)/klcc/klcc.1 $(INSTALLROOT)$(mandir)/man1/$(KCROSS)klcc.1
View
10 pkgs/top-level/all-packages.nix
@@ -5999,9 +5999,9 @@ let
kqemu = callPackage ../os-specific/linux/kqemu { };
- klibc = callPackage ../os-specific/linux/klibc {
- linuxHeaders = glibc.kernelHeaders;
- };
+ kernelHeaders = callPackage ../os-specific/linux/kernel-headers { };
+
+ klibc = callPackage ../os-specific/linux/klibc { };
splashutils = let hasFbConDecor = if self.kernel ? features
then self.kernel.features ? fbConDecor
@@ -6073,9 +6073,7 @@ let
lsiutil = callPackage ../os-specific/linux/lsiutil { };
- klibc = callPackage ../os-specific/linux/klibc {
- linuxHeaders = glibc.kernelHeaders;
- };
+ klibc = linuxPackages.klibc;
klibcShrunk = callPackage ../os-specific/linux/klibc/shrunk.nix { };
View
1  pkgs/top-level/platforms.nix
@@ -2,6 +2,7 @@ rec {
pcBase = {
name = "pc";
uboot = null;
+ kernelMajor = "2.6";
kernelHeadersBaseConfig = "defconfig";
kernelBaseConfig = "defconfig";
# Build whatever possible as a module, if not stated in the extra config.
Please sign in to comment.
Something went wrong with that request. Please try again.