Skip to content

Instantly share code, notes, and snippets.

@beakthoven
Last active May 4, 2025 12:55
Show Gist options
  • Save beakthoven/240736992abf0ea6f0ee1d8acb57a400 to your computer and use it in GitHub Desktop.
Save beakthoven/240736992abf0ea6f0ee1d8acb57a400 to your computer and use it in GitHub Desktop.
A script for patching toolchains to resolve glibc requirement issues on distros with old glibc packages. ( DEPRECATED ) ( FUNCTIONALITY MOVED TO https://github.com/Neutron-Toolchains/antman )
#!/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
@retrozenith
Copy link

retrozenith commented Mar 4, 2024

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)

@beakthoven
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment