bootstrap-tools-musl: WIP
This commit is contained in:
parent
a0af2aadb6
commit
0e16989d39
@ -14,5 +14,5 @@ derivation {
|
|||||||
# Needed by the GCC wrapper.
|
# Needed by the GCC wrapper.
|
||||||
langC = true;
|
langC = true;
|
||||||
langCC = true;
|
langCC = true;
|
||||||
isGNU = true;
|
isGNU = false;
|
||||||
}
|
}
|
||||||
|
@ -26,18 +26,19 @@ for i in $out/bin/* $out/libexec/gcc/*/*/*; do
|
|||||||
./patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i"
|
./patchelf --set-interpreter $LD_BINARY --set-rpath $out/lib --force-rpath "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
for i in $out/lib/librt-*.so $out/lib/libpcre*; do
|
for i in $out/lib/libiconv*.so $out/lib/libpcre* $out/lib/libc.so; do
|
||||||
if [ -L "$i" ]; then continue; fi
|
if [ -L "$i" ]; then continue; fi
|
||||||
echo patching "$i"
|
echo patching "$i"
|
||||||
$out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
|
$out/bin/patchelf --set-rpath $out/lib --force-rpath "$i"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fix the libc linker script.
|
|
||||||
export PATH=$out/bin
|
export PATH=$out/bin
|
||||||
cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp
|
|
||||||
mv $out/lib/libc.so.tmp $out/lib/libc.so
|
# Fix the libc linker script.
|
||||||
cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp
|
#cat $out/lib/libc.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libc.so.tmp
|
||||||
mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
|
#mv $out/lib/libc.so.tmp $out/lib/libc.so
|
||||||
|
#cat $out/lib/libpthread.so | sed "s|/nix/store/e*-[^/]*/|$out/|g" > $out/lib/libpthread.so.tmp
|
||||||
|
#mv $out/lib/libpthread.so.tmp $out/lib/libpthread.so
|
||||||
|
|
||||||
# Provide some additional symlinks.
|
# Provide some additional symlinks.
|
||||||
ln -s bash $out/bin/sh
|
ln -s bash $out/bin/sh
|
||||||
|
@ -46,7 +46,7 @@ in with pkgs; rec {
|
|||||||
set -x
|
set -x
|
||||||
mkdir -p $out/bin $out/lib $out/libexec
|
mkdir -p $out/bin $out/lib $out/libexec
|
||||||
|
|
||||||
'' + (if (targetPlatform.libc == "glibc") then ''
|
'' + (if (hostPlatform.libc == "glibc") then ''
|
||||||
# Copy what we need of Glibc.
|
# Copy what we need of Glibc.
|
||||||
cp -d ${libc.out}/lib/ld*.so* $out/lib
|
cp -d ${libc.out}/lib/ld*.so* $out/lib
|
||||||
cp -d ${libc.out}/lib/libc*.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 -exec rm {} \;
|
||||||
find $out/include -name ..install.cmd -exec rm {} \;
|
find $out/include -name ..install.cmd -exec rm {} \;
|
||||||
mv $out/include $out/include-glibc
|
mv $out/include $out/include-glibc
|
||||||
'' else if (targetPlatform.libc == "musl") then ''
|
'' else if (hostPlatform.libc == "musl") then ''
|
||||||
# Copy what we need from musl
|
# Copy what we need from musl
|
||||||
cp ${libc.out}/lib/* $out/lib
|
cp ${libc.out}/lib/* $out/lib
|
||||||
cp -rL ${libc.dev}/include $out
|
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
|
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 -exec rm {} \;
|
||||||
find $out/include -name ..install.cmd -exec rm {} \;
|
find $out/include -name ..install.cmd -exec rm {} \;
|
||||||
|
mv $out/include $out/include-libc
|
||||||
'' else throw "unsupported libc for bootstrap tools")
|
'' else throw "unsupported libc for bootstrap tools")
|
||||||
+ ''
|
+ ''
|
||||||
# Copy coreutils, bash, etc.
|
# Copy coreutils, bash, etc.
|
||||||
@ -137,6 +138,8 @@ in with pkgs; rec {
|
|||||||
cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
|
cp -d ${libmpc.out}/lib/libmpc*.so* $out/lib
|
||||||
cp -d ${zlib.out}/lib/libz.so* $out/lib
|
cp -d ${zlib.out}/lib/libz.so* $out/lib
|
||||||
cp -d ${libelf}/lib/libelf.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) ''
|
'' + lib.optionalString (hostPlatform != buildPlatform) ''
|
||||||
# These needed for cross but not native tools because the stdenv
|
# 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 = runCommand "bootstrap-tools.tar.xz" {} "cp ${build}/on-server/bootstrap-tools.tar.xz $out";
|
||||||
};
|
};
|
||||||
|
|
||||||
bootstrapTools = import ./bootstrap-tools {
|
bootstrapTools = if (hostPlatform.libc == "glibc") then
|
||||||
|
import ./bootstrap-tools {
|
||||||
inherit (hostPlatform) system;
|
inherit (hostPlatform) system;
|
||||||
inherit bootstrapFiles;
|
inherit bootstrapFiles;
|
||||||
};
|
}
|
||||||
|
else if (hostPlatform.libc == "musl") then
|
||||||
|
import ./bootstrap-tools-musl {
|
||||||
|
inherit (hostPlatform) system;
|
||||||
|
inherit bootstrapFiles;
|
||||||
|
}
|
||||||
|
else throw "unsupported libc";
|
||||||
|
|
||||||
test = derivation {
|
test = derivation {
|
||||||
name = "test-bootstrap-tools";
|
name = "test-bootstrap-tools";
|
||||||
@ -226,10 +236,17 @@ in with pkgs; rec {
|
|||||||
grep --version
|
grep --version
|
||||||
gcc --version
|
gcc --version
|
||||||
|
|
||||||
|
'' + lib.optionalString (hostPlatform.libc == "glibc") ''
|
||||||
ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?)
|
ldlinux=$(echo ${bootstrapTools}/lib/ld-linux*.so.?)
|
||||||
export CPP="cpp -idirafter ${bootstrapTools}/include-glibc -B${bootstrapTools}"
|
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 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"
|
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 <stdio.h>' >> foo.c
|
||||||
echo '#include <limits.h>' >> foo.c
|
echo '#include <limits.h>' >> foo.c
|
||||||
|
Loading…
x
Reference in New Issue
Block a user