Using Sun Studio for open source apps

Resources for building open source apps with Sun Studio compilers

This page is a place holder so I can write things down and not forget them.
I'm sure there are lots of good tutorials and white papers around too. I'll try to go dig some up and put links here.

Porting tips

Eric Boutilier has collected a lot good info about building FOSS apps on Solaris with Sun Studio http://www.genunix.org/wiki/index.php/Category:Porting_FOSS_applications

Page of tuning information for a selection of popular open source applications http://wikis.sun.com/display/AppPerfTuning/Application+Performance+Tuning+Home

gccfss

One way of building Solaris SPARC applications that were designed for GCC compilers (gcc and g++) is to use the gccfss compilers. They are a distribution of the GCC compilers with the Sun optimizing SPARC backend. gccfss is not included in the Sun Studio product at this point, you can download it as part of the CoolTools suite.

For more info about gccfss: http://cooltools.sunsource.net/gcc/

Related topics:

Alan's tips and tricks

Note: These need to be formatted, and some of them might belong on a different page.

-- GNU autoconf checks

 - Is Sun Studio compiler in use?

    AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])

 - Can -xc99 be used?

    # -xc99 is only in Sun/Forte cc 6.2 and later
    # It enables C99-ism's such as inline & C++ comments
    AC_MSG_CHECKING([whether Sun/Forte cc -xc99 option works])
    save_CFLAGS="${CFLAGS}"
    CFLAGS="${CFLAGS} -xc99"
    AC_TRY_COMPILE([inline int foo () {return 0; }],
        [int a = foo();], AC_MSG_RESULT([yes]),
        AC_MSG_RESULT([no])
        AC_MSG_CHECKING([[whether Sun/Forte cc -xc99=%all,no_lib option works]])
        [CFLAGS="${save_CFLAGS} -xc99=%all,no_lib"]
        AC_TRY_COMPILE([inline int foo () {return 0; }],
                [int a = foo();], AC_MSG_RESULT([yes]),
                CFLAGS="$save_CFLAGS -xCC" ; AC_MSG_RESULT([no])))


 - Common compiler flags

   if test "$GCC" = "yes" ; then
    SHAREDLIB_LDFLAGS="-shared"
    DEPEND_CCFLAGS="-MM"
    OPTIMIZER_CFLAGS="-O2"
    OPTIMIZER_CXXFLAGS="-O2"
    WARNING_CFLAGS="-Wall"
   fi

   if test "$SUNCC" = "yes" ; then
    SHAREDLIB_LDFLAGS="-G"
    DEPEND_CCFLAGS="-xM1"
    OPTIMIZER_CFLAGS="-xO4 -xlibmil -xdepend"
    OPTIMIZER_CXXFLAGS="-xO4 -xlibmil"
    WARNING_CFLAGS="-v"
   fi

-- C source code

 - Symbol visibility attributes:

   Note that GCC allows these at the end of function declarations,
   but Sun Studio requires them at the beginning, such as:
   EXPORT void foo(int bar);

#if defined(__GNUC__) && (__GNUC__ >= 4)
# define EXPORT		__attribute__((visibility("default")))
# define HIDDEN		__attribute__((visibility("hidden")))
# define INTERNAL	__attribute__((visibility("internal")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
# define EXPORT		__global
# define HIDDEN		__hidden
# define INTERNAL	__hidden
#else /* not gcc >= 4 and not Sun Studio >= 8 */
# define EXPORT
# define HIDDEN
# define INTERNAL
#endif /* GNUC >= 4 */

 - Weak symbols:

#if defined(__ELF__) && defined(__GNUC__) && (__GNUC__ >= 3)
#define weak __attribute__((weak))
#else
#define weak
#endif

#ifdef __SUNPRO_C
#pragma weak foo
#endif

weak int foo(int bar);

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact