-
-
Save beakthoven/240736992abf0ea6f0ee1d8acb57a400 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
WORK_DIR=$(pwd) | |
cd "$HOME" || exit | |
echo "Downloading patchelf binary from ArchLinux repos" | |
mkdir -p patchelf-temp | |
#curl -L https://github.com/Jebaitedneko/docker/raw/ubuntu/patchelf | |
curl -L https://archlinux.org/packages/community/x86_64/patchelf/download | bsdtar -C patchelf-temp -xf - | |
mv "$HOME"/patchelf-temp/usr/bin/patchelf "$HOME"/ | |
rm -rf "$HOME"/patchelf-temp | |
echo "Downloading latest glibc from ArchLinux repos" | |
mkdir -p glibc | |
curl -L https://archlinux.org/packages/core/x86_64/glibc/download | bsdtar -C glibc -xf - | |
curl -L https://archlinux.org/packages/core/x86_64/lib32-glibc/download | bsdtar -C glibc -xf - | |
ln -svf "$HOME"/glibc/usr/lib "$HOME"/glibc/usr/lib64 | |
echo "Patching glibc" | |
for bin in $(find "$HOME"/glibc -type f -exec file {} \; | grep 'ELF .* interpreter' | awk '{print $1}'); do | |
bin="${bin::-1}" | |
echo "Patching: $bin" | |
"$HOME"/patchelf --set-rpath "$HOME"/glibc/usr/lib --force-rpath --set-interpreter "$HOME"/glibc/usr/lib/ld-linux-x86-64.so.2 "$bin" | |
done | |
echo "Patching Toolchain" | |
for bin in $(find "$WORK_DIR" -type f -exec file {} \; | grep 'ELF .* interpreter' | awk '{print $1}'); do | |
bin="${bin::-1}" | |
echo "Patching: $bin" | |
"$HOME"/patchelf --add-rpath "$HOME"/glibc/usr/lib --force-rpath --set-interpreter "$HOME"/glibc/usr/lib/ld-linux-x86-64.so.2 "$bin" | |
done | |
echo "Cleaning" | |
rm -rf "$HOME"/patchelf |
Hi. I am trying to build my Android Kernel (SM8350 Kernel https://github.com/glikched/android_kernel_samsung_sm8350). But it seems something needs to be also patched.
Info: WSL2 Ubuntu 22.04.4 LTS on Windows 10 x86_64 (5.15.133.1-microsoft-standard-WSL2)
Error:
ld.lld: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by ld.lld)
Hi. I am trying to build my Android Kernel (SM8350 Kernel https://github.com/glikched/android_kernel_samsung_sm8350). But it seems something needs to be also patched.
Info: WSL2 Ubuntu 22.04.4 LTS on Windows 10 x86_64 (5.15.133.1-microsoft-standard-WSL2)
Error: ld.lld: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by ld.lld)
This script's functionality has been moved to antman utility and since v2.4 update it can handle glibcxx patching along with glibc. Please migrate to antman utility for patching your toolchain.
Oh right I completely forgot that I use NixOS binaries in antman, I did it because NixOS release binaries are statically linked against musl libc, This allows the patchelf binary to be executed on platforms with very old glibc where ArchLinux's patchelf which is linked against newer glibc won't work.
So I think there is no changes required to be made in antman and users of this particular script can also safely migrate to antman.