From 1b29d29c7610402cb278130f12b27900bb5a99f0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 6 Dec 2012 15:51:52 +0000 Subject: [PATCH 01/47] First movement to get the raspberrypi stdenv building. --- .../development/compilers/gcc/4.6/default.nix | 4 +- .../libraries/glibc/2.13/common.nix | 18 +++- .../libraries/glibc/2.13/default.nix | 3 +- pkgs/stdenv/default.nix | 1 + pkgs/stdenv/generic/default.nix | 2 + pkgs/stdenv/linux/default.nix | 13 ++- pkgs/top-level/platforms.nix | 98 +++++++++++++++++++ 7 files changed, 131 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index e27f1a47f9c1..bcdde3ec8701 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -294,7 +294,9 @@ stdenv.mkDerivation ({ ${if langAda then " --enable-libada" else ""} ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} - "; + " + (if (cross == null && stdenv.platform.name == "raspberrypi") then + "--with-arch=armv6 --with-fpu=vfp --with-float=hard --with-mode=arm" else ""); + # ^ This above is out of "" because we don't want to rebuild stdenv in other archs targetConfig = if (cross != null) then cross.config else null; diff --git a/pkgs/development/libraries/glibc/2.13/common.nix b/pkgs/development/libraries/glibc/2.13/common.nix index 2333e42246b0..316c66c51900 100644 --- a/pkgs/development/libraries/glibc/2.13/common.nix +++ b/pkgs/development/libraries/glibc/2.13/common.nix @@ -8,7 +8,7 @@ cross : , machHeaders ? null, hurdHeaders ? null, libpthreadHeaders ? null , mig ? null, fetchgit ? null , profilingLibraries ? false, meta -, preConfigure ? "", ... }@args : +, preConfigure ? "", recentGcc ? true, ... }@args : let # For GNU/Hurd, see below. @@ -120,11 +120,21 @@ stdenv.mkDerivation ({ && cross.platform.kernelMajor == "2.6") [ "--enable-kernel=2.6.0" "--with-__thread" - ] ++ stdenv.lib.optionals stdenv.isArm [ + ] ++ stdenv.lib.optionals (cross == null && + (stdenv.system == "armv5tel-linux") || + (!recentGcc && stdenv.platform.name == "raspberrypi")) [ "--host=arm-linux-gnueabi" "--build=arm-linux-gnueabi" "--without-fp" + # To avoid linking with -lgcc_s (dynamic link) + # so the glibc does not depend on its compiler store path + "libc_cv_as_needed=no" + ] ++ stdenv.lib.optionals (cross == null && recentGcc && stdenv.platform.name == "raspberrypi") [ + "--host=arm-linux-gnueabihf" + "--build=arm-linux-gnueabihf" + "--with-fp" + # To avoid linking with -lgcc_s (dynamic link) # so the glibc does not depend on its compiler store path "libc_cv_as_needed=no" @@ -192,6 +202,10 @@ stdenv.mkDerivation ({ configureScript="`pwd`/../$sourceRoot/configure" ${preConfigure} + '' + stdenv.lib.optionalString (cross == null + && recentGcc + && stdenv.platform.name == "raspberrypi") '' + configureFlagsArray=("CFLAGS=-march=armv6 -mfpu=vfp -mhard-float") ''; meta = { diff --git a/pkgs/development/libraries/glibc/2.13/default.nix b/pkgs/development/libraries/glibc/2.13/default.nix index f80ed9372e63..59f8ca647e6f 100644 --- a/pkgs/development/libraries/glibc/2.13/default.nix +++ b/pkgs/development/libraries/glibc/2.13/default.nix @@ -5,6 +5,7 @@ , profilingLibraries ? false , gccCross ? null , debugSymbols ? false +, recentGcc ? true }: assert stdenv.gcc.gcc != null; @@ -19,7 +20,7 @@ in + stdenv.lib.optionalString debugSymbols "-debug"; inherit fetchurl stdenv kernelHeaders installLocales profilingLibraries - gccCross; + gccCross recentGcc; builder = ./builder.sh; diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 8e0da288eec7..3c75597afca9 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -55,6 +55,7 @@ rec { if stdenvType == "i686-linux" then stdenvLinux else if stdenvType == "x86_64-linux" then stdenvLinux else if stdenvType == "armv5tel-linux" then stdenvLinux else + if stdenvType == "armv6l-linux" then stdenvLinux else if stdenvType == "armv7l-linux" then stdenvLinux else if stdenvType == "mips64el-linux" then stdenvLinux else if stdenvType == "powerpc-linux" then /* stdenvLinux */ stdenvNative else diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 20cbb1b455ca..ea101ddb075c 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -87,6 +87,7 @@ let || result.system == "x86_64-linux" || result.system == "powerpc-linux" || result.system == "armv5tel-linux" + || result.system == "armv6l-linux" || result.system == "armv7l-linux" || result.system == "mips64el-linux"; isGNU = result.system == "i686-gnu"; # GNU/Hurd @@ -120,6 +121,7 @@ let isMips = result.system == "mips-linux" || result.system == "mips64el-linux"; isArm = result.system == "armv5tel-linux" + || result.system == "armv6l-linux" || result.system == "armv7l-linux"; # Utility function: allow stdenv to be easily regenerated with diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 3105e76f8177..6a202951c7c1 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -16,6 +16,7 @@ rec { else if system == "x86_64-linux" then import ./bootstrap/x86_64 else if system == "powerpc-linux" then import ./bootstrap/powerpc else if system == "armv5tel-linux" then import ./bootstrap/armv5tel + else if system == "armv6l-linux" then import ./bootstrap/armv5tel else if system == "armv7l-linux" then import ./bootstrap/armv5tel else if system == "mips64el-linux" then import ./bootstrap/loongson2f else abort "unsupported platform for the pure Linux stdenv"; @@ -57,7 +58,7 @@ rec { builder = bootstrapFiles.sh; args = - if system == "armv5tel-linux" + if (system == "armv5tel-linux" || system == "arm6l-linux") then [ ./scripts/unpack-bootstrap-tools-arm.sh ] else [ ./scripts/unpack-bootstrap-tools.sh ]; @@ -189,7 +190,7 @@ rec { # 5) Build Glibc with the bootstrap tools. The result is the full, # dynamically linked, final Glibc. - stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc; + stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc.override { recentGcc = false; }; # 6) Construct a third stdenv identical to the 2nd, except that @@ -201,19 +202,23 @@ rec { coreutils = bootstrapTools; libc = stdenvLinuxGlibc; }; - overrides = pkgs: { + overrides = pkgs: ({ glibc = stdenvLinuxGlibc; inherit (stdenvLinuxBoot1Pkgs) perl; + } // (if (platform ? name && platform.name != "raspberrypi") then { # Link GCC statically against GMP etc. This makes sense because # these builds of the libraries are only used by GCC, so it # reduces the size of the stdenv closure. + + # On raspberry pi we can't do that, because libgcc/libstdc++ are made + # without hardfp, and can't be linked with the new hardfp code in gcc. gmp = pkgs.gmp.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; mpfr = pkgs.mpfr.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; mpc = pkgs.mpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; isl = pkgs.isl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; cloog = pkgs.cloog.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; - }; + } else {})); inherit fetchurl; }; diff --git a/pkgs/top-level/platforms.nix b/pkgs/top-level/platforms.nix index f00ad36f2e47..c53b41958a45 100644 --- a/pkgs/top-level/platforms.nix +++ b/pkgs/top-level/platforms.nix @@ -126,6 +126,104 @@ rec { ubootConfig = "sheevaplug_config"; }; + raspberrypi = { + name = "raspberrypi"; + kernelMajor = "2.6"; + kernelHeadersBaseConfig = "kirkwood_defconfig"; + kernelBaseConfig = "bcmrpi_defconfig"; + kernelArch = "arm"; + kernelAutoModules = false; + kernelExtraConfig = + '' + BLK_DEV_RAM y + BLK_DEV_INITRD y + BLK_DEV_CRYPTOLOOP m + BLK_DEV_DM m + DM_CRYPT m + MD y + REISERFS_FS m + BTRFS_FS m + XFS_FS m + JFS_FS m + EXT4_FS m + USB_STORAGE_CYPRESS_ATACB m + + # mv cesa requires this sw fallback, for mv-sha1 + CRYPTO_SHA1 y + + IP_PNP y + IP_PNP_DHCP y + NFS_FS y + ROOT_NFS y + TUN m + NFS_V4 y + NFS_V4_1 y + NFS_FSCACHE y + NFSD m + NFSD_V2_ACL y + NFSD_V3 y + NFSD_V3_ACL y + NFSD_V4 y + NETFILTER y + IP_NF_IPTABLES y + IP_NF_FILTER y + IP_NF_MATCH_ADDRTYPE y + IP_NF_TARGET_LOG y + IP_NF_MANGLE y + IPV6 m + VLAN_8021Q m + + CIFS y + CIFS_XATTR y + CIFS_POSIX y + CIFS_FSCACHE y + CIFS_ACL y + + WATCHDOG y + WATCHDOG_CORE y + ORION_WATCHDOG m + + ZRAM m + NETCONSOLE m + + # Fail to build + DRM n + SCSI_ADVANSYS n + USB_ISP1362_HCD n + SND_SOC n + SND_ALI5451 n + FB_SAVAGE n + SCSI_NSP32 n + ATA_SFF n + SUNGEM n + IRDA n + ATM_HE n + SCSI_ACARD n + BLK_DEV_CMD640_ENHANCED n + + FUSE_FS m + + # nixos mounts some cgroup + CGROUPS y + + # Latencytop + LATENCYTOP y + + # Ubi for the mtd + MTD_UBI y + UBIFS_FS y + UBIFS_FS_XATTR y + UBIFS_FS_ADVANCED_COMPR y + UBIFS_FS_LZO y + UBIFS_FS_ZLIB y + UBIFS_FS_DEBUG n + ''; + kernelTarget = "uImage"; + uboot = "sheevaplug"; + # Only for uboot = uboot : + ubootConfig = "sheevaplug_config"; + }; + guruplug = sheevaplug // { # Define `CONFIG_MACH_GURUPLUG' (see # ) From a30086c8d520cf9e0725a7dea74895f92c152078 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Dec 2012 15:13:39 +0000 Subject: [PATCH 02/47] Disabling ppl and cloog on gcc for raspberrypi. Shorter stdenv builds. --- pkgs/stdenv/linux/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 6a202951c7c1..d8b404cc7761 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -239,7 +239,8 @@ rec { inherit (stdenvLinuxBoot3Pkgs) binutils; coreutils = bootstrapTools; libc = stdenvLinuxGlibc; - gcc = stdenvLinuxBoot3Pkgs.gcc.gcc; + gcc = stdenvLinuxBoot3Pkgs.gcc.gcc.override (if platform.name == "raspberrypi" then + { ppl = null; cloog = null; } else {}); name = ""; }; extraPath = [ stdenvLinuxBoot3Pkgs.xz ]; @@ -278,7 +279,7 @@ rec { inherit (stdenvLinuxBoot3Pkgs) binutils; inherit (stdenvLinuxBoot4Pkgs) coreutils; libc = stdenvLinuxGlibc; - gcc = stdenvLinuxBoot3Pkgs.gcc.gcc; + gcc = stdenvLinuxBoot4.gcc.gcc; shell = stdenvLinuxBoot4Pkgs.bash + "/bin/bash"; name = ""; }; From 32c061146de6a5241cea9d710457f5c04040d3ae Mon Sep 17 00:00:00 2001 From: root Date: Fri, 7 Dec 2012 15:14:04 +0000 Subject: [PATCH 03/47] Making gcc use some extra flags to build the proper hardfp gcc. This commit breaks non-raspberrypi; just testing. --- pkgs/development/compilers/gcc/4.6/builder.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh index 2f655ece1703..f4b3758c7c13 100644 --- a/pkgs/development/compilers/gcc/4.6/builder.sh +++ b/pkgs/development/compilers/gcc/4.6/builder.sh @@ -97,6 +97,7 @@ if test "$noSysDirs" = "1"; then glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib" extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags" + extraFlags="-mcpu=armv6 -mfpu=vfp -mhard-float -marm $extraFlags" extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" EXTRA_TARGET_CFLAGS="$extraFlags" From 43fc5ae7cf38932d5b1f6962abfcfc03491a124c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 7 Dec 2012 16:26:38 +0000 Subject: [PATCH 04/47] Trying to fix the gcc builder; I added pi flags in the wrong if/else branch. --- pkgs/development/compilers/gcc/4.6/builder.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh index f4b3758c7c13..5012c76650f4 100644 --- a/pkgs/development/compilers/gcc/4.6/builder.sh +++ b/pkgs/development/compilers/gcc/4.6/builder.sh @@ -75,7 +75,11 @@ if test "$noSysDirs" = "1"; then fi else if test -z "$NIX_GCC_CROSS"; then - EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" + if $system == "armv6l-linux"; then + EXTRA_TARGET_CFLAGS="-mcpu=armv6 -mfpu=vfp -mhard-float -marm $EXTRA_FLAGS" + else + EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" + fi EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" else # This the case of cross-building the gcc. @@ -97,7 +101,6 @@ if test "$noSysDirs" = "1"; then glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib" extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags" - extraFlags="-mcpu=armv6 -mfpu=vfp -mhard-float -marm $extraFlags" extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" EXTRA_TARGET_CFLAGS="$extraFlags" From b520b4aeee76e345916c87f01d1d9f4dbc78688e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 7 Dec 2012 17:05:12 +0000 Subject: [PATCH 05/47] Fixing my bash scripting of the previous commit --- pkgs/development/compilers/gcc/4.6/builder.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh index 5012c76650f4..b596e0edbd7f 100644 --- a/pkgs/development/compilers/gcc/4.6/builder.sh +++ b/pkgs/development/compilers/gcc/4.6/builder.sh @@ -75,7 +75,7 @@ if test "$noSysDirs" = "1"; then fi else if test -z "$NIX_GCC_CROSS"; then - if $system == "armv6l-linux"; then + if [ $system == "armv6l-linux" ]; then EXTRA_TARGET_CFLAGS="-mcpu=armv6 -mfpu=vfp -mhard-float -marm $EXTRA_FLAGS" else EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" From 9fdd9d51bd183bf5deeb26dd3490590b7022674e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Mon, 10 Dec 2012 21:55:16 +0000 Subject: [PATCH 06/47] Setting some kind of cross-compiler situation, for armv6l gnueabihf. --- pkgs/development/compilers/gcc/4.6/builder.sh | 14 +++++++------- pkgs/development/compilers/gcc/4.6/default.nix | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh index b596e0edbd7f..e6e7542b6ac6 100644 --- a/pkgs/development/compilers/gcc/4.6/builder.sh +++ b/pkgs/development/compilers/gcc/4.6/builder.sh @@ -248,12 +248,12 @@ postInstall() { } -if test -z "$targetConfig" && test -z "$crossConfig"; then - if test -z "$profiledCompiler"; then - buildFlags="bootstrap $buildFlags" - else - buildFlags="profiledbootstrap $buildFlags" - fi -fi +#if test -z "$targetConfig" && test -z "$crossConfig"; then +# if test -z "$profiledCompiler"; then +# buildFlags="bootstrap $buildFlags" +# else +# buildFlags="profiledbootstrap $buildFlags" +# fi +#fi genericBuild diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index bcdde3ec8701..52cc1f9ec94f 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -295,7 +295,7 @@ stdenv.mkDerivation ({ ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} " + (if (cross == null && stdenv.platform.name == "raspberrypi") then - "--with-arch=armv6 --with-fpu=vfp --with-float=hard --with-mode=arm" else ""); + "--with-arch=armv6 --with-fpu=vfp --with-float=hard --with-mode=arm --build=armv6l-linux-gnueabi --host=armv6l-linux-gnueabihf" else ""); # ^ This above is out of "" because we don't want to rebuild stdenv in other archs targetConfig = if (cross != null) then cross.config else null; From fc51895afecc50327353f273351f8c46f88433a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 20 Dec 2012 20:08:11 +0100 Subject: [PATCH 07/47] Get gccs understand 'fpu' --- pkgs/development/compilers/gcc/4.6/default.nix | 3 +++ pkgs/development/compilers/gcc/4.7/default.nix | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index 52cc1f9ec94f..38773fba973d 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -91,9 +91,11 @@ let version = "4.6.3"; gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross; gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; + gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross; withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; + withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; crossMingw = (cross != null && cross.libc == "msvcrt"); crossConfigureFlags = @@ -101,6 +103,7 @@ let version = "4.6.3"; withArch + withCpu + withAbi + + withFpu + (if (crossMingw && crossStageStatic) then " --with-headers=${libcCross}/include" + " --with-gcc" + diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index 60ef44f2a901..0d24f19e3c30 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -89,9 +89,11 @@ let version = "4.7.2"; gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross; gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; + gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross; withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; + withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; crossMingw = (cross != null && cross.libc == "msvcrt"); crossConfigureFlags = @@ -99,6 +101,7 @@ let version = "4.7.2"; withArch + withCpu + withAbi + + withFpu + (if (crossMingw && crossStageStatic) then " --with-headers=${libcCross}/include" + " --with-gcc" + From 5b975f3c90e541bd807e825a45d693f769b7b027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 12:17:06 +0100 Subject: [PATCH 08/47] Adding an attempt to crossbuild bootstrap tools for the pi. Based on the cross/make-bootstrap-tools.nix I had for the sheevaplug in my nixos.org svn configuration directory. --- .../linux/make-bootstrap-tools-crosspi.nix | 256 ++++++++++++++++++ 1 file changed, 256 insertions(+) create mode 100644 pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix new file mode 100644 index 000000000000..061e5f35528a --- /dev/null +++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix @@ -0,0 +1,256 @@ +{system ? builtins.currentSystem}: + +let + pkgsFun = import ; # The root nixpkgs default.nix + pkgsNoParams = pkgsFun {}; + raspberrypiCrossSystem = { + crossSystem = { + config = "armv6l-unknown-linux-gnueabi"; + bigEndian = false; + arch = "arm"; + float = "hard"; + fpu = "vfp"; + withTLS = true; + libc = "glibc"; + platform = pkgsNoParams.platforms.raspberrypi; + openssl.system = "linux-generic32"; + gcc = { + arch = "armv6"; + fpu = "vfp"; + float = "hard"; + }; + }; + }; + + raspberrypiCrossSystemUclibc = { + crossSystem = { + config = "armv6l-unknown-linux-gnueabi"; + bigEndian = false; + arch = "arm"; + float = "hard"; + fpu = "vfp"; + withTLS = true; + libc = "uclibc"; + platform = pkgsNoParams.platforms.raspberrypi; + openssl.system = "linux-generic32"; + gcc = { + arch = "armv6"; + fpu = "vfp"; + float = "hard"; + }; + uclibc.extraConfig = '' + ARCH_WANTS_BIG_ENDIAN n + ARCH_BIG_ENDIAN n + ARCH_WANTS_LITTLE_ENDIAN y + ARCH_LITTLE_ENDIAN y + ''; + }; + }; + + pkgsuclibc = pkgsFun ({inherit system;} // raspberrypiCrossSystemUclibc); + pkgs = pkgsFun ({inherit system;} // raspberrypiCrossSystem); + + inherit (pkgs) stdenv nukeReferences cpio binutilsCross; + + # We want coreutils without ACL support. + coreutils_base = pkgs.coreutils.override (args: { + aclSupport = false; + }); + + coreutils_ = coreutils_base.hostDrv; + + glibc = pkgs.libcCross; + bash = pkgs.bash.hostDrv; + findutils = pkgs.findutils.hostDrv; + diffutils = pkgs.diffutils.hostDrv; + gnused = pkgs.gnused.hostDrv; + gnugrep = pkgs.gnugrep.hostDrv; + gawk = pkgs.gawk.hostDrv; + gnutar = pkgs.gnutar.hostDrv; + gzip = pkgs.gzip.hostDrv; + bzip2 = pkgs.bzip2.hostDrv; + gnumake = pkgs.gnumake.hostDrv; + patch = pkgs.patch.hostDrv; + patchelf = pkgs.patchelf.hostDrv; + replace = pkgs.replace.hostDrv; + gcc = pkgs.gcc; + gmp = pkgs.gmp.hostDrv; + mpfr = pkgs.mpfr.hostDrv; + #ppl = pkgs.ppl.hostDrv; + #cloogppl = pkgs.cloogppl.hostDrv; + binutils = pkgs.binutils.hostDrv; + klibc = pkgs.klibc.hostDrv; + +in + +rec { + + curlStatic = import { + stdenv = pkgsuclibc.stdenv; + inherit (pkgsuclibc) fetchurl; + zlibSupport = false; + sslSupport = false; + linkStatic = true; + }; + + bzip2Static = import { + stdenv = pkgsuclibc.stdenv; + inherit (pkgsuclibc) fetchurl; + linkStatic = true; + }; + + build = + + stdenv.mkDerivation { + name = "build"; + + buildInputs = [nukeReferences cpio binutilsCross]; + + crossConfig = stdenv.cross.config; + + buildCommand = '' + set -x + ensureDir $out/bin $out/lib $out/libexec + + # Copy what we need of Glibc. + cp -d ${glibc}/lib/ld-*.so* $out/lib + cp -d ${glibc}/lib/libc*.so* $out/lib + cp -d ${glibc}/lib/libc_nonshared.a $out/lib + cp -d ${glibc}/lib/libm*.so* $out/lib + cp -d ${glibc}/lib/libdl*.so* $out/lib + cp -d ${glibc}/lib/librt*.so* $out/lib + cp -d ${glibc}/lib/libpthread*.so* $out/lib + cp -d ${glibc}/lib/libnsl*.so* $out/lib + cp -d ${glibc}/lib/libutil*.so* $out/lib + cp -d ${glibc}/lib/crt?.o $out/lib + + cp -rL ${glibc}/include $out + chmod -R u+w $out/include + + # Hopefully we won't need these. + rm -rf $out/include/mtd $out/include/rdma $out/include/sound $out/include/video + find $out/include -name .install -exec rm {} \; + find $out/include -name ..install.cmd -exec rm {} \; + mv $out/include $out/include-glibc + + # Copy coreutils, bash, etc. + cp ${coreutils_}/bin/* $out/bin + (cd $out/bin && rm vdir dir sha*sum pinky factor pathchk runcon shuf who whoami shred users) + + cp ${bash}/bin/bash $out/bin + cp ${findutils}/bin/find $out/bin + cp ${findutils}/bin/xargs $out/bin + cp -d ${diffutils}/bin/* $out/bin + cp -d ${gnused}/bin/* $out/bin + cp -d ${gnugrep}/bin/* $out/bin + cp ${gawk}/bin/gawk $out/bin + cp -d ${gawk}/bin/awk $out/bin + cp ${gnutar}/bin/tar $out/bin + cp ${gzip}/bin/gzip $out/bin + cp ${bzip2}/bin/bzip2 $out/bin + cp -d ${gnumake}/bin/* $out/bin + cp -d ${patch}/bin/* $out/bin + cp ${patchelf}/bin/* $out/bin + cp ${replace}/bin/* $out/bin + + cp -d ${gnugrep.pcre.hostDrv}/lib/libpcre*.so* $out/lib # needed by grep + + # Copy what we need of GCC. + cp -d ${gcc.gcc.hostDrv}/bin/gcc $out/bin + cp -d ${gcc.gcc.hostDrv}/bin/cpp $out/bin + cp -d ${gcc.gcc.hostDrv}/bin/g++ $out/bin + cp -d ${gcc.gcc.hostDrv}/lib*/libgcc_s.so* $out/lib + cp -d ${gcc.gcc.hostDrv}/lib*/libstdc++.so* $out/lib + cp -rd ${gcc.gcc.hostDrv}/lib/gcc $out/lib + chmod -R u+w $out/lib + rm -f $out/lib/gcc/*/*/include*/linux + rm -f $out/lib/gcc/*/*/include*/sound + rm -rf $out/lib/gcc/*/*/include*/root + rm -f $out/lib/gcc/*/*/include-fixed/asm + rm -rf $out/lib/gcc/*/*/plugin + #rm -f $out/lib/gcc/*/*/*.a + cp -rd ${gcc.gcc.hostDrv}/libexec/* $out/libexec + mkdir $out/include + cp -rd ${gcc.gcc.hostDrv}/include/c++ $out/include + chmod -R u+w $out/include + rm -rf $out/include/c++/*/ext/pb_ds + rm -rf $out/include/c++/*/ext/parallel + + cp -d ${gmp}/lib/libgmp*.so* $out/lib + cp -d ${mpfr}/lib/libmpfr*.so* $out/lib + + # Copy binutils. + for i in as ld ar ranlib nm strip readelf objdump; do + cp ${binutils}/bin/$i $out/bin + done + + chmod -R u+w $out + + # Strip executables even further. + for i in $out/bin/* $out/libexec/gcc/*/*/*; do + if test -x $i -a ! -L $i; then + chmod +w $i + $crossConfig-strip -s $i || true + fi + done + + nuke-refs $out/bin/* + nuke-refs $out/lib/* + nuke-refs $out/libexec/gcc/*/*/* + + mkdir $out/.pack + mv $out/* $out/.pack + mv $out/.pack $out/pack + + mkdir $out/on-server + (cd $out/pack && (find | cpio -o -H newc)) | bzip2 > $out/on-server/bootstrap-tools.cpio.bz2 + + mkdir $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/sh $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/cpio $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/mkdir $out/in-nixpkgs + cp ${klibc}/lib/klibc/bin.static/ln $out/in-nixpkgs + cp ${curlStatic.hostDrv}/bin/curl $out/in-nixpkgs + cp ${bzip2Static.hostDrv}/bin/bzip2 $out/in-nixpkgs + chmod u+w $out/in-nixpkgs/* + $crossConfig-strip $out/in-nixpkgs/* + nuke-refs $out/in-nixpkgs/* + bzip2 $out/in-nixpkgs/curl + ''; # */ + + # The result should not contain any references (store paths) so + # that we can safely copy them out of the store and to other + # locations in the store. + allowedReferences = []; + }; + + + unpack = + + stdenv.mkDerivation { + name = "unpack"; + + buildCommand = '' + ${build}/in-nixpkgs/mkdir $out + ${build}/in-nixpkgs/bzip2 -d < ${build}/on-server/bootstrap-tools.cpio.bz2 | (cd $out && ${build}/in-nixpkgs/cpio -V -i) + + for i in $out/bin/* $out/libexec/gcc/*/*/*; do + echo patching $i + if ! test -L $i; then + LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.2 \ + $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.2 --set-rpath $out/lib --force-rpath $i + fi + done + + # Fix the libc linker script. + for i in $out/lib/libc.so; do + cat $i | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $i.tmp + mv $i.tmp $i + done + ''; # " */ + + allowedReferences = ["out"]; + }; + + +} From 2194b98565d644a5a255f5498e3b392e27e1ae3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 16:29:17 +0000 Subject: [PATCH 09/47] Removing any cross-building kind of native build for the pi. --- pkgs/development/compilers/gcc/4.6/builder.sh | 6 +----- pkgs/development/compilers/gcc/4.6/default.nix | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh index e6e7542b6ac6..fbfe86a7b314 100644 --- a/pkgs/development/compilers/gcc/4.6/builder.sh +++ b/pkgs/development/compilers/gcc/4.6/builder.sh @@ -75,11 +75,7 @@ if test "$noSysDirs" = "1"; then fi else if test -z "$NIX_GCC_CROSS"; then - if [ $system == "armv6l-linux" ]; then - EXTRA_TARGET_CFLAGS="-mcpu=armv6 -mfpu=vfp -mhard-float -marm $EXTRA_FLAGS" - else - EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" - fi + EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" else # This the case of cross-building the gcc. diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index 38773fba973d..a504eb96a8b7 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -298,7 +298,7 @@ stdenv.mkDerivation ({ ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} " + (if (cross == null && stdenv.platform.name == "raspberrypi") then - "--with-arch=armv6 --with-fpu=vfp --with-float=hard --with-mode=arm --build=armv6l-linux-gnueabi --host=armv6l-linux-gnueabihf" else ""); + "--with-arch=armv6 --with-fpu=vfp --with-float=hard --with-mode=arm --build=arm-linux-gnueabi --host=arm-linux-gnueabihf" else ""); # ^ This above is out of "" because we don't want to rebuild stdenv in other archs targetConfig = if (cross != null) then cross.config else null; From 651734b6193491478d06a9b268200ffefbb2d5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 17:53:35 +0100 Subject: [PATCH 10/47] gcc/gcc-cross-wrapper: making gcc47 work with uclibc It wants pthreads, and libpthreads wants libdl, and this can only be found with -rpath-link when cross building. --- pkgs/build-support/gcc-cross-wrapper/builder.sh | 2 +- pkgs/development/compilers/gcc/4.7/builder.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/gcc-cross-wrapper/builder.sh b/pkgs/build-support/gcc-cross-wrapper/builder.sh index fae37342940f..5a5bd45a8f81 100644 --- a/pkgs/build-support/gcc-cross-wrapper/builder.sh +++ b/pkgs/build-support/gcc-cross-wrapper/builder.sh @@ -28,7 +28,7 @@ if test -z "$nativeLibc"; then echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags - echo "-L$libc/lib" > $out/nix-support/libc-ldflags + echo "-L$libc/lib -rpath $libc/lib -rpath-link $libc/lib" > $out/nix-support/libc-ldflags # The dynamic linker is passed in `ldflagsBefore' to allow # explicit overrides of the dynamic linker by callers to gcc/ld diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.7/builder.sh index 4ae7a1c193b9..d0ee80a58afb 100644 --- a/pkgs/development/compilers/gcc/4.7/builder.sh +++ b/pkgs/development/compilers/gcc/4.7/builder.sh @@ -71,7 +71,7 @@ if test "$noSysDirs" = "1"; then unset CPATH if test -z "$crossStageStatic"; then EXTRA_TARGET_CFLAGS="-B${libcCross}/lib -idirafter ${libcCross}/include" - EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib" + EXTRA_TARGET_LDFLAGS="-Wl,-L${libcCross}/lib -Wl,-rpath,${libcCross}/lib -Wl,-rpath-link,${libcCross}/lib" fi else if test -z "$NIX_GCC_CROSS"; then From f16193bd996073529be3949e1cbd640d8b48269b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 18:53:45 +0100 Subject: [PATCH 11/47] Setting gcc47 for the cross build tools --- pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix index 061e5f35528a..e956fe90c127 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix @@ -73,7 +73,7 @@ let patch = pkgs.patch.hostDrv; patchelf = pkgs.patchelf.hostDrv; replace = pkgs.replace.hostDrv; - gcc = pkgs.gcc; + gcc = pkgs.gcc47; gmp = pkgs.gmp.hostDrv; mpfr = pkgs.mpfr.hostDrv; #ppl = pkgs.ppl.hostDrv; From 43fac48f15e33f5fe6de0390a2155f33d3e0a611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 20:03:10 +0100 Subject: [PATCH 12/47] gcc47: trying to fix cross-building a gcc --- pkgs/development/compilers/gcc/4.7/builder.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.7/builder.sh index d0ee80a58afb..1771121bc7c2 100644 --- a/pkgs/development/compilers/gcc/4.7/builder.sh +++ b/pkgs/development/compilers/gcc/4.7/builder.sh @@ -95,7 +95,9 @@ if test "$noSysDirs" = "1"; then NIX_FIXINC_DUMMY_CROSS=$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/include # The path to the Glibc binaries such as `crti.o'. - glibc_libdir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)/lib" + glibc_dir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)" + glibc_libdir="$glibc_dir/nix-support/orig-libc)/lib" + configureFlags="--with-native-system-header-dir=$glibc_dir/include" extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags" extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" From 52ee2b99eeef0a8b1fb244c5db1436de028b6125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 20:46:33 +0100 Subject: [PATCH 13/47] gcc47: fix on configureFlags, for cross-built gcc --- pkgs/development/compilers/gcc/4.7/builder.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.7/builder.sh index 1771121bc7c2..638e3b71a93d 100644 --- a/pkgs/development/compilers/gcc/4.7/builder.sh +++ b/pkgs/development/compilers/gcc/4.7/builder.sh @@ -97,7 +97,7 @@ if test "$noSysDirs" = "1"; then # The path to the Glibc binaries such as `crti.o'. glibc_dir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)" glibc_libdir="$glibc_dir/nix-support/orig-libc)/lib" - configureFlags="--with-native-system-header-dir=$glibc_dir/include" + configureFlags="$configureFlags --with-native-system-header-dir=$glibc_dir/include" extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags" extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" From a29b4228e95f9cb93bdeaf6e403868b2bc8aad3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 22:09:00 +0100 Subject: [PATCH 14/47] Typo in 4.7 builder.sh --- pkgs/development/compilers/gcc/4.7/builder.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.7/builder.sh index 638e3b71a93d..b39b3ac827a1 100644 --- a/pkgs/development/compilers/gcc/4.7/builder.sh +++ b/pkgs/development/compilers/gcc/4.7/builder.sh @@ -96,7 +96,7 @@ if test "$noSysDirs" = "1"; then # The path to the Glibc binaries such as `crti.o'. glibc_dir="$(cat $NIX_GCC_CROSS/nix-support/orig-libc)" - glibc_libdir="$glibc_dir/nix-support/orig-libc)/lib" + glibc_libdir="$glibc_dir/lib" configureFlags="$configureFlags --with-native-system-header-dir=$glibc_dir/include" extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags" From eeb9720b928d4f88cd0a03976dc027cc5918443f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 22 Dec 2012 22:57:47 +0100 Subject: [PATCH 15/47] Fixing the bootstrap-tools-crosspi for gcc47 --- pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix index e956fe90c127..8be86eedb3ef 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix @@ -197,6 +197,7 @@ rec { nuke-refs $out/bin/* nuke-refs $out/lib/* nuke-refs $out/libexec/gcc/*/*/* + nuke-refs $out/libexec/gcc/*/*/*/* mkdir $out/.pack mv $out/* $out/.pack From 4c8bca317b03cd546b440b0d487bda53f85e8767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 23 Dec 2012 13:18:26 +0100 Subject: [PATCH 16/47] Improving the bootstrap tools (missing libs) --- .../linux/make-bootstrap-tools-crosspi.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix index 8be86eedb3ef..afc5ed3d5c38 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix @@ -76,8 +76,12 @@ let gcc = pkgs.gcc47; gmp = pkgs.gmp.hostDrv; mpfr = pkgs.mpfr.hostDrv; - #ppl = pkgs.ppl.hostDrv; - #cloogppl = pkgs.cloogppl.hostDrv; + ppl = pkgs.ppl.hostDrv; + cloogppl = pkgs.cloogppl.hostDrv; + cloog = pkgs.cloog.hostDrv; + zlib = pkgs.zlib.hostDrv; + isl = pkgs.isl.hostDrv; + mpc = pkgs.mpc.hostDrv; binutils = pkgs.binutils.hostDrv; klibc = pkgs.klibc.hostDrv; @@ -99,6 +103,8 @@ rec { linkStatic = true; }; + inherit pkgs; + build = stdenv.mkDerivation { @@ -178,6 +184,12 @@ rec { cp -d ${gmp}/lib/libgmp*.so* $out/lib cp -d ${mpfr}/lib/libmpfr*.so* $out/lib + cp -d ${cloogppl}/lib/libcloog*.so* $out/lib + cp -d ${cloog}/lib/libcloog*.so* $out/lib + cp -d ${ppl}/lib/libppl*.so* $out/lib + cp -d ${isl}/lib/libisl*.so* $out/lib + cp -d ${mpc}/lib/libmpc*.so* $out/lib + cp -d ${zlib}/lib/libz.so* $out/lib # Copy binutils. for i in as ld ar ranlib nm strip readelf objdump; do From 164a84f8f4bd41a24ab2d9dc39fd2537de50bd0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 23 Dec 2012 20:11:33 +0100 Subject: [PATCH 17/47] Restoring the gcc 4.6 builder. No need to change it. --- pkgs/development/compilers/gcc/4.6/builder.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh index fbfe86a7b314..2f655ece1703 100644 --- a/pkgs/development/compilers/gcc/4.6/builder.sh +++ b/pkgs/development/compilers/gcc/4.6/builder.sh @@ -244,12 +244,12 @@ postInstall() { } -#if test -z "$targetConfig" && test -z "$crossConfig"; then -# if test -z "$profiledCompiler"; then -# buildFlags="bootstrap $buildFlags" -# else -# buildFlags="profiledbootstrap $buildFlags" -# fi -#fi +if test -z "$targetConfig" && test -z "$crossConfig"; then + if test -z "$profiledCompiler"; then + buildFlags="bootstrap $buildFlags" + else + buildFlags="profiledbootstrap $buildFlags" + fi +fi genericBuild From 6c9002639dda6738ab9a4d18e62ebddcac4cddd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 23 Dec 2012 20:14:13 +0100 Subject: [PATCH 18/47] I forgot to undo a gcc46 unneeded change. --- pkgs/development/compilers/gcc/4.6/default.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index a504eb96a8b7..ade35c3c2cf1 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -297,9 +297,7 @@ stdenv.mkDerivation ({ ${if langAda then " --enable-libada" else ""} ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} - " + (if (cross == null && stdenv.platform.name == "raspberrypi") then - "--with-arch=armv6 --with-fpu=vfp --with-float=hard --with-mode=arm --build=arm-linux-gnueabi --host=arm-linux-gnueabihf" else ""); - # ^ This above is out of "" because we don't want to rebuild stdenv in other archs + "; targetConfig = if (cross != null) then cross.config else null; From 68a65bcf2a10a63553a3e5a4a6958e7a0ef98cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 23 Dec 2012 20:16:50 +0100 Subject: [PATCH 19/47] Undoing glibc 2.13 work for the pi (previous attempt of bootstrapping from the armv5tel bootstrap tools) --- pkgs/development/libraries/glibc/2.13/common.nix | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pkgs/development/libraries/glibc/2.13/common.nix b/pkgs/development/libraries/glibc/2.13/common.nix index 316c66c51900..2c43dd05f526 100644 --- a/pkgs/development/libraries/glibc/2.13/common.nix +++ b/pkgs/development/libraries/glibc/2.13/common.nix @@ -8,7 +8,7 @@ cross : , machHeaders ? null, hurdHeaders ? null, libpthreadHeaders ? null , mig ? null, fetchgit ? null , profilingLibraries ? false, meta -, preConfigure ? "", recentGcc ? true, ... }@args : +, preConfigure ? "", ... }@args : let # For GNU/Hurd, see below. @@ -121,8 +121,7 @@ stdenv.mkDerivation ({ "--enable-kernel=2.6.0" "--with-__thread" ] ++ stdenv.lib.optionals (cross == null && - (stdenv.system == "armv5tel-linux") || - (!recentGcc && stdenv.platform.name == "raspberrypi")) [ + (stdenv.system == "armv5tel-linux")) [ "--host=arm-linux-gnueabi" "--build=arm-linux-gnueabi" "--without-fp" @@ -130,7 +129,7 @@ stdenv.mkDerivation ({ # To avoid linking with -lgcc_s (dynamic link) # so the glibc does not depend on its compiler store path "libc_cv_as_needed=no" - ] ++ stdenv.lib.optionals (cross == null && recentGcc && stdenv.platform.name == "raspberrypi") [ + ] ++ stdenv.lib.optionals (cross == null && stdenv.platform.name == "raspberrypi") [ "--host=arm-linux-gnueabihf" "--build=arm-linux-gnueabihf" "--with-fp" @@ -202,10 +201,6 @@ stdenv.mkDerivation ({ configureScript="`pwd`/../$sourceRoot/configure" ${preConfigure} - '' + stdenv.lib.optionalString (cross == null - && recentGcc - && stdenv.platform.name == "raspberrypi") '' - configureFlagsArray=("CFLAGS=-march=armv6 -mfpu=vfp -mhard-float") ''; meta = { From 0af1283e977ffbd72681461ab8e75735563a4421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 23 Dec 2012 20:17:53 +0100 Subject: [PATCH 20/47] Undoing more glibc unneeded changes --- pkgs/development/libraries/glibc/2.13/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/development/libraries/glibc/2.13/default.nix b/pkgs/development/libraries/glibc/2.13/default.nix index 59f8ca647e6f..f80ed9372e63 100644 --- a/pkgs/development/libraries/glibc/2.13/default.nix +++ b/pkgs/development/libraries/glibc/2.13/default.nix @@ -5,7 +5,6 @@ , profilingLibraries ? false , gccCross ? null , debugSymbols ? false -, recentGcc ? true }: assert stdenv.gcc.gcc != null; @@ -20,7 +19,7 @@ in + stdenv.lib.optionalString debugSymbols "-debug"; inherit fetchurl stdenv kernelHeaders installLocales profilingLibraries - gccCross recentGcc; + gccCross; builder = ./builder.sh; From 50ae899f622240f0048611b3db06adf5f413c2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 23 Dec 2012 20:19:55 +0100 Subject: [PATCH 21/47] Removing a glibc outdated mention in stdenvLinux --- pkgs/stdenv/linux/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index d8b404cc7761..c59c03506ea9 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -190,7 +190,7 @@ rec { # 5) Build Glibc with the bootstrap tools. The result is the full, # dynamically linked, final Glibc. - stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc.override { recentGcc = false; }; + stdenvLinuxGlibc = stdenvLinuxBoot2Pkgs.glibc; # 6) Construct a third stdenv identical to the 2nd, except that From 764ebc29ab3efdd708c51c98168e0a86254c80d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Mon, 24 Dec 2012 15:10:40 +0000 Subject: [PATCH 22/47] Adding the armv6l bootstrap; I forgot that file in previous commits. --- pkgs/stdenv/linux/bootstrap/armv6l/default.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 pkgs/stdenv/linux/bootstrap/armv6l/default.nix diff --git a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix new file mode 100644 index 000000000000..b71b3f6cf681 --- /dev/null +++ b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix @@ -0,0 +1,13 @@ +{ + sh = ../armv5tel/sh; + bzip2 = ../armv5tel/bzip2; + mkdir = ../armv5tel/mkdir; + cpio = ../armv5tel/cpio; + ln = ../armv5tel/ln; + curl = ../armv5tel/curl.bz2; + + bootstrapTools = { + url = "file:///root/v6/bootstrap-tools.cpio.bz2"; + sha256 = "01s4z461jv9plsxwkspjakdvjxzd5pd84i73nc2ynag5hmjyj63d"; + }; +} From 5258c8a0c641bf18faf3ae2e3618153f7cf4850a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 23 Dec 2012 13:36:19 +0000 Subject: [PATCH 23/47] Going with armv6l-linux bootstrap-tools. I had lost this change in some branch. --- pkgs/stdenv/linux/default.nix | 4 +-- .../scripts/unpack-bootstrap-tools-arm.sh | 28 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index c59c03506ea9..224e749e6090 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -16,7 +16,7 @@ rec { else if system == "x86_64-linux" then import ./bootstrap/x86_64 else if system == "powerpc-linux" then import ./bootstrap/powerpc else if system == "armv5tel-linux" then import ./bootstrap/armv5tel - else if system == "armv6l-linux" then import ./bootstrap/armv5tel + else if system == "armv6l-linux" then import ./bootstrap/armv6l else if system == "armv7l-linux" then import ./bootstrap/armv5tel else if system == "mips64el-linux" then import ./bootstrap/loongson2f else abort "unsupported platform for the pure Linux stdenv"; @@ -58,7 +58,7 @@ rec { builder = bootstrapFiles.sh; args = - if (system == "armv5tel-linux" || system == "arm6l-linux") + if (system == "armv5tel-linux" || system == "armv6l-linux") then [ ./scripts/unpack-bootstrap-tools-arm.sh ] else [ ./scripts/unpack-bootstrap-tools.sh ]; diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh index 3709ac05041b..28c9b0dcd586 100644 --- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh +++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh @@ -14,21 +14,23 @@ LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? $out/bin/cp $out/bin/patchelf . for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do echo patching $i - if ! test -L $i; then - LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ - $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i - LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ - $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i - fi + if test ${i%.la} != $i; then continue; fi + if test ${i%*.so*} != $i; then continue; fi + if ! test -f $i; then continue; fi + if test -L $i; then continue; fi + LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ + $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i + LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ + $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i done -for i in $out/lib/libppl* $out/lib/libgmp*; do +for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp*; do echo patching $i - if ! test -L $i; then - LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ - $out/bin/patchelf --set-rpath $out/lib --force-rpath $i - LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ - $out/bin/patchelf --set-rpath $out/lib --force-rpath $i - fi + if ! test -f $i; then continue; fi + if test -L $i; then continue; fi + LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ + $out/bin/patchelf --set-rpath $out/lib --force-rpath $i + LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ + $out/bin/patchelf --set-rpath $out/lib --force-rpath $i done # Fix the libc linker script. From 96b0de4c33fe53916e147ce15b04ee5a316b7b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Mon, 24 Dec 2012 16:37:54 +0100 Subject: [PATCH 24/47] gcc4.7: making the cross-built gcc respect withAbi, withArch, ... --- pkgs/development/compilers/gcc/4.7/default.nix | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index 0d24f19e3c30..9eb8f10115ca 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -308,7 +308,16 @@ stdenv.mkDerivation ({ then "install-strip" else "install"; - crossAttrs = { + crossAttrs = let + xgccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null stdenv.cross; + xgccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null stdenv.cross; + xgccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null stdenv.cross; + xgccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null stdenv.cross; + xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else ""; + xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else ""; + xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else ""; + xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else ""; + in { AR = "${stdenv.cross.config}-ar"; LD = "${stdenv.cross.config}-ld"; CC = "${stdenv.cross.config}-gcc"; @@ -347,9 +356,11 @@ stdenv.mkDerivation ({ ) } ${if langAda then " --enable-libada" else ""} - ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} - ${if cross != null then crossConfigureFlags else ""} --target=${stdenv.cross.config} + ${xwithArch} + ${xwithCpu} + ${xwithAbi} + ${xwithFpu} ''; }; From 2717392cbfaa93f3aca55503d1741bc919a5df5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Wed, 26 Dec 2012 15:29:49 +0000 Subject: [PATCH 25/47] The glibc doesn't like "gnueabihf" in the triplet. I better set "gnueabi". --- pkgs/development/libraries/glibc/2.13/common.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/glibc/2.13/common.nix b/pkgs/development/libraries/glibc/2.13/common.nix index 2c43dd05f526..10ce4f459e6f 100644 --- a/pkgs/development/libraries/glibc/2.13/common.nix +++ b/pkgs/development/libraries/glibc/2.13/common.nix @@ -130,8 +130,8 @@ stdenv.mkDerivation ({ # so the glibc does not depend on its compiler store path "libc_cv_as_needed=no" ] ++ stdenv.lib.optionals (cross == null && stdenv.platform.name == "raspberrypi") [ - "--host=arm-linux-gnueabihf" - "--build=arm-linux-gnueabihf" + "--host=arm-linux-gnueabi" + "--build=arm-linux-gnueabi" "--with-fp" # To avoid linking with -lgcc_s (dynamic link) From 120499c03ae7fb1e3d9f493efa83f67663740e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Wed, 26 Dec 2012 22:42:57 +0000 Subject: [PATCH 26/47] Setting a public URL for the pi bootstrap tools --- pkgs/stdenv/linux/bootstrap/armv6l/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix index b71b3f6cf681..da4f1e468273 100644 --- a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix +++ b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix @@ -7,7 +7,7 @@ curl = ../armv5tel/curl.bz2; bootstrapTools = { - url = "file:///root/v6/bootstrap-tools.cpio.bz2"; + url = http://viric.name/tmp/nix/pi/bootstrap-tools.cpio.bz2; sha256 = "01s4z461jv9plsxwkspjakdvjxzd5pd84i73nc2ynag5hmjyj63d"; }; } From e9365882c1086c5dae199334038527b579d022a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 27 Dec 2012 14:54:44 +0000 Subject: [PATCH 27/47] gcc46: moving the bootstrap logic into nix It was in the builder.sh. --- pkgs/development/compilers/gcc/4.6/builder.sh | 9 --------- pkgs/development/compilers/gcc/4.6/default.nix | 10 +++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/builder.sh b/pkgs/development/compilers/gcc/4.6/builder.sh index 2f655ece1703..2bb185417390 100644 --- a/pkgs/development/compilers/gcc/4.6/builder.sh +++ b/pkgs/development/compilers/gcc/4.6/builder.sh @@ -243,13 +243,4 @@ postInstall() { eval "$postInstallGhdl" } - -if test -z "$targetConfig" && test -z "$crossConfig"; then - if test -z "$profiledCompiler"; then - buildFlags="bootstrap $buildFlags" - else - buildFlags="profiledbootstrap $buildFlags" - fi -fi - genericBuild diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index ade35c3c2cf1..bf2d01b280de 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -156,6 +156,8 @@ let version = "4.6.3"; "-stage-final"; crossNameAddon = if (cross != null) then "-${cross.config}" + stageNameAddon else ""; + bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips; + in # We need all these X libraries when building AWT with GTK+. @@ -230,7 +232,7 @@ stdenv.mkDerivation ({ '' else null; - inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic + inherit noSysDirs staticCompiler langJava crossStageStatic libcCross crossMingw; buildNativeInputs = [ texinfo which gettext ] @@ -297,10 +299,15 @@ stdenv.mkDerivation ({ ${if langAda then " --enable-libada" else ""} ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} + ${if !bootstrap then "--disable-bootstrap" else ""} "; targetConfig = if (cross != null) then cross.config else null; + buildFlags = if bootstrap then + (if profiledCompiler then "profiledbootstrap" else "bootstrap") + else ""; + installTargets = if stripped then "install-strip" @@ -350,6 +357,7 @@ stdenv.mkDerivation ({ ${if cross != null then crossConfigureFlags else ""} --target=${stdenv.cross.config} ''; + buildFlags = ""; }; From d05b33653e6376124f39984a56c92295b8a65e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 27 Dec 2012 14:57:32 +0000 Subject: [PATCH 28/47] gcc47: moving the bootstrap logic into nix It was in the builder.sh. Similar to the previous patch to gcc46. --- pkgs/development/compilers/gcc/4.7/builder.sh | 9 --------- pkgs/development/compilers/gcc/4.7/default.nix | 10 +++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.7/builder.sh b/pkgs/development/compilers/gcc/4.7/builder.sh index b39b3ac827a1..37400fba5bf5 100644 --- a/pkgs/development/compilers/gcc/4.7/builder.sh +++ b/pkgs/development/compilers/gcc/4.7/builder.sh @@ -239,13 +239,4 @@ postInstall() { eval "$postInstallGhdl" } - -if test -z "$targetConfig" && test -z "$crossConfig"; then - if test -z "$profiledCompiler"; then - buildFlags="bootstrap $buildFlags" - else - buildFlags="profiledbootstrap $buildFlags" - fi -fi - genericBuild diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index 9eb8f10115ca..028a1680cb63 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -154,6 +154,8 @@ let version = "4.7.2"; "-stage-final"; crossNameAddon = if (cross != null) then "-${cross.config}" + stageNameAddon else ""; + bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips; + in # We need all these X libraries when building AWT with GTK+. @@ -225,7 +227,7 @@ stdenv.mkDerivation ({ '' else null; - inherit noSysDirs profiledCompiler staticCompiler langJava crossStageStatic + inherit noSysDirs staticCompiler langJava crossStageStatic libcCross crossMingw; buildNativeInputs = [ texinfo which gettext ] @@ -299,10 +301,15 @@ stdenv.mkDerivation ({ ${if langAda then " --enable-libada" else ""} ${if (cross == null && stdenv.isi686) then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} + ${if !bootstrap then "--disable-bootstrap" else ""} "; targetConfig = if (cross != null) then cross.config else null; + buildFlags = if bootstrap then + (if profiledCompiler then "profiledbootstrap" else "bootstrap") + else ""; + installTargets = if stripped then "install-strip" @@ -362,6 +369,7 @@ stdenv.mkDerivation ({ ${xwithAbi} ${xwithFpu} ''; + buildFlags = ""; }; From ee2f05d683cfdfe6169263d9185fbd0f76303d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 27 Dec 2012 15:19:23 +0000 Subject: [PATCH 29/47] Removing unneeded changes in stdenvLinux, for the pi. I had those changes from the time when I wanted to bootstrap its stdenvLinux from armv5tel bootstrap-tools. But that never worked. --- pkgs/stdenv/linux/default.nix | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index cae95615a446..bdf91e717cdf 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -203,23 +203,19 @@ rec { coreutils = bootstrapTools; libc = stdenvLinuxGlibc; }; - overrides = pkgs: ({ + overrides = pkgs: { glibc = stdenvLinuxGlibc; inherit (stdenvLinuxBoot1Pkgs) perl; - } // (if (platform ? name && platform.name != "raspberrypi") then { # Link GCC statically against GMP etc. This makes sense because # these builds of the libraries are only used by GCC, so it # reduces the size of the stdenv closure. - - # On raspberry pi we can't do that, because libgcc/libstdc++ are made - # without hardfp, and can't be linked with the new hardfp code in gcc. gmp = pkgs.gmp.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; mpfr = pkgs.mpfr.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; mpc = pkgs.mpc.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; isl = pkgs.isl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; cloog = pkgs.cloog.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; ppl = pkgs.ppl.override { stdenv = pkgs.makeStaticLibraries pkgs.stdenv; }; - } else {})); + }; inherit fetchurl; }; @@ -240,8 +236,7 @@ rec { inherit (stdenvLinuxBoot3Pkgs) binutils; coreutils = bootstrapTools; libc = stdenvLinuxGlibc; - gcc = stdenvLinuxBoot3Pkgs.gcc.gcc.override (if platform.name == "raspberrypi" then - { ppl = null; cloog = null; } else {}); + gcc = stdenvLinuxBoot3Pkgs.gcc.gcc; name = ""; }; extraPath = [ stdenvLinuxBoot3Pkgs.xz ]; From ab2520c383b430d8ea5a6159779b1dcee3258038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Thu, 27 Dec 2012 21:29:56 +0000 Subject: [PATCH 30/47] Adding linux-3.6-rpi I picked the change from https://github.com/aforemny/nixpkgs/commit/7b4d69eeff2eb10c395c8d1a52a0c1e246cddb45 --- .../linux/kernel/linux-rpi-3.6.nix | 42 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 5 +++ 2 files changed, 47 insertions(+) create mode 100644 pkgs/os-specific/linux/kernel/linux-rpi-3.6.nix diff --git a/pkgs/os-specific/linux/kernel/linux-rpi-3.6.nix b/pkgs/os-specific/linux/kernel/linux-rpi-3.6.nix new file mode 100644 index 000000000000..0dc6378fff38 --- /dev/null +++ b/pkgs/os-specific/linux/kernel/linux-rpi-3.6.nix @@ -0,0 +1,42 @@ +args @ { + stdenv, fetchgit, extraConfig ? "" , perl, mktemp, module_init_tools, ... +}: + +let + configWithPlatform = kernelPlatform : + '' + ${if kernelPlatform ? kernelExtraConfig then kernelPlatform.kernelExtraConfig else ""} + ${extraConfig} + ''; +in + +import ./generic.nix ( + + rec { + version = "3.6.y"; + testing = false; + + preConfigure = '' + substituteInPlace scripts/depmod.sh --replace '-b "$INSTALL_MOD_PATH"' "" + ''; + + src = fetchgit { + url = https://github.com/raspberrypi/linux; + rev = "6e1f8bce970043a658d15f9350eb85152fd5fc4e"; + sha256 = ""; + }; + + config = configWithPlatform stdenv.platform; + configCross = configWithPlatform stdenv.cross.platform; + + features.iwlwifi = true; + #features.efiBootStub = true; + #features.needsCifsUtils = true; + #features.canDisableNetfilterConntrackHelpers = true; + #features.netfilterRPFilter = true; + + fetchurl = null; + } + + // removeAttrs args ["extraConfig"] +) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 895d9db36c10..65d49f47b61d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5860,6 +5860,10 @@ let ]; }; + linux_3_6_rpi = makeOverridable (import ../os-specific/linux/kernel/linux-rpi-3.6.nix) { + inherit fetchgit stdenv perl mktemp module_init_tools ubootChooser; + }; + /* Linux kernel modules are inherently tied to a specific kernel. So rather than provide specific instances of those packages for a specific kernel, we have a function that builds those packages @@ -5987,6 +5991,7 @@ let linuxPackages_3_4 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_4 pkgs.linuxPackages_3_4); linuxPackages_3_5 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_5 pkgs.linuxPackages_3_5); linuxPackages_3_6 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_6 pkgs.linuxPackages_3_6); + linuxPackages_3_6_rpi = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_6_rpi pkgs.linuxPackages_3_6_rpi); linuxPackages_3_7 = recurseIntoAttrs (linuxPackagesFor pkgs.linux_3_7 pkgs.linuxPackages_3_7); # The current default kernel / kernel modules. From 33d3cf2d1c86fa537d0c563668db9d99f331f299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 16:39:54 +0000 Subject: [PATCH 31/47] Fixes in make-bootstrap-tools-crosspi.nix It doesn't reference anymore. And I fixed the indentation. --- .../linux/make-bootstrap-tools-crosspi.nix | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix index afc5ed3d5c38..8f58efe750fe 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix @@ -1,49 +1,49 @@ {system ? builtins.currentSystem}: let - pkgsFun = import ; # The root nixpkgs default.nix + pkgsFun = import ../../top-level/all-packages.nix; pkgsNoParams = pkgsFun {}; raspberrypiCrossSystem = { crossSystem = { - config = "armv6l-unknown-linux-gnueabi"; - bigEndian = false; - arch = "arm"; - float = "hard"; + config = "armv6l-unknown-linux-gnueabi"; + bigEndian = false; + arch = "arm"; + float = "hard"; + fpu = "vfp"; + withTLS = true; + libc = "glibc"; + platform = pkgsNoParams.platforms.raspberrypi; + openssl.system = "linux-generic32"; + gcc = { + arch = "armv6"; fpu = "vfp"; - withTLS = true; - libc = "glibc"; - platform = pkgsNoParams.platforms.raspberrypi; - openssl.system = "linux-generic32"; - gcc = { - arch = "armv6"; - fpu = "vfp"; - float = "hard"; - }; + float = "hard"; + }; }; }; raspberrypiCrossSystemUclibc = { crossSystem = { - config = "armv6l-unknown-linux-gnueabi"; - bigEndian = false; - arch = "arm"; - float = "hard"; + config = "armv6l-unknown-linux-gnueabi"; + bigEndian = false; + arch = "arm"; + float = "hard"; + fpu = "vfp"; + withTLS = true; + libc = "uclibc"; + platform = pkgsNoParams.platforms.raspberrypi; + openssl.system = "linux-generic32"; + gcc = { + arch = "armv6"; fpu = "vfp"; - withTLS = true; - libc = "uclibc"; - platform = pkgsNoParams.platforms.raspberrypi; - openssl.system = "linux-generic32"; - gcc = { - arch = "armv6"; - fpu = "vfp"; - float = "hard"; - }; - uclibc.extraConfig = '' - ARCH_WANTS_BIG_ENDIAN n - ARCH_BIG_ENDIAN n - ARCH_WANTS_LITTLE_ENDIAN y - ARCH_LITTLE_ENDIAN y - ''; + float = "hard"; + }; + uclibc.extraConfig = '' + ARCH_WANTS_BIG_ENDIAN n + ARCH_BIG_ENDIAN n + ARCH_WANTS_LITTLE_ENDIAN y + ARCH_LITTLE_ENDIAN y + ''; }; }; From affca4a11cd0b79682398941eec6196df56818e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 16:53:18 +0000 Subject: [PATCH 32/47] Making the raspberrypi glibc include hard float. --- pkgs/development/libraries/glibc/2.16/common.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/glibc/2.16/common.nix b/pkgs/development/libraries/glibc/2.16/common.nix index ea54b45a50de..a8cb4f2b1d05 100644 --- a/pkgs/development/libraries/glibc/2.16/common.nix +++ b/pkgs/development/libraries/glibc/2.16/common.nix @@ -114,10 +114,20 @@ stdenv.mkDerivation ({ && cross.platform.kernelMajor == "2.6") [ "--enable-kernel=2.6.0" "--with-__thread" - ] ++ stdenv.lib.optionals stdenv.isArm [ + ] ++ stdenv.lib.optionals (cross == null && + (stdenv.system == "armv5tel-linux")) [ "--host=arm-linux-gnueabi" "--build=arm-linux-gnueabi" "--without-fp" + + # To avoid linking with -lgcc_s (dynamic link) + # so the glibc does not depend on its compiler store path + "libc_cv_as_needed=no" + ] ++ stdenv.lib.optionals (cross == null && stdenv.platform.name == "raspberrypi") [ + "--host=arm-linux-gnueabi" + "--build=arm-linux-gnueabi" + "--with-fp" + # To avoid linking with -lgcc_s (dynamic link) # so the glibc does not depend on its compiler store path "libc_cv_as_needed=no" From f2f50c42d2c705dc59465c070f5259a4ad00cf4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 21:12:57 +0100 Subject: [PATCH 33/47] gcc47: adding --with-float option to gcc builder Meant for cross-building. I need that for the raspberrypi bootstrap-tools. Before this, its bootstrap-tools gcc built for softfloat by default. --- pkgs/development/compilers/gcc/4.7/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index 028a1680cb63..f89ee067143e 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -90,10 +90,12 @@ let version = "4.7.2"; gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross; + gccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null cross; withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; + withFloat = if gccFpu != null then " --with-float=${gccFloat}" else ""; crossMingw = (cross != null && cross.libc == "msvcrt"); crossConfigureFlags = @@ -102,6 +104,7 @@ let version = "4.7.2"; withCpu + withAbi + withFpu + + withFloat + (if (crossMingw && crossStageStatic) then " --with-headers=${libcCross}/include" + " --with-gcc" + @@ -320,10 +323,12 @@ stdenv.mkDerivation ({ xgccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null stdenv.cross; xgccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null stdenv.cross; xgccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null stdenv.cross; + xgccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null stdenv.cross; xwithArch = if xgccArch != null then " --with-arch=${xgccArch}" else ""; xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else ""; xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else ""; xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else ""; + xwithFloat = if xgccFpu != null then " --with-float=${xgccFloat}" else ""; in { AR = "${stdenv.cross.config}-ar"; LD = "${stdenv.cross.config}-ld"; From 4485ee59166a25106136b3e77f6e731fd39d82fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 21:16:25 +0100 Subject: [PATCH 34/47] glibc: removing raspberrypi specific code I think its --with-fp or --without-fp makes nothing, for arm. --- pkgs/development/libraries/glibc/2.16/common.nix | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pkgs/development/libraries/glibc/2.16/common.nix b/pkgs/development/libraries/glibc/2.16/common.nix index a8cb4f2b1d05..3876cf237c8c 100644 --- a/pkgs/development/libraries/glibc/2.16/common.nix +++ b/pkgs/development/libraries/glibc/2.16/common.nix @@ -114,19 +114,9 @@ stdenv.mkDerivation ({ && cross.platform.kernelMajor == "2.6") [ "--enable-kernel=2.6.0" "--with-__thread" - ] ++ stdenv.lib.optionals (cross == null && - (stdenv.system == "armv5tel-linux")) [ + ] ++ stdenv.lib.optionals (cross == null && stdenv.isArm) [ "--host=arm-linux-gnueabi" "--build=arm-linux-gnueabi" - "--without-fp" - - # To avoid linking with -lgcc_s (dynamic link) - # so the glibc does not depend on its compiler store path - "libc_cv_as_needed=no" - ] ++ stdenv.lib.optionals (cross == null && stdenv.platform.name == "raspberrypi") [ - "--host=arm-linux-gnueabi" - "--build=arm-linux-gnueabi" - "--with-fp" # To avoid linking with -lgcc_s (dynamic link) # so the glibc does not depend on its compiler store path From 2b19eb189dc5a0eb9adbbd054d27ef01f500eeb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 21:22:13 +0100 Subject: [PATCH 35/47] Adapting make-bootstrap-tools-crosspi.nix to crossDrv --- .../linux/make-bootstrap-tools-crosspi.nix | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix index 8f58efe750fe..9b2949e3e368 100644 --- a/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix +++ b/pkgs/stdenv/linux/make-bootstrap-tools-crosspi.nix @@ -57,33 +57,33 @@ let aclSupport = false; }); - coreutils_ = coreutils_base.hostDrv; + coreutils_ = coreutils_base.crossDrv; glibc = pkgs.libcCross; - bash = pkgs.bash.hostDrv; - findutils = pkgs.findutils.hostDrv; - diffutils = pkgs.diffutils.hostDrv; - gnused = pkgs.gnused.hostDrv; - gnugrep = pkgs.gnugrep.hostDrv; - gawk = pkgs.gawk.hostDrv; - gnutar = pkgs.gnutar.hostDrv; - gzip = pkgs.gzip.hostDrv; - bzip2 = pkgs.bzip2.hostDrv; - gnumake = pkgs.gnumake.hostDrv; - patch = pkgs.patch.hostDrv; - patchelf = pkgs.patchelf.hostDrv; - replace = pkgs.replace.hostDrv; + bash = pkgs.bash.crossDrv; + findutils = pkgs.findutils.crossDrv; + diffutils = pkgs.diffutils.crossDrv; + gnused = pkgs.gnused.crossDrv; + gnugrep = pkgs.gnugrep.crossDrv; + gawk = pkgs.gawk.crossDrv; + gnutar = pkgs.gnutar.crossDrv; + gzip = pkgs.gzip.crossDrv; + bzip2 = pkgs.bzip2.crossDrv; + gnumake = pkgs.gnumake.crossDrv; + patch = pkgs.patch.crossDrv; + patchelf = pkgs.patchelf.crossDrv; + replace = pkgs.replace.crossDrv; gcc = pkgs.gcc47; - gmp = pkgs.gmp.hostDrv; - mpfr = pkgs.mpfr.hostDrv; - ppl = pkgs.ppl.hostDrv; - cloogppl = pkgs.cloogppl.hostDrv; - cloog = pkgs.cloog.hostDrv; - zlib = pkgs.zlib.hostDrv; - isl = pkgs.isl.hostDrv; - mpc = pkgs.mpc.hostDrv; - binutils = pkgs.binutils.hostDrv; - klibc = pkgs.klibc.hostDrv; + gmp = pkgs.gmp.crossDrv; + mpfr = pkgs.mpfr.crossDrv; + ppl = pkgs.ppl.crossDrv; + cloogppl = pkgs.cloogppl.crossDrv; + cloog = pkgs.cloog.crossDrv; + zlib = pkgs.zlib.crossDrv; + isl = pkgs.isl.crossDrv; + mpc = pkgs.mpc.crossDrv; + binutils = pkgs.binutils.crossDrv; + klibc = pkgs.klibc.crossDrv; in @@ -159,15 +159,15 @@ rec { cp ${patchelf}/bin/* $out/bin cp ${replace}/bin/* $out/bin - cp -d ${gnugrep.pcre.hostDrv}/lib/libpcre*.so* $out/lib # needed by grep + cp -d ${gnugrep.pcre.crossDrv}/lib/libpcre*.so* $out/lib # needed by grep # Copy what we need of GCC. - cp -d ${gcc.gcc.hostDrv}/bin/gcc $out/bin - cp -d ${gcc.gcc.hostDrv}/bin/cpp $out/bin - cp -d ${gcc.gcc.hostDrv}/bin/g++ $out/bin - cp -d ${gcc.gcc.hostDrv}/lib*/libgcc_s.so* $out/lib - cp -d ${gcc.gcc.hostDrv}/lib*/libstdc++.so* $out/lib - cp -rd ${gcc.gcc.hostDrv}/lib/gcc $out/lib + cp -d ${gcc.gcc.crossDrv}/bin/gcc $out/bin + cp -d ${gcc.gcc.crossDrv}/bin/cpp $out/bin + cp -d ${gcc.gcc.crossDrv}/bin/g++ $out/bin + cp -d ${gcc.gcc.crossDrv}/lib*/libgcc_s.so* $out/lib + cp -d ${gcc.gcc.crossDrv}/lib*/libstdc++.so* $out/lib + cp -rd ${gcc.gcc.crossDrv}/lib/gcc $out/lib chmod -R u+w $out/lib rm -f $out/lib/gcc/*/*/include*/linux rm -f $out/lib/gcc/*/*/include*/sound @@ -175,9 +175,9 @@ rec { rm -f $out/lib/gcc/*/*/include-fixed/asm rm -rf $out/lib/gcc/*/*/plugin #rm -f $out/lib/gcc/*/*/*.a - cp -rd ${gcc.gcc.hostDrv}/libexec/* $out/libexec + cp -rd ${gcc.gcc.crossDrv}/libexec/* $out/libexec mkdir $out/include - cp -rd ${gcc.gcc.hostDrv}/include/c++ $out/include + cp -rd ${gcc.gcc.crossDrv}/include/c++ $out/include chmod -R u+w $out/include rm -rf $out/include/c++/*/ext/pb_ds rm -rf $out/include/c++/*/ext/parallel @@ -223,8 +223,8 @@ rec { cp ${klibc}/lib/klibc/bin.static/cpio $out/in-nixpkgs cp ${klibc}/lib/klibc/bin.static/mkdir $out/in-nixpkgs cp ${klibc}/lib/klibc/bin.static/ln $out/in-nixpkgs - cp ${curlStatic.hostDrv}/bin/curl $out/in-nixpkgs - cp ${bzip2Static.hostDrv}/bin/bzip2 $out/in-nixpkgs + cp ${curlStatic.crossDrv}/bin/curl $out/in-nixpkgs + cp ${bzip2Static.crossDrv}/bin/bzip2 $out/in-nixpkgs chmod u+w $out/in-nixpkgs/* $crossConfig-strip $out/in-nixpkgs/* nuke-refs $out/in-nixpkgs/* From d7fb4db24193772e28ad30fe9bba8708a796dca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 20:19:32 +0000 Subject: [PATCH 36/47] armv6l: Updating bootstrap tools to build for harfp --- pkgs/stdenv/linux/bootstrap/armv6l/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix index da4f1e468273..67ba5306db12 100644 --- a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix +++ b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix @@ -7,7 +7,9 @@ curl = ../armv5tel/curl.bz2; bootstrapTools = { + # Built from make-bootstrap-tools-crosspi.nix + # nixpkgs rev f2f50c42d2c705dc59465c070f5259a4ad00cf4c url = http://viric.name/tmp/nix/pi/bootstrap-tools.cpio.bz2; - sha256 = "01s4z461jv9plsxwkspjakdvjxzd5pd84i73nc2ynag5hmjyj63d"; + sha256 = "1mpl4qgij43xiqhn173glz3ysrf3l3bnwvz07fiqr7lfmd7g54p5"; }; } From 87ec7b49b120950a260d9733de7f34d7c2bffb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 21:38:03 +0100 Subject: [PATCH 37/47] gcc47: Fixing the gcc.float cross parameters --- pkgs/development/compilers/gcc/4.7/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index ed1a977b6941..662f6192f9fb 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -95,7 +95,7 @@ let version = "4.7.2"; withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; - withFloat = if gccFpu != null then " --with-float=${gccFloat}" else ""; + withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; crossMingw = (cross != null && cross.libc == "msvcrt"); crossConfigureFlags = @@ -328,7 +328,7 @@ stdenv.mkDerivation ({ xwithCpu = if xgccCpu != null then " --with-cpu=${xgccCpu}" else ""; xwithAbi = if xgccAbi != null then " --with-abi=${xgccAbi}" else ""; xwithFpu = if xgccFpu != null then " --with-fpu=${xgccFpu}" else ""; - xwithFloat = if xgccFpu != null then " --with-float=${xgccFloat}" else ""; + xwithFloat = if xgccFloat != null then " --with-float=${xgccFloat}" else ""; in { AR = "${stdenv.cross.config}-ar"; LD = "${stdenv.cross.config}-ld"; @@ -373,6 +373,7 @@ stdenv.mkDerivation ({ ${xwithCpu} ${xwithAbi} ${xwithFpu} + ${xwithFloat} ''; buildFlags = ""; }; From f2133155d8497cf8705b2c67f30208a4d25a7793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Fri, 28 Dec 2012 21:14:32 +0000 Subject: [PATCH 38/47] armv6l: new bootstrap-tools Trying again to get a hardfp compiler. --- pkgs/stdenv/linux/bootstrap/armv6l/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix index 67ba5306db12..f8eef244fce1 100644 --- a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix +++ b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix @@ -8,8 +8,8 @@ bootstrapTools = { # Built from make-bootstrap-tools-crosspi.nix - # nixpkgs rev f2f50c42d2c705dc59465c070f5259a4ad00cf4c + # nixpkgs rev 87ec7b49b120950a260d9733de7f34d7c2bffb98 url = http://viric.name/tmp/nix/pi/bootstrap-tools.cpio.bz2; - sha256 = "1mpl4qgij43xiqhn173glz3ysrf3l3bnwvz07fiqr7lfmd7g54p5"; + sha256 = "04qy8cqd30pqhil62b9sx67ijdspf9npx2snwwrcwvk3zbyhcll3"; }; } From 29fdf278ce37566cc10a8c0396b3a206c287a6b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 29 Dec 2012 14:14:53 +0000 Subject: [PATCH 39/47] Enabling support of ld-linux-armhf.so.3 ld.so, in ARM I use wildcards. --- pkgs/build-support/gcc-wrapper/builder.sh | 2 +- pkgs/build-support/gcc-wrapper/default.nix | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh index ad2b8003f090..81e698c66849 100644 --- a/pkgs/build-support/gcc-wrapper/builder.sh +++ b/pkgs/build-support/gcc-wrapper/builder.sh @@ -31,7 +31,7 @@ if test -z "$nativeLibc"; then # The dynamic linker is passed in `ldflagsBefore' to allow # explicit overrides of the dynamic linker by callers to gcc/ld # (the *last* value counts, so ours should come first). - echo "-dynamic-linker $dynamicLinker" > $out/nix-support/libc-ldflags-before + echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before fi if test -n "$nativeTools"; then diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index 5a4ccba5eb38..c174af016757 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -85,7 +85,8 @@ stdenv.mkDerivation ({ if !nativeLibc then (if stdenv.system == "i686-linux" then "ld-linux.so.2" else if stdenv.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else - if stdenv.isArm then "ld-linux.so.3" else + # ARM with a wildcard, which can be "" or "-armhf". + if stdenv.isArm then "ld-linux*.so.3" else if stdenv.system == "powerpc-linux" then "ld.so.1" else if stdenv.system == "mips64el-linux" then "ld.so.1" else abort "don't know the name of the dynamic linker for this platform") From f05067545819e4312525560becbad7d284920547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 29 Dec 2012 23:14:25 +0000 Subject: [PATCH 40/47] unpack bootstrap tools arm: fix more rpaths libstdc++ and libmudflapth link to the dynamic loader; if the bootstrap uses another dynamic loader name, and the rpath of these libs isn't changed, they will fail to load. --- pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh index 28c9b0dcd586..1224abdeefb9 100644 --- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh +++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh @@ -23,7 +23,8 @@ for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i done -for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp*; do +for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp* \ + $out/lib/libstdc++* $out/lib/libmudflap*; do echo patching $i if ! test -f $i; then continue; fi if test -L $i; then continue; fi From 52ac6f96aa53b2eb82405caaececbeb75bceccb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 29 Dec 2012 23:21:18 +0000 Subject: [PATCH 41/47] Fix on prev commit: the bootstrap tools don't have libmudflap Out of glibc libs, only libstdc++ requires ld.so. --- pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh index 1224abdeefb9..5b9d5db90815 100644 --- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh +++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh @@ -24,7 +24,7 @@ for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i done for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp* \ - $out/lib/libstdc++* $out/lib/libmudflap*; do + $out/lib/libstdc++*.so; do echo patching $i if ! test -f $i; then continue; fi if test -L $i; then continue; fi From 0ba8b50e834c2ede59d2940e4fc31a29ddda1386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sat, 29 Dec 2012 23:46:00 +0000 Subject: [PATCH 42/47] Fixing again about libstdc++. I also move the 'echo patching' lines down, so they are printed only for files really patched. --- pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh index 5b9d5db90815..afa949c5deb2 100644 --- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh +++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh @@ -13,21 +13,21 @@ echo Patching the bootstrap tools... LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? $out/bin/cp $out/bin/patchelf . for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do - echo patching $i if test ${i%.la} != $i; then continue; fi if test ${i%*.so*} != $i; then continue; fi if ! test -f $i; then continue; fi if test -L $i; then continue; fi + echo patching $i LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i done for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp* \ - $out/lib/libstdc++*.so; do - echo patching $i + $out/lib/libstdc++*.so*[0-9]; do if ! test -f $i; then continue; fi if test -L $i; then continue; fi + echo patching $i LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ $out/bin/patchelf --set-rpath $out/lib --force-rpath $i LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ From cfdc532102c52ebe63fe51012362963ee7c0039b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 30 Dec 2012 13:50:31 +0000 Subject: [PATCH 43/47] Updating bootstrap tools to ones with glibc 2.17 This solves the problem of the change of name in ld.so between glibc 2.13 and 2.17 (at least for armhf). Some comments about it in https://github.com/NixOS/nixpkgs/issues/234#issuecomment-11764352 As there says, without this, gmp (after glibc built) tests crashed - segfault. --- pkgs/stdenv/linux/bootstrap/armv6l/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix index f8eef244fce1..ecda6be8bd32 100644 --- a/pkgs/stdenv/linux/bootstrap/armv6l/default.nix +++ b/pkgs/stdenv/linux/bootstrap/armv6l/default.nix @@ -8,8 +8,8 @@ bootstrapTools = { # Built from make-bootstrap-tools-crosspi.nix - # nixpkgs rev 87ec7b49b120950a260d9733de7f34d7c2bffb98 + # nixpkgs rev eb0422e4c1263a65a9b2b954fe10a1e03d67db3e url = http://viric.name/tmp/nix/pi/bootstrap-tools.cpio.bz2; - sha256 = "04qy8cqd30pqhil62b9sx67ijdspf9npx2snwwrcwvk3zbyhcll3"; + sha256 = "1zb27x5h54k51yrvn3sy4wb1qprx8iv2kfbgklxwc0mcxp9b7ccd"; }; } From d8b083497304ba58e8921a0a54e704d90be026b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 30 Dec 2012 13:53:48 +0000 Subject: [PATCH 44/47] unpack-bootstrap-tools: Removing the patch of libstdc++ Although patching it made some programs run (configure tests), some others crashed with segfault. So I don't think there is any win patching it. The proper way to solve the bootstrap in the raspberry pi is, as far as I've been testing, use glibc 2.17 libs in bootstrap-tools with the same ld.so name as the bootstrapped glibc. This is a problem inherent in our way to bootstrap, that first replaces the glibc of a given gcc+glibc (bootstrap-tools) with gcc-wrapper tricks, and then builds a new gcc. A nicer way would be to build a gcc without glibc, then the glibc, then the final gcc, as we do with cross-tools. Some comments about this problem in https://github.com/NixOS/nixpkgs/issues/234#issuecomment-11764352 --- pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh index afa949c5deb2..dcf819ad6f75 100644 --- a/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh +++ b/pkgs/stdenv/linux/scripts/unpack-bootstrap-tools-arm.sh @@ -23,8 +23,7 @@ for i in $out/bin/* $out/libexec/gcc/*/*/* $out/lib/librt*; do LD_LIBRARY_PATH=$out/lib $out/lib/ld-linux*.so.? \ $out/bin/patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib --force-rpath $i done -for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp* \ - $out/lib/libstdc++*.so*[0-9]; do +for i in $out/lib/librt* $out/lib/libcloog* $out/lib/libppl* $out/lib/libgmp*; do if ! test -f $i; then continue; fi if test -L $i; then continue; fi echo patching $i From 97d81bde0c1bcc1337e33c709c765021711aeff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Sun, 30 Dec 2012 21:55:02 +0000 Subject: [PATCH 45/47] Adding platform gcc information for raspberrypi, and the gcc support. Without it, gcc builds for softfloat, and the glibc doesn't have support for softfloat (it ends up requiring some gnu-soft.h file). We'll have to test if this fixes the build of gcc or not, though. --- .../development/compilers/gcc/4.6/default.nix | 42 ++++++++++++++----- pkgs/top-level/platforms.nix | 5 +++ 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index 09980da8fe14..2c572380d04c 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -87,18 +87,37 @@ let version = "4.6.3"; javaAwtGtk = langJava && gtk != null; - /* Cross-gcc settings */ - gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross; - gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; - gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; - gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross; - withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; - withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; - withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; - withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; - crossMingw = (cross != null && cross.libc == "msvcrt"); + /* Platform flags */ + platformFlags = let + gccArch = stdenv.lib.attrByPath [ "platform" "gcc" "arch" ] null stdenv; + gccCpu = stdenv.lib.attrByPath [ "platform" "gcc" "cpu" ] null stdenv; + gccAbi = stdenv.lib.attrByPath [ "platform" "gcc" "abi" ] null stdenv; + gccFpu = stdenv.lib.attrByPath [ "platform" "gcc" "fpu" ] null stdenv; + gccFloat = stdenv.lib.attrByPath [ "platform" "gcc" "float" ] null stdenv; + withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; + withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; + withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; + withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; + withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; + in + (withArch + + withCpu + + withAbi + + withFpu + + withFloat); - crossConfigureFlags = + /* Cross-gcc settings */ + crossMingw = (cross != null && cross.libc == "msvcrt"); + crossConfigureFlags = let + gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross; + gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; + gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; + gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross; + withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; + withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; + withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; + withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; + in "--target=${cross.config}" + withArch + withCpu + @@ -300,6 +319,7 @@ stdenv.mkDerivation ({ ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} ${if !bootstrap then "--disable-bootstrap" else ""} + ${if cross == null then platformFlags else ""} "; targetConfig = if cross != null then cross.config else null; diff --git a/pkgs/top-level/platforms.nix b/pkgs/top-level/platforms.nix index c53b41958a45..7bd72d13a687 100644 --- a/pkgs/top-level/platforms.nix +++ b/pkgs/top-level/platforms.nix @@ -222,6 +222,11 @@ rec { uboot = "sheevaplug"; # Only for uboot = uboot : ubootConfig = "sheevaplug_config"; + gcc = { + arch = "armv6"; + fpu = "vfp"; + float = "hard"; + }; }; guruplug = sheevaplug // { From ba7cde015699c037aea4a47c0e7d2787f4d740bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Mon, 31 Dec 2012 09:32:11 +0000 Subject: [PATCH 46/47] Porting the platform gcc flags support to gcc 4.7 --- .../development/compilers/gcc/4.6/default.nix | 104 +++++------ .../development/compilers/gcc/4.7/default.nix | 161 ++++++++++-------- 2 files changed, 144 insertions(+), 121 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index 2c572380d04c..74edfe80c1d8 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -118,59 +118,59 @@ let version = "4.6.3"; withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; in - "--target=${cross.config}" + - withArch + - withCpu + - withAbi + - withFpu + - (if crossMingw && crossStageStatic then - " --with-headers=${libcCross}/include" + - " --with-gcc" + - " --with-gnu-as" + - " --with-gnu-ld" + - " --with-gnu-ld" + - " --disable-shared" + - " --disable-nls" + - " --disable-debug" + - " --enable-sjlj-exceptions" + - " --enable-threads=win32" + - " --disable-win32-registry" - else if crossStageStatic then - " --disable-libssp --disable-nls" + - " --without-headers" + - " --disable-threads " + - " --disable-libmudflap " + - " --disable-libgomp " + - " --disable-libquadmath" + - " --disable-shared" + - " --disable-decimal-float" # libdecnumber requires libc - else - " --with-headers=${libcCross}/include" + - " --enable-__cxa_atexit" + - " --enable-long-long" + - (if crossMingw then - " --enable-threads=win32" + - " --enable-sjlj-exceptions" + - " --enable-hash-synchronization" + - " --disable-libssp" + - " --disable-nls" + - " --with-dwarf2" + - # I think noone uses shared gcc libs in mingw, so we better do the same. - # In any case, mingw32 g++ linking is broken by default with shared libs, - # unless adding "-lsupc++" to any linking command. I don't know why. + "--target=${cross.config}" + + withArch + + withCpu + + withAbi + + withFpu + + (if crossMingw && crossStageStatic then + " --with-headers=${libcCross}/include" + + " --with-gcc" + + " --with-gnu-as" + + " --with-gnu-ld" + + " --with-gnu-ld" + " --disable-shared" + - (if cross.config == "x86_64-w64-mingw32" then - # To keep ABI compatibility with upstream mingw-w64 - " --enable-fully-dynamic-string" - else "") - else (if cross.libc == "uclibc" then - # In uclibc cases, libgomp needs an additional '-ldl' - # and as I don't know how to pass it, I disable libgomp. - " --disable-libgomp" else "") + - " --enable-threads=posix" + - " --enable-nls" + - " --disable-decimal-float") # No final libdecnumber (it may work only in 386) - ); + " --disable-nls" + + " --disable-debug" + + " --enable-sjlj-exceptions" + + " --enable-threads=win32" + + " --disable-win32-registry" + else if crossStageStatic then + " --disable-libssp --disable-nls" + + " --without-headers" + + " --disable-threads " + + " --disable-libmudflap " + + " --disable-libgomp " + + " --disable-libquadmath" + + " --disable-shared" + + " --disable-decimal-float" # libdecnumber requires libc + else + " --with-headers=${libcCross}/include" + + " --enable-__cxa_atexit" + + " --enable-long-long" + + (if crossMingw then + " --enable-threads=win32" + + " --enable-sjlj-exceptions" + + " --enable-hash-synchronization" + + " --disable-libssp" + + " --disable-nls" + + " --with-dwarf2" + + # I think noone uses shared gcc libs in mingw, so we better do the same. + # In any case, mingw32 g++ linking is broken by default with shared libs, + # unless adding "-lsupc++" to any linking command. I don't know why. + " --disable-shared" + + (if cross.config == "x86_64-w64-mingw32" then + # To keep ABI compatibility with upstream mingw-w64 + " --enable-fully-dynamic-string" + else "") + else (if cross.libc == "uclibc" then + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + " --disable-libgomp" else "") + + " --enable-threads=posix" + + " --enable-nls" + + " --disable-decimal-float") # No final libdecnumber (it may work only in 386) + ); stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index 10783972a248..3978dbaac112 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -85,77 +85,99 @@ let version = "4.7.2"; javaAwtGtk = langJava && gtk != null; - /* Cross-gcc settings */ - gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross; - gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; - gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; - gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross; - gccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null cross; - gccMode = stdenv.lib.attrByPath [ "gcc" "mode" ] null cross; - withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; - withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; - withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; - withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; - withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; - withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; - crossMingw = (cross != null && cross.libc == "msvcrt"); + /* Platform flags */ + platformFlags = let + gccArch = stdenv.lib.attrByPath [ "platform" "gcc" "arch" ] null stdenv; + gccCpu = stdenv.lib.attrByPath [ "platform" "gcc" "cpu" ] null stdenv; + gccAbi = stdenv.lib.attrByPath [ "platform" "gcc" "abi" ] null stdenv; + gccFpu = stdenv.lib.attrByPath [ "platform" "gcc" "fpu" ] null stdenv; + gccFloat = stdenv.lib.attrByPath [ "platform" "gcc" "float" ] null stdenv; + gccMode = stdenv.lib.attrByPath [ "platform" "gcc" "mode" ] null stdenv; + withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; + withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; + withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; + withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; + withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; + withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; + in + (withArch + + withCpu + + withAbi + + withFpu + + withFloat + + withMode); - crossConfigureFlags = - "--target=${cross.config}" + - withArch + - withCpu + - withAbi + - withFpu + - withFloat + - withMode + - (if crossMingw && crossStageStatic then - " --with-headers=${libcCross}/include" + - " --with-gcc" + - " --with-gnu-as" + - " --with-gnu-ld" + - " --with-gnu-ld" + - " --disable-shared" + - " --disable-nls" + - " --disable-debug" + - " --enable-sjlj-exceptions" + - " --enable-threads=win32" + - " --disable-win32-registry" - else if crossStageStatic then - " --disable-libssp --disable-nls" + - " --without-headers" + - " --disable-threads " + - " --disable-libmudflap " + - " --disable-libgomp " + - " --disable-libquadmath" + - " --disable-shared" + - " --disable-decimal-float" # libdecnumber requires libc - else - " --with-headers=${libcCross}/include" + - " --enable-__cxa_atexit" + - " --enable-long-long" + - (if crossMingw then - " --enable-threads=win32" + - " --enable-sjlj-exceptions" + - " --enable-hash-synchronization" + - " --disable-libssp" + - " --disable-nls" + - " --with-dwarf2" + - # I think noone uses shared gcc libs in mingw, so we better do the same. - # In any case, mingw32 g++ linking is broken by default with shared libs, - # unless adding "-lsupc++" to any linking command. I don't know why. + /* Cross-gcc settings */ + crossMingw = (cross != null && cross.libc == "msvcrt"); + crossConfigureFlags = let + gccArch = stdenv.lib.attrByPath [ "gcc" "arch" ] null cross; + gccCpu = stdenv.lib.attrByPath [ "gcc" "cpu" ] null cross; + gccAbi = stdenv.lib.attrByPath [ "gcc" "abi" ] null cross; + gccFpu = stdenv.lib.attrByPath [ "gcc" "fpu" ] null cross; + gccFloat = stdenv.lib.attrByPath [ "gcc" "float" ] null cross; + gccMode = stdenv.lib.attrByPath [ "gcc" "mode" ] null cross; + withArch = if gccArch != null then " --with-arch=${gccArch}" else ""; + withCpu = if gccCpu != null then " --with-cpu=${gccCpu}" else ""; + withAbi = if gccAbi != null then " --with-abi=${gccAbi}" else ""; + withFpu = if gccFpu != null then " --with-fpu=${gccFpu}" else ""; + withFloat = if gccFloat != null then " --with-float=${gccFloat}" else ""; + withMode = if gccMode != null then " --with-mode=${gccMode}" else ""; + in + "--target=${cross.config}" + + withArch + + withCpu + + withAbi + + withFpu + + withFloat + + withMode + + (if crossMingw && crossStageStatic then + " --with-headers=${libcCross}/include" + + " --with-gcc" + + " --with-gnu-as" + + " --with-gnu-ld" + + " --with-gnu-ld" + " --disable-shared" + - (if cross.config == "x86_64-w64-mingw32" then - # To keep ABI compatibility with upstream mingw-w64 - " --enable-fully-dynamic-string" - else "") - else (if cross.libc == "uclibc" then - # In uclibc cases, libgomp needs an additional '-ldl' - # and as I don't know how to pass it, I disable libgomp. - " --disable-libgomp" else "") + - " --enable-threads=posix" + - " --enable-nls" + - " --disable-decimal-float") # No final libdecnumber (it may work only in 386) - ); + " --disable-nls" + + " --disable-debug" + + " --enable-sjlj-exceptions" + + " --enable-threads=win32" + + " --disable-win32-registry" + else if crossStageStatic then + " --disable-libssp --disable-nls" + + " --without-headers" + + " --disable-threads " + + " --disable-libmudflap " + + " --disable-libgomp " + + " --disable-libquadmath" + + " --disable-shared" + + " --disable-decimal-float" # libdecnumber requires libc + else + " --with-headers=${libcCross}/include" + + " --enable-__cxa_atexit" + + " --enable-long-long" + + (if crossMingw then + " --enable-threads=win32" + + " --enable-sjlj-exceptions" + + " --enable-hash-synchronization" + + " --disable-libssp" + + " --disable-nls" + + " --with-dwarf2" + + # I think noone uses shared gcc libs in mingw, so we better do the same. + # In any case, mingw32 g++ linking is broken by default with shared libs, + # unless adding "-lsupc++" to any linking command. I don't know why. + " --disable-shared" + + (if cross.config == "x86_64-w64-mingw32" then + # To keep ABI compatibility with upstream mingw-w64 + " --enable-fully-dynamic-string" + else "") + else (if cross.libc == "uclibc" then + # In uclibc cases, libgomp needs an additional '-ldl' + # and as I don't know how to pass it, I disable libgomp. + " --disable-libgomp" else "") + + " --enable-threads=posix" + + " --enable-nls" + + " --disable-decimal-float") # No final libdecnumber (it may work only in 386) + ); stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; @@ -308,6 +330,7 @@ stdenv.mkDerivation ({ ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} ${if !bootstrap then "--disable-bootstrap" else ""} + ${if cross == null then platformFlags else ""} "; targetConfig = if cross != null then cross.config else null; From 2402bb2613b80427feaeea1290c9f95702170584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Llu=C3=ADs=20Batlle=20i=20Rossell?= Date: Mon, 31 Dec 2012 09:38:32 +0000 Subject: [PATCH 47/47] gcc: Moving the arch=loongson2f to the current platform approach --- pkgs/development/compilers/gcc/4.6/default.nix | 2 -- pkgs/development/compilers/gcc/4.7/default.nix | 2 -- pkgs/top-level/platforms.nix | 1 + 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index 74edfe80c1d8..b2456eb33c28 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -313,8 +313,6 @@ stdenv.mkDerivation ({ ) ) } - ${ # Trick that should be taken out once we have a mips64el-linux not loongson2f - if cross == null && stdenv.system == "mips64el-linux" then "--with-arch=loongson2f" else ""} ${if langAda then " --enable-libada" else ""} ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} diff --git a/pkgs/development/compilers/gcc/4.7/default.nix b/pkgs/development/compilers/gcc/4.7/default.nix index 3978dbaac112..62a86751a712 100644 --- a/pkgs/development/compilers/gcc/4.7/default.nix +++ b/pkgs/development/compilers/gcc/4.7/default.nix @@ -324,8 +324,6 @@ stdenv.mkDerivation ({ ${if (stdenv ? glibc && cross == null) then " --with-native-system-header-dir=${stdenv.glibc}/include" else ""} - ${ # Trick that should be taken out once we have a mips64el-linux not loongson2f - if cross == null && stdenv.system == "mips64el-linux" then "--with-arch=loongson2f" else ""} ${if langAda then " --enable-libada" else ""} ${if cross == null && stdenv.isi686 then "--with-arch=i686" else ""} ${if cross != null then crossConfigureFlags else ""} diff --git a/pkgs/top-level/platforms.nix b/pkgs/top-level/platforms.nix index 7bd72d13a687..b879ea9fdeb9 100644 --- a/pkgs/top-level/platforms.nix +++ b/pkgs/top-level/platforms.nix @@ -378,5 +378,6 @@ rec { ''; kernelTarget = "vmlinux"; uboot = null; + gcc.arch = "loongson2f"; }; }