On Friday 20 April 2007 07:14, Brad Hards wrote:
> I'm trying to test the kdesupport module using the SunStudio
> Express compiler. I am mainly trying to make sure that the Qt
> Cryptographic Architecture stuff will build, and that there aren't
> bugs in the code that sunstudio can identify.
>
> Note that I'm doing the testing on Linux (a Fedora Core 6 box).
>
> I'm not sure I'm doing it right. I've got the compiler installed,
> and it does at least start up. $ /opt/sun/sunstudio12/bin/CC -V
> CC: Sun C++ 5.9 Linux_i386 Build40_1 2007/02/09
>
> However I'm not able to get it going with cmake:
> CC="/opt/sun/sunstudio12/bin/c99"
> CXX="/opt/sun/sunstudio12/bin/CC"

[ snippy ]

Hi Brad

Sorry it took me a while to reply -- i actually installed Studio 12 
Express on my Linux laptop to make sure the flags are the same as on 
Solaris. :-)

Studio won't like -fPIC (and pretty much none of the GCC flags, 
actually).

Could you please try these:

export CPPFLAGS=-I/opt/sun/sunstudio12/prod/include/CC \
-I/opt/sun/sunstudio12/prod/include/CC/Cstd \
[ + add more includes here ]

For 32-bit:

export CFLAGS=" -Xc -erroff=%all -errshort=full -errfmt=error \
-errwarn=%none -xO3 -s -xjobs=2 -xregs=no%frameptr \
-xprefetch=auto -xprefetch_auto_type=indirect_array_access \
-xprefetch_level=3 -xbuiltin=%all -xcsi -xinline=%all \
-xustr=ascii_utf16_ushort -z combreloc -z redlocsym \
-z nodefaultlib -z now -z rescan \
-z absexec -xildoff -xldscope=symbolic \
-xrestrict=%all -xF=%none -xalias_level=std \
-xthreadvar -lc -lpthread -lposix4 -lrt \
-mt -D_REENTRANT -D__EXTENSIONS__=1 \
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 \
-D_XPG4 -D_XPG4_2 -D_XPG5 -D_XPG6 \
-D_POSIX_PTHREAD_SEMANTICS -D_XOPEN_SOURCE=600 \
-D_POSIX_C_SOURCE=200112L  -D_STDC_C99 \
-xtarget=pentium4 -xarch=sse2 \
-xchip=pentium4 -xcache=8/64/4:256/128/8"

[ some of the defines might have to be slightly adjusted for Linux, 
these are for Solaris]

export CXXFLAGS=" -features=%all,extensions,tmplife,tmplrefstatic \
-instances=global -template=geninlinefuncs -verbose=template \
-xO3 -s -xlang=c99 -xregs=no%frameptr -xprefetch=auto \
-xprefetch_auto_type=indirect_array_access -xprefetch_level=3 \
-xbuiltin=%all -xinline=%all -xjobs=2 \
-xustr=ascii_utf16_ushort -z combreloc -z redlocsym \
-z nodefaultlib -z now -z rescan -z absexec \
-xldscope=symbolic -xalias_level=compatible \
-Qoption ccfe -complextmplexp -Qoption ccfe -features=gcc \
-lc -lpthread -lposix4 -lrt -mt -D_REENTRANT \
-DNDEBUG -KPIC -xrestrict=%all -xF=%none -xthreadvar \
-D__EXTENSIONS__=1 -D_LARGEFILE_SOURCE \
-D_FILE_OFFSET_BITS=64 -D_XPG4 -D_XPG4_2 \
-D_XPG5 -D_XPG6 -xtarget=pentium4 -xarch=sse2 \
-xchip=pentium4 -xcache=8/64/4:256/128/8 "

This is a very optimized build. Some of the options are crazy. For a 
vanilla debug build, you could try

export CXXFLAGS=" -features=%all,extensions,tmplife,tmplrefstatic \
-instances=global -template=geninlinefuncs -verbose=template \
-g -xlang=c99 -xustr=ascii_utf16_ushort -z combreloc -z redlocsym \
-z nodefaultlib -z now -z rescan -z absexec \
-xldscope=symbolic \
-Qoption ccfe -complextmplexp -Qoption ccfe -features=gcc \
-xildoff -lc -lpthread -lposix4 -lrt -mt -D_REENTRANT \
-KPIC -D__EXTENSIONS__=1 -D_LARGEFILE_SOURCE \
-D_FILE_OFFSET_BITS=64 -D_XPG4 -D_XPG4_2 \
-D_XPG5 -D_XPG6 "

export LDFLAGS=" -L/opt/sun/sunstudio12/prod/lib -lCrun -lCstd "
[ + add more needed libraries here ]

For 64-bit you can change the following:

-xtarget=opteron -xarch=amd64 -xchip=opteron \
-xcache=8/64/4:256/128/8

and change LDFLAGS to

export LDFLAGS=" -L/opt/sun/sunstudio12/prod/lib/amd64 \
-lCrun -lCstd "
[ + add more 64-bit libraries ]

This will build for Opterons. For a generic 64-bit,  you can try

-xtarget=generic64 -xarch=amd64

for $(CXXFLAGS) and $(LDFLAGS)

When creating *.a (archive) libraries, you should do:

$(CXX) $(CXXFLAGS) -xar -o <libarchive-name.a>. 

When linking/creating a shared lib:

$(CXX) $(CXXFLAGS) $(LDFLAGS) -G -h'$(SONAME)' \
<list-of-object-files> -o <shared-library-name.so>

A quick way of finding out Studio's cc, c99 and CC flags is:

/opt/sun/sunstudio12/bin/cc -xhelp=flags
/opt/sun/sunstudio12/bin/c99 -xhelp=flags
/opt/sun/sunstudio12/bin/CC -xhelp=flags

The -xtarget=, -xarch= and -xchip= are important. You can get very 
nice performance by setting them for the right architecture (with the 
caveat that if you compile something for P4/SSE2 or Opteron, it will 
not work on earlier pentiums).

If you run into problems with macros, you can pass

-xdumpmacros=%all to CC, and it will print out the macro expansions.

You can also use cc, c99 and CC as CPP:

export CPP="${CC} ${CFLAGS} ${CPPFLAGS} -E "
export CXXCPP="${CXX} ${CPPFLAGS} ${CXXFLAGS} -E "

I've built QCA + QT 3.x and 4.x with Studio 10 and 11 (on Solaris) and 
they build and work very very nicely.

Please let us know how it goes. :-)

--Stefan

-- 
Stefan Teleman                  'Nobody Expects the Spanish Inquisition'
KDE e.V.                                                -Monty Python
stefan.teleman at gmail.com

Reply via email to