228
228
prepare_tcmalloc () {
229
229
if [[ " ${OSTYPE} " == " linux" * ]] && [[ -z " ${NO_TCMALLOC} " ]] && [[ -z " ${LD_PRELOAD} " ]]; then
230
230
# check glibc version
231
- LIBC_LIB=" $( PATH=/usr/sbin:$PATH ldconfig -p | grep -P " libc.so.6" | head -n 1) "
232
- LIBC_INFO=$( echo ${LIBC_LIB} | awk ' {print $NF}' )
233
- LIBC_VER=$( echo $( ${LIBC_INFO} | awk ' NR==1 {print $NF}' ) | grep -oP ' \d+\.\d+' )
231
+ LIBC_VER=$( echo $( ldd --version | awk ' NR==1 {print $NF}' ) | grep -oP ' \d+\.\d+' )
234
232
echo " glibc version is $LIBC_VER "
235
233
libc_vernum=$( expr $LIBC_VER )
236
234
# Since 2.34 libpthread is integrated into libc.so
@@ -245,9 +243,9 @@ prepare_tcmalloc() {
245
243
TC_INFO=(${TCMALLOC// =>/ } )
246
244
if [[ ! -z " ${TC_INFO} " ]]; then
247
245
echo " Check TCMalloc: ${TC_INFO} "
248
- # Determine if the library is linked to libptthread and resolve undefined symbol: ptthread_key_create
246
+ # Determine if the library is linked to libpthread and resolve undefined symbol: pthread_key_create
249
247
if [ $( echo " $libc_vernum < $libc_v234 " | bc) -eq 1 ]; then
250
- # glibc < 2.33 pthread_key_create into libpthead .so. check linking libpthread.so...
248
+ # glibc < 2.34 pthread_key_create into libpthread .so. check linking libpthread.so...
251
249
if ldd ${TC_INFO[2]} | grep -q ' libpthread' ; then
252
250
echo " $TC_INFO is linked with libpthread,execute LD_PRELOAD=${TC_INFO[2]} "
253
251
# set fullpath LD_PRELOAD (To be on the safe side)
@@ -257,7 +255,7 @@ prepare_tcmalloc() {
257
255
echo " $TC_INFO is not linked with libpthread will trigger undefined symbol: pthread_Key_create error"
258
256
fi
259
257
else
260
- # Version 2.34 of libc.so (glibc) includes the pthead library IN GLIBC. (USE ubuntu 22.04 and modern linux system and WSL)
258
+ # Version 2.34 of libc.so (glibc) includes the pthread library IN GLIBC. (USE ubuntu 22.04 and modern linux system and WSL)
261
259
# libc.so(glibc) is linked with a library that works in ALMOST ALL Linux userlands. SO NO CHECK!
262
260
echo " $TC_INFO is linked with libc.so,execute LD_PRELOAD=${TC_INFO[2]} "
263
261
# set fullpath LD_PRELOAD (To be on the safe side)
@@ -267,7 +265,7 @@ prepare_tcmalloc() {
267
265
fi
268
266
done
269
267
if [[ -z " ${LD_PRELOAD} " ]]; then
270
- printf " \e[1m\e[31mCannot locate TCMalloc. Do you have tcmalloc or gperftools installed on your system? (improves CPU memory usage)\e[0m\n"
268
+ printf " \e[1m\e[31mCannot locate TCMalloc. Do you have tcmalloc or google-perftool installed on your system? (improves CPU memory usage)\e[0m\n"
271
269
fi
272
270
fi
273
271
}
0 commit comments