bootstrap-tools-musl: WIP

+31 -13
+1 -1
pkgs/stdenv/linux/bootstrap-tools-musl/default.nix
··· 14 14 # Needed by the GCC wrapper. 15 15 langC = true; 16 16 langCC = true; 17 - isGNU = true; 17 + isGNU = false; 18 18 }
+7 -6
pkgs/stdenv/linux/bootstrap-tools-musl/scripts/unpack-bootstrap-tools.sh
··· 26 26 ./patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i" 27 27 done 28 28 29 - for i in $out/lib/librt-*.so $out/lib/libpcre*; do 29 + for i in $out/lib/libiconv*.so $out/lib/libpcre* $out/lib/libc.so; do 30 30 if [ -L "$i" ]; then continue; fi 31 31 echo patching "$i" 32 32 $out/bin/patchelf --set-rpath $out/lib --force-rpath "$i" 33 33 done 34 + 35 + export PATH=$out/bin 34 36 35 37 # Fix the libc linker script. 36 - export PATH=$out/bin 37 - cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp 38 - mv $out/lib/libc.so.tmp $out/lib/libc.so 39 - cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp 40 - mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so 38 + #cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp 39 + #mv $out/lib/libc.so.tmp $out/lib/libc.so 40 + #cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp 41 + #mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so 41 42 42 43 # Provide some additional symlinks. 43 44 ln -s bash $out/bin/sh
+23 -6
pkgs/stdenv/linux/make-bootstrap-tools.nix
··· 46 46 set -x 47 47 mkdir -p $out/bin $out/lib $out/libexec 48 48 49 - '' + (if (targetPlatform.libc == "glibc") then '' 49 + '' + (if (hostPlatform.libc == "glibc") then '' 50 50 # Copy what we need of Glibc. 51 51 cp -d ${libc.out}/lib/ld*.so* $out/lib 52 52 cp -d ${libc.out}/lib/libc*.so* $out/lib ··· 77 77 find $out/include -name .install -exec rm {} \; 78 78 find $out/include -name ..install.cmd -exec rm {} \; 79 79 mv $out/include $out/include-glibc 80 - '' else if (targetPlatform.libc == "musl") then '' 80 + '' else if (hostPlatform.libc == "musl") then '' 81 81 # Copy what we need from musl 82 82 cp ${libc.out}/lib/* $out/lib 83 83 cp -rL ${libc.dev}/include $out ··· 86 86 rm -rf $out/include/mtd $out/include/rdma $out/include/sound $out/include/video 87 87 find $out/include -name .install -exec rm {} \; 88 88 find $out/include -name ..install.cmd -exec rm {} \; 89 + mv $out/include $out/include-libc 89 90 '' else throw "unsupported libc for bootstrap tools") 90 91 + '' 91 92 # Copy coreutils, bash, etc. ··· 137 138 cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib 138 139 cp -d ${zlib.out}/lib/libz.so* $out/lib 139 140 cp -d ${libelf}/lib/libelf.so* $out/lib 141 + '' + lib.optionalString (hostPlatform.libc == "musl") '' 142 + cp -d ${libiconv.out}/lib/libiconv*.so* $out/lib 140 143 141 144 '' + lib.optionalString (hostPlatform != buildPlatform) '' 142 145 # These needed for cross but not native tools because the stdenv ··· 200 203 bootstrapTools = runCommand "bootstrap-tools.tar.xz" {} "cp ${build}/on-server/bootstrap-tools.tar.xz $out"; 201 204 }; 202 205 203 - bootstrapTools = import ./bootstrap-tools { 204 - inherit (hostPlatform) system; 205 - inherit bootstrapFiles; 206 - }; 206 + bootstrapTools = if (hostPlatform.libc == "glibc") then 207 + import ./bootstrap-tools { 208 + inherit (hostPlatform) system; 209 + inherit bootstrapFiles; 210 + } 211 + else if (hostPlatform.libc == "musl") then 212 + import ./bootstrap-tools-musl { 213 + inherit (hostPlatform) system; 214 + inherit bootstrapFiles; 215 + } 216 + else throw "unsupported libc"; 207 217 208 218 test = derivation { 209 219 name = "test-bootstrap-tools"; ··· 226 236 grep --version 227 237 gcc --version 228 238 239 + '' + lib.optionalString (hostPlatform.libc == "glibc") '' 229 240 ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?) 230 241 export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}" 231 242 export CC="gcc -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib" 232 243 export CXX="g++ -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib" 244 + '' + lib.optionalString (hostPlatform.libc == "musl") '' 245 + ldmusl=$(echo ${bootstrapTools}/lib/ld-musl*.so.?) 246 + export CPP="cpp -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools}" 247 + export CC="gcc -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib" 248 + export CXX="g++ -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib" 249 + '' + '' 233 250 234 251 echo '#include <stdio.h>' >> foo.c 235 252 echo '#include <limits.h>' >> foo.c