Topic
  • 3 replies
  • Latest Post - ‏2012-11-16T13:13:34Z by PowerLinuxFAQ
PowerLinuxFAQ
PowerLinuxFAQ
18 Posts

Pinned topic Re-building AT 5.0 components for debug

‏2012-11-15T19:26:10Z |
I have recently been stumped on a pthread_mutex_lock programming issue on my POWER7 server.  
 
To debug it, I wanted to re-build the AT5.0 glibc components so that I could add some debug to figure out why the owner field of the mutex can't be set to zero.  
 
My attempts to rebuild the at5.0-src tree are not going very well, and was wondering if there was a document or hints describing the process?
Updated on 2012-11-16T13:13:34Z at 2012-11-16T13:13:34Z by PowerLinuxFAQ
  • ryanarn
    ryanarn
    1 Post

    Re: Re-building AT 5.0 components for debug

    ‏2012-11-15T23:14:30Z  
    Building toolchains is complicated, so I'm not surprised that you're encountering problems.
     
    Technically, all you need to do is use the Advance Toolchain to rebuild GLIBC and then copy the resultant shared objects into the /opt/at5.0/lib[64]/power7/ directories.  In practice it's a bit more complicated, since that directory has tuned versions of the shared objects.
     
    The glibc source from the at5.0 src tree should be complete so you can start there.
     
    I'm assuming you're building your application with -m64. 
     
    We'll assume your src is in ${src} directory and you have a separate build directory called ${build}
     
    Before you replace the existing libraries make sure that you back them up so you can restore them later: 
     
     cp /opt/at5.0/lib64/power7/libc-2.13.so \
    /opt/at5.0/lib64/power7/libc-2.13.so.back

    cp /opt/at5.0/lib64/power7/libm-2.13.so \
    /opt/at5.0/lib64/power7/libm-2.13.so.back

    cp /opt/at5.0/lib64/power7/librt-2.13.so \
    /opt/at5.0/lib64/power7/librt-2.13.so.back

    cp /opt/at5.0/lib64/power7/libpthread-2.13.so \
    /opt/at5.0/lib64/power7/libpthread-2.13.so.back

    cp /opt/at5.0/lib64/power7/libthread_db-1.0.so \
    /opt/at5.0/lib64/power7/libthread_db-1.0.so.back

    cp /opt/at5.0/lib64/power7/libc.a \
    /opt/at5.0/lib64/power7/libc.a.back

    cp /opt/at5.0/lib64/power7/libm.a \
    /opt/at5.0/lib64/power7/libm.a.back

    cp /opt/at5.0/lib64/power7/librt.a \
    /opt/at5.0/lib64/power7/librt.a.back

    cp /opt/at5.0/lib64/power7/libpthread.a \
    /opt/at5.0/lib64/power7/libpthread.a.back
     
    Here's a bash script that should work for you. 
     
    #!/bin/bash
    cd ${build} 
    export PATH=/opt/at5.0/bin:$PATH 
    echo slibdir="/opt/at5.0"/lib64 > configparms
    echo bindir="/opt/at5.0"/bin64 >> configparms
    echo sbindir="/opt/at5.0"/sbin64 >> configparms
    echo rootsbindir="/opt/at5.0"/sbin64 >> configparms
    CC="/opt/at5.0/bin/gcc -m64" \
    CXX="/opt/at5.0/bin/g++ -m64" \
    CFLAGS="-mlong-double-128 -O3 -g" \
    AUTOCONF="/usr/local/bin/autoconf" \
        ${src}/configure \
        --build=powerpc64-linux \
        --host=powerpc64-linux \
        --prefix="/opt/at5.0" \
        --libdir="/opt/at5.0"/lib64 \
        --libexecdir="/opt/at5.0"/libexec64 \
        --with-headers="/opt/at5.0"/include \
        --with-tls \
        --with-__thread \
        --enable-shared \
        --enable-multi-arch \
        --enable-experimental-malloc \
        --without-cvs \
        --enable-add-ons=nptl \
        --with-cpu=power7 \
        --enable-kernel="2.6.16" 2>&1 | tee _configure64_power7
    make -j <pick-a-number> 2>&1 | tee _make64_power7
    make install install_root="${build}/install/power7" 2>&1 | tee _install64_power7
     
    # Now that the objects are built you need to copy over the existing AT versions in the lib64/power7/ directory. 
     cp "${build}/install/power7/opt/at5.0/lib64/libc-2.13.so" "/opt/at5.0/lib64/power7/"

    cp "${build}/install/power7/opt/at5.0/lib64/libm-2.13.so" "/opt/at5.0/lib64/power7/"

    cp "${build}/install/power7/opt/at5.0/lib64/librt-2.13.so" "/opt/at5.0/lib64/power7/"

    cp "${build}/install/power7/opt/at5.0/lib64/libpthread-2.13.so" "/opt/at5.0/lib64/power7/"

    cp "${build}/install/power7/opt/at5.0/lib64/libthread_db-1.0.so" "/opt/at5.0/lib64/power7/"

    cp "${build}/install/power7/opt/at5.0/lib64/libc.a" "/opt/at5.0/lib64/power7/"

    cp "${build}/install/power7/opt/at5.0/lib64/libm.a" "/opt/at5.0/lib64/power7/"

    cp "${build}/install/power7/opt/at5.0/lib64/librt.a" "/opt/at5.0/lib64/power7/"
  • Bill_Buros
    Bill_Buros
    160 Posts

    Re: Re-building AT 5.0 components for debug

    ‏2012-11-16T13:07:40Z  
     And on behalf of Steve Munroe..    who observed...
     
    The Mutex owner field is only maintained for recursive Mutexes and so should be zero for any mutex that is not recursive. Thus the assert.

    So either this pthread_mutex_t has not been initialized or there has been a data clobber. So I would suggest Valgrind/Helgrind tool or Valgrind/Memcheck
  • PowerLinuxFAQ
    PowerLinuxFAQ
    18 Posts

    Re: Re-building AT 5.0 components for debug

    ‏2012-11-16T13:13:34Z  
     And on behalf of Steve Munroe..    who observed...
     
    The Mutex owner field is only maintained for recursive Mutexes and so should be zero for any mutex that is not recursive. Thus the assert.

    So either this pthread_mutex_t has not been initialized or there has been a data clobber. So I would suggest Valgrind/Helgrind tool or Valgrind/Memcheck
    I do think it is a data clobber.  However, I suspect that valgrind won't work with huge memory maps, right?  Perhaps there is a trick to use valgrind with huge memory?  I am using my own mmap of huge memory which is carved up by my memory allocation function.  I can fall back to normal malloc if need be.