git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #39486 from dtzWill/fix/musl-provide-iconv-tool

musl: provide 'iconv' utility like other libc's

commita1349f0a3be43fe1f840d90b816f82a341a467c1 authorMichael Raskin <7c6f434c@mail.ru> dateWed 25 Apr 2018, 15:42 (9 years ago) parent6c748ae558f742
4 files changed+29−5
pkgs/os-specific/linux/musl/default.nix+28−1 pkgs/stdenv/linux/bootstrap-tools-musl/scripts/unpack-bootstrap-tools.sh+1−1 pkgs/stdenv/linux/default.nix−1 pkgs/stdenv/linux/make-bootstrap-tools.nix−2
pkgs/os-specific/linux/musl/default.nix+28−1
@@ -17,6 +17,16 @@ let
1717 sha256 = "14igk6k00bnpfw660qhswagyhvr0gfqg4q55dxvaaq7ikfkrir71";
1818 };
1919
20+ # iconv tool, implemented by musl author.
21+ # Original: http://git.etalabs.net/cgit/noxcuse/plain/src/iconv.c?id=02d288d89683e99fd18fe9f54d4e731a6c474a4f
22+ # We use copy from Alpine which fixes error messages, see:
23+ # https://git.alpinelinux.org/cgit/aports/commit/main/musl/iconv.c?id=a3d97e95f766c9c378194ee49361b375f093b26f
24+ iconv_c = fetchurl {
25+ name = "iconv.c";
26+ url = "https://git.alpinelinux.org/cgit/aports/plain/main/musl/iconv.c?id=a3d97e95f766c9c378194ee49361b375f093b26f";
27+ sha256 = "1mzxnc2ncq8lw9x6n7p00fvfklc9p3wfv28m68j0dfz5l8q2k6pp";
28+ };
29+
2030in
2131stdenv.mkDerivation rec {
2232 name = "musl-${version}";
@@ -41,6 +51,13 @@ stdenv.mkDerivation rec {
4151 --replace -fno-asynchronous-unwind-tables ""
4252 '';
4353
54+ patches = [
55+ # Minor touchup to build system making dynamic linker symlink relative
56+ (fetchurl {
57+ url = https://raw.githubusercontent.com/openwrt/openwrt/87606e25afac6776d1bbc67ed284434ec5a832b4/toolchain/musl/patches/300-relative.patch;
58+ sha256 = "0hfadrycb60sm6hb6by4ycgaqc9sgrhh42k39v8xpmcvdzxrsq2n";
59+ })
60+ ];
4461 preConfigure = ''
4562 configureFlagsArray+=("--syslibdir=$out/lib")
4663 '';
@@ -58,6 +75,8 @@ stdenv.mkDerivation rec {
5875 dontDisableStatic = true;
5976 separateDebugInfo = true;
6077
78+ NIX_DONT_SET_RPATH = true;
79+
6180 postInstall = ''
6281 # Not sure why, but link in all but scsi directory as that's what uclibc/glibc do.
6382 # Apparently glibc provides scsi itself?
@@ -68,7 +87,7 @@ stdenv.mkDerivation rec {
6887 mkdir -p $out/bin
6988
7089 # Create 'ldd' symlink, builtin
71− ln -s $out/lib/libc.so $out/bin/ldd
90+ ln -rs $out/lib/libc.so $out/bin/ldd
7291
7392 # (impure) cc wrapper around musl for interactive usuage
7493 for i in musl-gcc musl-clang ld.musl-clang; do
@@ -77,6 +96,14 @@ stdenv.mkDerivation rec {
7796 moveToOutput lib/musl-gcc.specs $dev
7897 substituteInPlace $dev/bin/musl-gcc \
7998 --replace $out/lib/musl-gcc.specs $dev/lib/musl-gcc.specs
99+
100+ # provide 'iconv' utility, using just-built headers, libc/ldso
101+ $CC ${iconv_c} -o $out/bin/iconv \
102+ -I$dev/include \
103+ -L$out/lib -Wl,-rpath=$out/lib \
104+ -lc \
105+ -B $out/lib \
106+ -Wl,-dynamic-linker=$(ls $out/lib/ld-*)
80107 '' + lib.optionalString useBSDCompatHeaders ''
81108 install -D ${queue_h} $dev/include/sys/queue.h
82109 install -D ${cdefs_h} $dev/include/sys/cdefs.h
pkgs/stdenv/linux/bootstrap-tools-musl/scripts/unpack-bootstrap-tools.sh+1−1
@@ -26,7 +26,7 @@ for i in $out/bin/* $out/libexec/gcc/*/*/*; do
2626 ./patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i"
2727done
2828
29−for i in $out/lib/libiconv*.so $out/lib/libpcre* $out/lib/libc.so; do
29+for i in $out/lib/libpcre* $out/lib/libc.so; do
3030 if [ -L "$i" ]; then continue; fi
3131 echo patching "$i"
3232 $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
pkgs/stdenv/linux/default.nix−1
@@ -362,7 +362,6 @@ in
362362 ++ [ /*propagated from .dev*/ linuxHeaders
363363 binutils gcc gcc.cc gcc.cc.lib gcc.expand-response-params
364364 ]
365− ++ lib.optional (localSystem.libc == "musl") libiconv
366365 ++ lib.optionals localSystem.isAarch64
367366 [ prevStage.updateAutotoolsGnuConfigScriptsHook prevStage.gnu-config ];
368367
pkgs/stdenv/linux/make-bootstrap-tools.nix−2
@@ -136,8 +136,6 @@ in with pkgs; rec {
136136 cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
137137 cp -d ${zlib.out}/lib/libz.so* $out/lib
138138 cp -d ${libelf}/lib/libelf.so* $out/lib
139− '' + lib.optionalString (hostPlatform.libc == "musl") ''
140− cp -d ${libiconv.out}/lib/libiconv*.so* $out/lib
141139
142140 '' + lib.optionalString (hostPlatform != buildPlatform) ''
143141 # These needed for cross but not native tools because the stdenv