runtime/yolo-glibc.nix
λpkgs, sources?
| pkgs | |
| sources | default import../lib/sources.nix inherit pkgs; |
let
in
rec
This just builds the Fil-C glibc yolo fork with the normal host GCC toolchain.
pkgs.stdenv.mkDerivation
rec
"yolo-glibc-impl"
"2.44"
Use single output (glibc tries to split into multiple outputs by default)
"out"
true
export NIX_CFLAGS_COMPILE=""
export NIX_LDFLAGS=""
# Set up ccache manually
${setupCcache}
export CC="ccache gcc"
export CXX="ccache g++"
# glibc requires out-of-tree build
autoconf
cd ..
mkdir -p build
cd build
configureScript=$PWD/../$sourceRoot/configure
# Set these in shell so $out actually expands
configureFlagsArray+=(
"libc_cv_slibdir=$out/lib"
)
Rename yolo-glibc components so they don't conflict with normal glibc
mkdir -p $out/lib
cd $out/lib
# Copy all .o files
cp ${yolo-glibc-impl}/lib/*.o .
# Copy and rename static libs
cp ${yolo-glibc-impl}/lib/libc.a libyoloc.a
cp ${yolo-glibc-impl}/lib/libc_nonshared.a libyoloc_nonshared.a
cp ${yolo-glibc-impl}/lib/libm.a libyolom.a
cp ${yolo-glibc-impl}/lib/*.a . # Copy other .a files as-is
chmod -R u+w .
# Fil-C's glibc names its loader ld-fil1-x86_64.so itself. Patching
# the loader with patchelf misbehaves with some older kernels.
cp ${yolo-glibc-impl}/lib/${lib.dynamicLinker} .
# Copy and patch libc implementation
cp ${yolo-glibc-impl}/lib/libc.so.6 libyolocimpl.so
chmod u+w libyolocimpl.so
patchelf --set-soname libyolocimpl.so \
--set-rpath '$ORIGIN' \
libyolocimpl.so
# Copy and patch libm implementation
cp ${yolo-glibc-impl}/lib/libm.so.6 libyolomimpl.so
chmod u+w libyolomimpl.so
patchelf --set-soname libyolomimpl.so \
--replace-needed libc.so.6 libyolocimpl.so \
--set-rpath '$ORIGIN' \
libyolomimpl.so
# Create linker scripts
cat > libyolom.so <<'EOF'
OUTPUT_FORMAT(${lib.elfFormat})
GROUP(libyolomimpl.so)
EOF
cat > libyoloc.so <<'EOF'
OUTPUT_FORMAT(${lib.elfFormat})
GROUP(libyolocimpl.so libyoloc_nonshared.a AS_NEEDED(${lib.dynamicLinker}))
EOF