xref: /aosp_15_r20/external/pytorch/.ci/docker/common/install_glibc.sh (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1#!/bin/bash
2
3set -ex
4
5[ -n "$GLIBC_VERSION" ]
6if [[ -n "$CENTOS_VERSION" ]]; then
7  [ -n "$DEVTOOLSET_VERSION" ]
8fi
9
10yum install -y wget sed
11
12mkdir -p /packages && cd /packages
13wget -q http://ftp.gnu.org/gnu/glibc/glibc-$GLIBC_VERSION.tar.gz
14tar xzf glibc-$GLIBC_VERSION.tar.gz
15if [[ "$GLIBC_VERSION" == "2.26" ]]; then
16  cd glibc-$GLIBC_VERSION
17  sed -i 's/$name ne "nss_test1"/$name ne "nss_test1" \&\& $name ne "nss_test2"/' scripts/test-installation.pl
18  cd ..
19fi
20mkdir -p glibc-$GLIBC_VERSION-build && cd glibc-$GLIBC_VERSION-build
21
22if [[ -n "$CENTOS_VERSION" ]]; then
23  export PATH=/opt/rh/devtoolset-$DEVTOOLSET_VERSION/root/usr/bin:$PATH
24fi
25
26../glibc-$GLIBC_VERSION/configure --prefix=/usr CFLAGS='-Wno-stringop-truncation -Wno-format-overflow -Wno-restrict -Wno-format-truncation -g -O2'
27make -j$(nproc)
28make install
29
30# Cleanup
31rm -rf /packages
32rm -rf /var/cache/yum/*
33rm -rf /var/lib/rpm/__db.*
34yum clean all
35