Porting Bible

  • Views Views: 1,283
  • Last updated Last updated:
  • This is a list of failures and exits that one may experience when porting software to IRIX. This list may include methods to overcome these failures.

    Issue: (.text.startup+0x7e0): undefined reference to `dirname'
    Fix: Run export LIBS="-lgen" before running ./configure.

    Issue: With software using Boost, exiting due to a bad context for shared_ptr
    Fix: Prepend boost:: to all failing references to shared_ptr

    Issue: Compiler complaining about something being used or referenced in the wrong way
    Example:
    Code:
    /usr/didbs/0_1_9_n32_mips3_gcc/include/boost/bind/bind.hpp:1284:48:   required from 'class boost::_bi::bind_t<boost::_bi::unspecified, int, boo$
    t::_bi::list2<boost::_bi::value<const sockaddr*>, boost::_bi::value<int> > >'
    tcpreceiver.cc:561:59: required from here

    ------------------


    546 #if !WIN32 && HAVE_IPV6
    547 for(vector<string>::const_iterator laddr=locals6.begin();laddr!=locals6.end();++laddr) {
    548 int s=socket(AF_INET6,SOCK_STREAM,0);
    549
    550 if(s<0)
    551 throw AhuException("Unable to acquire TCPv6 socket: "+stringerror());
    552
    553 ComboAddress local(*laddr, ::arg().asNum("local-port"));
    554
    555 int tmp=1;
    556 if(setsockopt(s,SOL_SOCKET,SO_REUSEADDR,(char*)&tmp,sizeof tmp)<0) {
    557 L<<Logger::Error<<"Setsockopt failed"<<endl;
    558 exit(1);
    559 }
    560
    561 if(bind(s, (const sockaddr*)&local, local.getSocklen())<0) {
    562 L<<Logger::Error<<"binding to TCP socket: "<<strerror(errno)<<endl;
    563 throw AhuException("Unable to bind to TCPv6 socket");
    564 }
    565
    566 listen(s,128);
    567 L<<Logger::Error<<"TCPv6 server bound to "<<local.toStringWithPort()<<endl;
    568 d_sockets.push_back(s);
    569 FD_SET(s, &d_rfds);
    570 d_highfd=max(s,d_highfd);
    571 }
    572 #endif // WIN32
    Fix: Could be that the code uses a name for something that is named the same as something in the OS. Reduce the context by prepending :: to the item name. In the above case, changing bind to ::bind resolved the issue.

    Issue: You'd like to case a section of code to only be referenced in IRIX
    Fix: Use the #define __sgi macro, then case around your code
    Example:
    C:
    #define __sgi

    #... more stuff

    #ifdef __sgi
    # do some sgi stuff
    #endif

    Issue:
    • Compilation fails due to unknown storage size of 'tv'
    Example:
    Code:

    src/ftbench.c:179:22: error: storage size of 'tv' isn't known
    179 | struct timespec tv;
    Fix: Add sys/time.h
    Code:

    #if defined(__sgi)
    #include <sys/time.h>
    #endif


    Issue:
    • error: 'CLOCK_SGI_CYCLE' undeclared
    Example:
    Code:

    src/ftbench.c:193:5: warning: implicit declaration of function 'clock_gettime' [-Wimplicit-function-declaration]
    193 | clock_gettime( CLOCK_SGI_CYCLE, &tv );
    Fix: Add sys/ptimers.h
    Code:

    #if defined(__sgi)
    #include <sys/ptimers.h>
    #endif


    ...

    #ifdef _POSIX_CPUTIME
    clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &tv );
    #elif defined(__sgi)
    clock_gettime( CLOCK_SGI_CYCLE, &tv );
    #else
    clock_gettime( CLOCK_REALTIME, &tv );
    #endif /* _POSIX_CPUTIME */


    Issue: the code defines something by a name that's already used elsewhere (normally in IRIX /usr/include)
    Fix: Give up and rename this thing everywhere in the source code
    Example:
    C:
    ./makehelp < ../tf-lib/tf-help > ../tf-lib/tf-help.idx
    In file included from socket.c:67:
    tfio.h:156:15: error: conflicting types for 'wprintf'
    156 | extern void wprintf(const char *fmt, ...) format_printf(1, 2);
    | ^~~~~~~
    In file included from /usr/include/wchar.h:11,
    from /usr/include/inttypes.h:243,
    from /usr/sgug/include/openssl/e_os2.h:243,
    from /usr/sgug/include/openssl/ssl.h:15,
    from socket.c:33:
    /usr/sgug/lib/gcc/mips-sgi-irix6.5/9/include-fixed/internal/wchar_core.h:182:12: note: previous declaration of 'wprintf' was here
    182 | extern int wprintf(const wchar_t * __restrict, ...);
    | ^~~~~~~

    ----------------

    Porting with RPM

    Issue: you need a patch
    Fix:
    • Extract and duplicate the source code directory
    • Fix the code and generate the patch
      • diff -Naur <source code.orig> <source code> > <source code>.irix.patch
    • Add a "Patch" line near the top of the specfile. Start with patch number 100.
      • Patch100: freetype.sgifixes.patch
    • Add "%patch" entry along with the rest of the %patch entries.
      • %patch100 -p1 -b .sgifixes

    Issue: "error: Failed build dependencies"
    Example:
    Code:
    error: Failed build dependencies:
    libX11-devel is needed by freetype-2.10.0-3.sgugalpha.mips
    Fix:
    • libX11 is specifically not installed by rpm (yet) in IRIX. Comment this section out in the specfile.

About us

  • Silicon Graphics User Group (SGUG) is a community for users, developers, and admirers of Silicon Graphics (SGI) products. We aim to be a friendly hobbyist community for discussing all aspects of SGIs, including use, software development, the IRIX Operating System, and troubleshooting, as well as facilitating hardware exchange.

User Menu