icu: Fix cross-building.

The icu4c cross-build process requires access to a full buildRoot of a
native build, so we add a variant of the build that just does the
buildPhase and copies the buildRoot to $out for access by the cross
compile.

+86 -53
+77 -48
pkgs/development/libraries/icu/base.nix
··· 1 1 { version, sha256, patches ? [], patchFlags ? "" }: 2 - { stdenv, fetchurl, fetchpatch, fixDarwinDylibNames }: 2 + { stdenv, fetchurl, fetchpatch, fixDarwinDylibNames 3 + # Cross-compiled icu4c requires a build-root of a native compile 4 + , buildRootOnly ? false, nativeBuildRoot, buildPlatform, hostPlatform 5 + }: 3 6 4 7 let 5 8 pname = "icu4c"; 6 - in 7 - stdenv.mkDerivation { 8 - name = pname + "-" + version; 9 9 10 - src = fetchurl { 11 - url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-" 12 - + (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz"; 13 - inherit sha256; 14 - }; 10 + baseAttrs = { 11 + src = fetchurl { 12 + url = "http://download.icu-project.org/files/${pname}/${version}/${pname}-" 13 + + (stdenv.lib.replaceChars ["."] ["_"] version) + "-src.tgz"; 14 + inherit sha256; 15 + }; 16 + 17 + postUnpack = '' 18 + sourceRoot=''${sourceRoot}/source 19 + echo Source root reset to ''${sourceRoot} 20 + ''; 21 + 22 + # https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27 23 + postPatch = if (stdenv.hostPlatform.libc == "glibc" || stdenv.hostPlatform.libc == "musl") 24 + then "substituteInPlace i18n/digitlst.cpp --replace '<xlocale.h>' '<locale.h>'" 25 + else null; # won't find locale_t on darwin 26 + 27 + inherit patchFlags patches; 28 + 29 + preConfigure = '' 30 + sed -i -e "s|/bin/sh|${stdenv.shell}|" configure 15 31 16 - outputs = [ "out" "dev" ]; 17 - outputBin = "dev"; 32 + # $(includedir) is different from $(prefix)/include due to multiple outputs 33 + sed -i -e 's|^\(CPPFLAGS = .*\) -I\$(prefix)/include|\1 -I$(includedir)|' config/Makefile.inc.in 34 + '' + stdenv.lib.optionalString stdenv.isArm '' 35 + # From https://archlinuxarm.org/packages/armv7h/icu/files/icudata-stdlibs.patch 36 + sed -e 's/LDFLAGSICUDT=-nodefaultlibs -nostdlib/LDFLAGSICUDT=/' -i config/mh-linux 37 + ''; 18 38 19 - # FIXME: This fixes dylib references in the dylibs themselves, but 20 - # not in the programs in $out/bin. 21 - buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; 39 + configureFlags = "--disable-debug" + 40 + stdenv.lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) " --enable-rpath" + 41 + stdenv.lib.optionalString (buildPlatform != hostPlatform) " --with-cross-build=${nativeBuildRoot}"; 22 42 23 - postUnpack = '' 24 - sourceRoot=''${sourceRoot}/source 25 - echo Source root reset to ''${sourceRoot} 26 - ''; 43 + enableParallelBuilding = true; 27 44 28 - # https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27 29 - postPatch = if (stdenv.hostPlatform.libc == "glibc" || stdenv.hostPlatform.libc == "musl") 30 - then "substituteInPlace i18n/digitlst.cpp --replace '<xlocale.h>' '<locale.h>'" 31 - else null; # won't find locale_t on darwin 45 + meta = with stdenv.lib; { 46 + description = "Unicode and globalization support library"; 47 + homepage = http://site.icu-project.org/; 48 + maintainers = with maintainers; [ raskin ]; 49 + platforms = platforms.all; 50 + }; 51 + }; 32 52 33 - inherit patchFlags patches; 53 + realAttrs = baseAttrs // { 54 + name = pname + "-" + version; 34 55 35 - preConfigure = '' 36 - sed -i -e "s|/bin/sh|${stdenv.shell}|" configure 56 + outputs = [ "out" "dev" ]; 57 + outputBin = "dev"; 37 58 38 - # $(includedir) is different from $(prefix)/include due to multiple outputs 39 - sed -i -e 's|^\(CPPFLAGS = .*\) -I\$(prefix)/include|\1 -I$(includedir)|' config/Makefile.inc.in 40 - '' + stdenv.lib.optionalString stdenv.isArm '' 41 - # From https://archlinuxarm.org/packages/armv7h/icu/files/icudata-stdlibs.patch 42 - sed -e 's/LDFLAGSICUDT=-nodefaultlibs -nostdlib/LDFLAGSICUDT=/' -i config/mh-linux 43 - ''; 59 + # FIXME: This fixes dylib references in the dylibs themselves, but 60 + # not in the programs in $out/bin. 61 + buildInputs = stdenv.lib.optional stdenv.isDarwin fixDarwinDylibNames; 44 62 45 - configureFlags = "--disable-debug" + 46 - stdenv.lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) " --enable-rpath"; 63 + # remove dependency on bootstrap-tools in early stdenv build 64 + postInstall = stdenv.lib.optionalString stdenv.isDarwin '' 65 + sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/${version}/pkgdata.inc 66 + '' + '' 67 + substituteInPlace "$dev/bin/icu-config" \ 68 + --replace \''${pkglibdir}/Makefile.inc "$dev/lib/icu/Makefile.inc" 69 + ''; 47 70 48 - # remove dependency on bootstrap-tools in early stdenv build 49 - postInstall = stdenv.lib.optionalString stdenv.isDarwin '' 50 - sed -i 's/INSTALL_CMD=.*install/INSTALL_CMD=install/' $out/lib/icu/${version}/pkgdata.inc 51 - '' + '' 52 - substituteInPlace "$dev/bin/icu-config" \ 53 - --replace \''${pkglibdir}/Makefile.inc "$dev/lib/icu/Makefile.inc" 54 - ''; 71 + postFixup = ''moveToOutput lib/icu "$dev" ''; 72 + }; 55 73 56 - postFixup = ''moveToOutput lib/icu "$dev" ''; 74 + buildRootOnlyAttrs = baseAttrs // { 75 + name = pname + "-build-root-" + version; 57 76 58 - enableParallelBuilding = true; 77 + preConfigure = baseAttrs.preConfigure + '' 78 + mkdir build 79 + cd build 80 + configureScript=../configure 81 + ''; 59 82 60 - meta = with stdenv.lib; { 61 - description = "Unicode and globalization support library"; 62 - homepage = http://site.icu-project.org/; 63 - maintainers = with maintainers; [ raskin ]; 64 - platforms = platforms.all; 83 + postBuild = '' 84 + cd .. 85 + mv build $out 86 + echo "Doing build-root only, exiting now" >&2 87 + exit 0 88 + ''; 65 89 }; 66 - } 90 + 91 + attrs = if buildRootOnly 92 + then buildRootOnlyAttrs 93 + else realAttrs; 94 + in 95 + stdenv.mkDerivation attrs
+9 -5
pkgs/top-level/all-packages.nix
··· 9210 9210 9211 9211 hyena = callPackage ../development/libraries/hyena { }; 9212 9212 9213 - icu58 = callPackage ../development/libraries/icu/58.nix 9213 + icu58 = callPackage ../development/libraries/icu/58.nix { 9214 + nativeBuildRoot = buildPackages.icu58.override { buildRootOnly = true; }; 9215 + } // 9214 9216 (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { 9215 9217 stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4' 9216 9218 }); 9217 - icu59 = callPackage ../development/libraries/icu/59.nix 9218 - (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { 9219 + icu59 = callPackage ../development/libraries/icu/59.nix { 9220 + nativeBuildRoot = buildPackages.icu59.override { buildRootOnly = true; }; 9221 + } // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { 9219 9222 stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4' 9220 9223 }); 9221 - icu60 = callPackage ../development/libraries/icu/60.nix 9222 - (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { 9224 + icu60 = callPackage ../development/libraries/icu/60.nix { 9225 + nativeBuildRoot = buildPackages.icu60.override { buildRootOnly = true; }; 9226 + } // (stdenv.lib.optionalAttrs (stdenv.cc.isGNU && stdenv.hostPlatform.isi686) { 9223 9227 stdenv = overrideCC stdenv gcc6; # with gcc-7: undefined reference to `__divmoddi4' 9224 9228 }); 9225 9229