summary refs log tree commit diff
path: root/pkgs/stdenv/linux/make-bootstrap-tools.nix
diff options
context:
space:
mode:
authorWill Dietz <w@wdtz.org>2018-01-05 16:26:46 -0600
committerWill Dietz <w@wdtz.org>2018-02-13 09:44:37 -0600
commit0e16989d398d4bd5ea587f3b3fe01e2e47342b5d (patch)
tree90f596da388378fb68ca6d789042a720254c8ebf /pkgs/stdenv/linux/make-bootstrap-tools.nix
parenta0af2aadb6aed0221de594026e4ba7af90524c3b (diff)
downloadnixpkgs-0e16989d398d4bd5ea587f3b3fe01e2e47342b5d.tar
nixpkgs-0e16989d398d4bd5ea587f3b3fe01e2e47342b5d.tar.gz
nixpkgs-0e16989d398d4bd5ea587f3b3fe01e2e47342b5d.tar.bz2
nixpkgs-0e16989d398d4bd5ea587f3b3fe01e2e47342b5d.tar.lz
nixpkgs-0e16989d398d4bd5ea587f3b3fe01e2e47342b5d.tar.xz
nixpkgs-0e16989d398d4bd5ea587f3b3fe01e2e47342b5d.tar.zst
nixpkgs-0e16989d398d4bd5ea587f3b3fe01e2e47342b5d.zip
bootstrap-tools-musl: WIP
Diffstat (limited to 'pkgs/stdenv/linux/make-bootstrap-tools.nix')
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix29
1 files changed, 23 insertions, 6 deletions
diff --git a/pkgs/stdenv/linux/make-bootstrap-tools.nix b/pkgs/stdenv/linux/make-bootstrap-tools.nix
index aae0c135d30..b659e259ee1 100644
--- a/pkgs/stdenv/linux/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/linux/make-bootstrap-tools.nix
@@ -46,7 +46,7 @@ in with pkgs; rec {
         set -x
         mkdir -p $out/bin $out/lib $out/libexec
 
-      '' + (if (targetPlatform.libc == "glibc") then ''
+      '' + (if (hostPlatform.libc == "glibc") then ''
         # Copy what we need of Glibc.
         cp -d ${libc.out}/lib/ld*.so* $out/lib
         cp -d ${libc.out}/lib/libc*.so* $out/lib
@@ -77,7 +77,7 @@ in with pkgs; rec {
         find $out/include -name .install -exec rm {} \;
         find $out/include -name ..install.cmd -exec rm {} \;
         mv $out/include $out/include-glibc
-    '' else if (targetPlatform.libc == "musl") then ''
+    '' else if (hostPlatform.libc == "musl") then ''
         # Copy what we need from musl
         cp ${libc.out}/lib/* $out/lib
         cp -rL ${libc.dev}/include $out
@@ -86,6 +86,7 @@ in with pkgs; rec {
         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-libc
     '' else throw "unsupported libc for bootstrap tools")
     + ''
         # Copy coreutils, bash, etc.
@@ -137,6 +138,8 @@ in with pkgs; rec {
         cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
         cp -d ${zlib.out}/lib/libz.so* $out/lib
         cp -d ${libelf}/lib/libelf.so* $out/lib
+      '' + lib.optionalString (hostPlatform.libc == "musl") ''
+        cp -d ${libiconv.out}/lib/libiconv*.so* $out/lib
 
       '' + lib.optionalString (hostPlatform != buildPlatform) ''
         # These needed for cross but not native tools because the stdenv
@@ -200,10 +203,17 @@ in with pkgs; rec {
     bootstrapTools = runCommand "bootstrap-tools.tar.xz" {} "cp ${build}/on-server/bootstrap-tools.tar.xz $out";
   };
 
-  bootstrapTools = import ./bootstrap-tools {
-    inherit (hostPlatform) system;
-    inherit bootstrapFiles;
-  };
+  bootstrapTools = if (hostPlatform.libc == "glibc") then
+    import ./bootstrap-tools {
+      inherit (hostPlatform) system;
+      inherit bootstrapFiles;
+    }
+    else if (hostPlatform.libc == "musl") then
+    import ./bootstrap-tools-musl {
+      inherit (hostPlatform) system;
+      inherit bootstrapFiles;
+    }
+    else throw "unsupported libc";
 
   test = derivation {
     name = "test-bootstrap-tools";
@@ -226,10 +236,17 @@ in with pkgs; rec {
       grep --version
       gcc --version
 
+    '' + lib.optionalString (hostPlatform.libc == "glibc") ''
       ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?)
       export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}"
       export CC="gcc -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
       export CXX="g++ -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools} -Wl,-dynamic-linker,$ldlinux -Wl,-rpath,${bootstrapTools}/lib"
+    '' + lib.optionalString (hostPlatform.libc == "musl") ''
+      ldmusl=$(echo ${bootstrapTools}/lib/ld-musl*.so.?)
+      export CPP="cpp -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools}"
+      export CC="gcc -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib"
+      export CXX="g++ -idirafter ${bootstrapTools}/include-libc -B${bootstrapTools} -Wl,-dynamic-linker,$ldmusl -Wl,-rpath,${bootstrapTools}/lib"
+    '' + ''
 
       echo '#include <stdio.h>' >> foo.c
       echo '#include <limits.h>' >> foo.c