AIX Open Source

 View Only
  • 1.  compile/linking troubles with aixtoolbox utilities

    Posted Wed June 24, 2020 06:36 AM
    Edited by C- -T Wed June 24, 2020 09:40 AM
    hi,

    i need to compile a self contained httpd distribution,  which need stricts library search paths in the binaries. i found out that
    something is messing up the resulting binaries.

    i use the following build settings, mostly stolen from your httpd spec file:

    export OBJECT_MODE=64
    
    export AR="/usr/bin/ar -X64"
    export LD="/usr/bin/ld"
    export RM="/usr/bin/rm -f"
    
    
    export CC="/usr/bin/gcc"
    export CXX="/usr/bin/g++"
    export LTFLAGS="--tag=CC --silent"
    export CFLAGS="-maix64 -fsigned-char -D_LARGE_FILES -O2 -I$OPENSSLSPATH/include -I/opt/freeware/include"
    export LDFLAGS="-L$APPATH/lib -L$OPENSSLPATH/lib -L/opt/freeware/lib64 -L/opt/freeware/lib -Wl,-blibpath:$APPATH/lib:/usr/lib:/lib"
    export CXXFLAGS=$CFLAGS
    ​


    the resulting bins contains a messed up search path (httpd for example):

    root@aixbuildhostng: /tmp/apatest/bin # dump -X64 -ovH httpd
    
    httpd:
    
                            ***Object Module Header***
    # Sections      Symbol Ptr      # Symbols       Opt Hdr Len     Flags
             4      0x00000000              0               120     0x100f
    Flags=( RELFLG EXEC LNNO LSYMS DYNLOAD DEP_SYSTEM )
    Timestamp = "Jun 24 12:17:59 2020"
    Magic = 0x1f7  (64-bit XCOFF)
    
                            ***Optional Header***
    Tsize       Dsize       Bsize       Tstart      Dstart
    0x00077ad4  0x0000c59c  0x00003898  0x10000240  0x20000d14
    
    SNloader    SNentry     SNtext      SNtoc       SNdata
    0x0004      0x0002      0x0001      0x0002      0x0002
    
    TXTalign    DATAalign   TOC         vstamp      entry
    0x0007      0x0004      0x2000bcc8  0x0001      0x200061a0
    
    maxSTACK    maxDATA     SNbss       magic       modtype
    0x00000000  0x00000000  0x0003      0x010b        1L
    
                            ***Loader Section***
                          Loader Header Information
    VERSION#         #SYMtableENT     #RELOCent        LENidSTR
    0x00000001       0x000006c1       0x000012ee       0x000000c3
    
    #IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL
    0x00000007       0x0001d130       0x00009267       0x0001d1f3
    
    
                            ***Import File Strings***
    INDEX  PATH                          BASE                MEMBER
    0      /opt/freeware/lib:/tmp/apatest/lib:/tmp/apatest/lib:/usr/lib:/lib
    1                                    libpcre.a           libpcre.so.1
    2                                    libaprutil-1.so
    3                                    libexpat.a          libexpat.so.1
    4                                    libapr-1.so
    5                                    libpthread.a        shr_xpg5_64.o
    6                                    libc.a              shr_64.o
    


    Index0 should contain only "/tmp//apatest/lib:/usr/lib:/lib" IMHO. i highly supsect some auttool/libtool rubbish acting up somewhere somehow.
    funnily this only concern the binaries (httpd,ab...), the modules are all correctly linked.
    any hints whats going on, i'm out of ideas?

    i also filed a bug in the apache tracker -> https://bz.apache.org/bugzilla/show_bug.cgi?id=64557



    ------------------------------
    I regret starting this entire conversation
    ------------------------------


  • 2.  RE: compile/linking troubles with aixtoolbox utilities

    Posted Wed June 24, 2020 09:03 AM
    i tried to relink with rtl_enable but this kills the binary...

    rtl_enable -X64 -o /tmp/aptest/bin/httpd_fixed /tmp/aptest/bin/httpd -blibpath:/tmp/aptest/lib:/usr/lib:/lib
    
    root@aixbuildhostng: /home/packagebuilder/apache2-itsv # dump -X64 -ovH /tmp/aptest/bin/httpd_fixed
    
    /tmp/aptest/bin/httpd_fixed:
    
                            ***Object Module Header***
    # Sections      Symbol Ptr      # Symbols       Opt Hdr Len     Flags
             4      0x00000000              0               120     0x100f
    Flags=( RELFLG EXEC LNNO LSYMS DYNLOAD DEP_SYSTEM )
    Timestamp = "Jun 24 14:53:19 2020"
    Magic = 0x1f7  (64-bit XCOFF)
    
                            ***Optional Header***
    Tsize       Dsize       Bsize       Tstart      Dstart
    0x0007f098  0x0000dc68  0x00003890  0x00000000  0x00000000
    
    SNloader    SNentry     SNtext      SNtoc       SNdata
    0x0004      0x0002      0x0001      0x0002      0x0002
    
    TXTalign    DATAalign   TOC         vstamp      entry
    0x0007      0x0004      0x0000afb8  0x0001      0x00005490
    
    maxSTACK    maxDATA     SNbss       magic       modtype
    0x00000000  0x00000000  0x0003      0x010b        1L
    
                            ***Loader Section***
                          Loader Header Information
    VERSION#         #SYMtableENT     #RELOCent        LENidSTR
    0x00000001       0x000006c1       0x000015c6       0x0000009f
    
    #IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL
    0x00000007       0x0001feb0       0x00009267       0x0001ff4f
    
    
                            ***Import File Strings***
    INDEX  PATH                          BASE                MEMBER
    0      /tmp/aptest/lib:/usr/lib:/lib
    1                                    libc.a              shr_64.o
    2                                    libpthread.a        shr_xpg5_64.o
    3                                    libapr-1.so
    4                                    libpcre.a           libpcre.so.1
    5                                    libaprutil-1.so
    6                                    libexpat.a          libexpat.so.1
    
    
    root@aixbuildhostng: /home/packagebuilder/apache2-itsv #  /tmp/aptest/bin/httpd_fixed -t -D DUMP_MODULES
    Illegal instruction​


    ------------------------------
    I regret starting this entire conversation
    ------------------------------



  • 3.  RE: compile/linking troubles with aixtoolbox utilities

    Posted Wed June 24, 2020 09:46 AM
    You need to look into the libtool script. For AIX Toolbox httpd build , " /opt/freeware/lib/apr-1/build/libtool " is used. 
    In that you need to check this " hardcode_libdir_flag_spec " value.

    ------------------------------
    Ayappan P
    ------------------------------



  • 4.  RE: compile/linking troubles with aixtoolbox utilities

    Posted Wed June 24, 2020 10:49 AM
    thank your for saving my day !

    for reference, doing the following fixes up the runtime linking problems:

    after configure is run:
    
    /opt/freeware/bin/sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' $BUILDPATH/httpd/srclib/apr/libtool
    
    result:
    
    root@aixbuildhostng: /tmp/aptest/bin # dump -X64 -ovH httpd
    
    httpd:
    
                            ***Object Module Header***
    # Sections      Symbol Ptr      # Symbols       Opt Hdr Len     Flags
             4      0x00000000              0               120     0x100f
    Flags=( RELFLG EXEC LNNO LSYMS DYNLOAD DEP_SYSTEM )
    Timestamp = "Jun 24 16:40:12 2020"
    Magic = 0x1f7  (64-bit XCOFF)
    
                            ***Optional Header***
    Tsize       Dsize       Bsize       Tstart      Dstart
    0x00077ad4  0x0000c59c  0x00003898  0x10000240  0x20000d14
    
    SNloader    SNentry     SNtext      SNtoc       SNdata
    0x0004      0x0002      0x0001      0x0002      0x0002
    
    TXTalign    DATAalign   TOC         vstamp      entry
    0x0007      0x0004      0x2000bcc8  0x0001      0x200061a0
    
    maxSTACK    maxDATA     SNbss       magic       modtype
    0x00000000  0x00000000  0x0003      0x010b        1L
    
                            ***Loader Section***
                          Loader Header Information
    VERSION#         #SYMtableENT     #RELOCent        LENidSTR
    0x00000001       0x000006c1       0x000012ee       0x0000009f
    
    #IMPfilID        OFFidSTR         LENstrTBL        OFFstrTBL
    0x00000007       0x0001d130       0x00009267       0x0001d1cf
    
    
                            ***Import File Strings***
    INDEX  PATH                          BASE                MEMBER
    0      /tmp/aptest/lib:/usr/lib:/lib
    1                                    libpcre.a           libpcre.so.1
    2                                    libaprutil-1.so
    3                                    libexpat.a          libexpat.so.1
    4                                    libapr-1.so
    5                                    libpthread.a        shr_xpg5_64.o
    6                                    libc.a              shr_64.o
    root@aixbuildhostng: /tmp/aptest/bin # ldd httpd
    httpd needs:
             /tmp/aptest/lib/libpcre.a(libpcre.so.1)
             /tmp/aptest/lib/libaprutil-1.so
             /tmp/aptest/lib/libexpat.a(libexpat.so.1)
             /tmp/aptest/lib/libapr-1.so
             /usr/lib/libpthread.a(shr_xpg5_64.o)
             /usr/lib/libc.a(shr_64.o)
             /tmp/aptest/lib/libgcc_s.a(shr.o)
             /tmp/aptest/lib/libiconv.a(libiconv.so.2)
             /unix
             /usr/lib/libcrypt.a(shr_64.o)
    ​


    ------------------------------
    I regret starting this entire conversation
    ------------------------------



  • 5.  RE: compile/linking troubles with aixtoolbox utilities

    Posted Wed June 24, 2020 03:48 PM
    i digged a little deeper and i think i found the root cause.

    apr_source_distributiom/build/libtool.m4

    # Determine the default libpath from the value encoded in an
            # empty executable.
            _LT_SYS_MODULE_PATH_AIX([$1])
            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"
            _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag
          else
    	if test ia64 = "$host_cpu"; then
    	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib'
    	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
    	  _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"
    	else
    	 # Determine the default libpath from the value encoded in an
    	 # empty executable.
    	 _LT_SYS_MODULE_PATH_AIX([$1])
    	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath"​

    not shure how to fix this up, libtool is one of my "kryptonites", still would be nice to convince the apache guys to patch this.

    ------------------------------
    I regret starting this entire conversation
    ------------------------------



  • 6.  RE: compile/linking troubles with aixtoolbox utilities

    Posted Thu June 25, 2020 02:07 AM
    I don't see a problem with the script.
    $wl-blibpath:$libdir:'"$aix_libpath" . This makes sense because $libdir is nothing but "$prefix+lib". So if somebody want to build self -contained httpd distribution, they have to set proper prefix also along with -blibpath.

    ------------------------------
    Ayappan P
    ------------------------------