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