2004  5  27 ո


      Sun[tm] Studio 9C ļ


            Ŀ¼

       1. 
       2.  Sun Studio 9C 
       3. Ժ͸ĵ
       4. 
       5. ͽ취
       6. ƺͲ
       7. ĵ

     

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


            A. 

    ĵ Sun[tm] Studio 9 C Ϣĵ˱а
    һЩ¹ܣ˷а汾г֪⡢
    ƺͲԡĵеϢڴ˷а汾ֲеϢ

    Ʒĵ

        * Solaris ƽ̨ķ˵ͨ Sun Studio 9 վ
          http://developers.sun.com/tools/cc/documentation/ss9_docs/release_notes.html
          ô˷˵˵еϢºչļе
          Ϣ
        * Sun Studio 9 ĵƷֲҳļ HTML 汾Լֲ
          Դ /installation_directory/SUNWspro/docs/index.html з
          ʡȱʡװĿ¼Ϊ /optԴ index.html ҳĵ
          ĵ
              o C ûָ
              o C++ ûָ
              o ѧļ
              o ֵָ
              o ʽӱ༭ļ
              o Sun ܿļ
              o Sun ܿοֲ
              o Fortran  C  Sun ܿûָ
        * ɿ (IDE) ĵSun Studio 9 IDE 
           IDE е [] ˵зʡ
        * ԱԴŻйؼ¡ĵ֪ʶ⣬μ
          ԱŻַhttp://developers.sun.com/prodtech/cc

    Ҫ鿴ıʽļµ

       cc -xhelp=readme

    Ҫ鿴 HTML ʽļʹȱʡװĿ¼

file:/opt/SUNWspro/docs/index.html <../../index.html>

    ע⡪ Sun Studio 9 δװȱʡ /opt Ŀ¼Уѯϵͳ
    ԱԻϵͳеĵȼ·

     

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


            B.  Sun Studio 9C C 

    ˷а汾 C  Solaris[tm]  (SPARC(R); Platform
    Edition) 汾 89  10Լ Solaris  (x86 Platform
    Edition) 汾 89  10

    ñ Solaris 10 Ĳϵͳ֧ ISO/IEC 9899:1999
     - C ָĴԹܡ Solaris 10 ϣָ
    -xc99=all,libñȫ C99 ׼ݡñ ISO/IEC
    9899:1990 - C ׼ݡ

    ÿ汾е 64 λ SPARC ܹ֧ C ʱ׼ -xarch=v9

     

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


            C. Ժ͸ĵ

     C ıа汾¹ܺ͸Ĺܡ

        * ͨΪ -xarch-xcode-xmemalign  -xprefetch ѡṩµ
		  ȱʡòͨΪ -fast  -O ѡṩµչܣ
		  ܡ


        *  Intel ϵṹµ -xarch-xtarget  -xchip ־
		  µ -flteval ѡ


        * ͨ -xlibmopt-xnolibmopt-xipo_archive 
		  -xprefetch_auto_type ѡĽʱܡ

        * ͨ -xpch ԶɵԤͷļ˱ʱܡ

        * ͨµ -xchip  -xtarget ־չ SPARC ֧֡


        *  Solaris 10 ȫ֧ 1999 C ISO ܣⲿ
		  ָʼַͨ


        * ͨ lint óִµİȫԼ顣

    µ -xarch ȱʡֵv8plus

    ڣC ΪȱʡϵṹɵĴ v8plus (UltraSPARC)ڽ
    İ汾н v7 ֧֡

    µȱʡֵΪǰʹõлṩߵʱܡȻ
    ڼƻԤװ UltraSPARC ϲӦóȱʡ½Щ
    ִСʹ -xarch=v8 б룬ȷӦóЩ
    ִС

     v8 ϵͳϽвÿԼκʱ
    ȷָѡ -xarch=v8ṩϵͳ v8 ϵṹС

     v7 ϵͳϽвÿԼκʱ
    ȷָѡ -xarch=v7ṩϵͳʹ v8 ָ Sun
    Studio 9 а棬v7 Ψһֵ֧Ĳϵͳ Solaris 8 а档 v8
    ָʱSolaris 8 ϵͳеָУܲ½

     x86-xarch ȱʡΪ genericע⣬x86 ϵ -fast չ
    -xarch=native

    й -xarch ĸϢμ C ֲҳ cc(1)

    µ -xcode ȱʡֵ

    (SPARC) V9 ϵȱʡֵΪ -xcode=abs44V8 ϵȱʡֵ -xcode=abs32

    й -xcode ĸϢμ C ֲҳ cc(1)

    µ -xmemalign ȱʡֵ

    (SPARC) е v8 ϵṹ-xmemalign ȱʡֵΪ -xmemalign=
    8i v9 ϵṹȱʡֵΪ -xmemalign=8s

    й -xmemalign ĸϢμ C ֲҳ cc(1)

    µ -xprefetch ȱʡֵ

    (SPARC) ڣ-xprefetch ȱʡֵ -xprefetch=auto,explicit˸
    ԱΪڴģʽɲӰ졣ҪøĹܣָ
    -xprefetch=no%auto,no%explicit

    й -xprefetch ĸϢμ C ֲҳ cc(1)

    µ -fast չ

    ڣ-fast ѡչаµѡ -xlibmopt

    µ -O չ

    SPARC  x86-O չ -xO3 -xO2

    ȱʡ£Ľߵʱܡǣ-x03 ܲʺЩ
    бԶΪ volatile ĳ򡣿ܾд˼ĵͳʵ
    ͬԪ豸ͽϾɵĶ߳Ӧó취ʹ
    -xO2  -O б롣

    й -O ĸϢμ C ֲҳ cc(1)

    Ϊ Intel ϵṹṩµ -xarch-xtarget  -xchip ־

    C ֧ Intel ϵͳʹµ -xarch-xtarget  -xchip 
    ־Щ±־ Intel ƽ̨ϵ sse  sse2 ָרƣ
     Pentium 3  Pentium 4 оƬ Solaris ֧ϵ
    ơЩ±־

        * -xchip=pentium3 Ϊ Pentium 3 ͵ĴŻ
        * -xchip=pentium4 Ϊ Pentium 4 ͵ĴŻ
        * -xtarget=pentium3  -xarch=sse-xchip=pentium3 
          -xcache=16/32/4:256/32/4
        * -xtarget=pentium4  -xarch=sse2-xchip=pentium4 
          -xcache=8/64/4:256/128/8
        * -xarch=sse  SSE ָӵ pentium_pro ָϵṹС
        * -xarch=sse2 Щ SSE ָ SSE2 ָ

          رע
           -xarch={sse | sse2} Ա Solaris x86 SSE/SSE2 Pentium
          4 ƽ̨еĳֻ SSE/SSE2 ƽ̨Сδ
           SSE/SSE2 ƽֳ̨ܻᵼ¶ιϻ߲ȷ
          ϢͲϵͳͱĲɷֹ
          SSE/SSE2 ĶƳδ SSE/SSE2 ƽִ̨УЩ
          ܻЩʱṩ

           Solaris 9 update 6 ͷĲϵͳ汾 Pentium 4 ƽ̨
           SSE/SSE2Solaris OS ڰ汾δ SSE/SSE2

          þ滹չ .il Թܳ SSE/SSE2 ָ
           __asm() 롣

          ڸĲнбӣҪʼʹñͨ
           -xarch={sse | sse2} ӣȷȷ̡

    ׼ȷµ -xarch-xchip  -xtarget ־ĸ
    ϷҪ

        *

          Ƿ Solaris 9 update 5 Ͱ汾 Pentium 3 
          Pentium 4 ϽйǷָ -fast-xarch=
          native  -xtarget=native

          չ

              o

                -xarch Ϊ pentium_pro pentium3 
                pentium4Ϊ Solaris 9 update 5 Ͱ汾Ĳϵͳ
                ֧ sse  sse2 ָ

                ע⣺ ʹʹЩ汾 Solaris Ҳָ
                -xarch=sse  -xarch=sse2 Solaris 9 update
                6 ߰汾ļӦ汾ṩĿִļΪ
                Щ汾 Solaris ֧ SSE  SSE2 ָ

              o Ҫ -xchip Ϊ pentium3  pentium4
              o

                -xcache Ϊ 16/32/4:256/32/4 Pentium 3 
                 8/64/4:256/128/8 Pentium 4 

        *

          Ƿ Solaris 9 update 6 ߰汾 Pentium 3 
          Pentium 4 ϽйǷָ -fast-xarch=
          native  -xtarget=native

          չ

              o -xarch Ϊ sse Pentium 3 sse2 Pentium
                4
              o Ҫ -xchip Ϊ pentium3  pentium4
              o -xcache Ϊ 16/32/4:256/32/4 Pentium 3
                8/64/4:256/128/8 Pentium 4

    й -xarch-xtarget  -xchip ĸϢμ C ֲҳ cc(1)

    µ -xlibmopt  -xnolibmopt ѡ

    -xlibmopt ѡʹܹʹŻѧ̿⡣ָѡʱ
    ָͨ -fround=nearest ʹȱʡģʽѧ̿ܽ
    ŻͨɸĴ롣ͨѧóĽ
    вͬȷʵˣ䲻֮ͬͨһλϡ

    ָͨµ -xnolibmopt ѡʽرմ˿⡣

    й -xlibmopt  -xnolibmopt ĸϢμ C ֲҳ cc(1)

    µ -xipo_archive ѡ

    ʹµ -xipo_archive ѡŻݸӳĶļ
    ʹ -xipo ĶļԼɿִļ֮ǰפڹ鵵 (.a)
    еĶļаκζļڱнŻ󶼻ᱻ
    İ汾滻

    й -xipo_archive ѡĸϢμ cc(1) ֲҳ

    µ -xprefetch_auto_type ѡ

    ʹµ -xprefetch_auto_type ѡֱܹڴԤȡͬ
    ʽΪѡ -xprefetch_level=[1|2|3] ָʾѭɼԤȡ

     -xdepend-xrestrict  -xalias_level ѡԸĽ
    -xprefetch_auto_type ŻԡǽӰԤȡѡļ
    ȣӶӰԶԤȡļȣΪɸ׼ȷ
    ڴϢ

    й -xprefetch_auto_type ѡĸϢμ cc(1) ֲҳ

    ʹ -xpch ԶɵԤͷļ

    ˰汾 C չԤͷļܣ԰ڱԤ
    ͷļԶܡҲѡֶԤͷļǣԱ
    ¹ܸȤĻμ cc(1) ֲҳ -xpch ѡչܣ
    ˽Ϣμ CCadmin(1) ֲҳ

    ͨµ -xchip  -xtarget ־չ SPARC ֧֡

    (SPARC) ڣ-xchip  -xtarget ѡ֧ ultra3i  ultra4 Ϊ
    ֵԹΪ UltraSPARC IIIi  UltraSPARC IV 
    Ӧó

    ֧ⲿ

     1999 C ISO ׼Ĺ涨ڿʹⲿ

    ʹùؼ inlineǹؼ static  extern
    ĺԴļļгֵԭҲؼ
    inlineؼ static  extern

    ûΪṩⲿ塣ڵõԺ
    庯ýԴļгֵκκá

    ָ -xO3 ߼ĵã
    ŻΪǳ򽫵ⲿˣ
    κγӦⲿĶļһ

    ؼ extern  inline ͬʱ뺯һʹãڼк
    ļеκԭʹãڸöļжⲿ
    ⲿĶӵ C++ ӳѡ
    һκⲿá

    Ҫ÷ϱ׼ΪʹõǰıԾɴб롣ǣ
    ԭе C and C++ ļC/C++ 5.6 ֮ǰⲿ
    壬ϣЩļµ C  C++ ļҲ
    ԭжļΪָ -features=no%extinl

    й -features ĸϢμ C ֲҳ cc(1)

    ָĳʼ

    ָĳʼΪʼϡṩһֻƣʵֵ
    кܳ

    ָĳʼԳʼϡṹϵͳкܳҿͨ
    κγԱʼϣܸóԱǷΪһԱ

    뿴Щʾһʾ˵ʹָĳʼʼ
    飺

enum { first, second, third };
const char *nm[] = {
[third] = "third member",
[first] = "first member",
[second] = "second member",
    };

    ʾ˵ʹָĳʼʼṹֶΣ

division_t result = { .quot = 2, .rem = -1 };

    ʾ˵ʹָĳʼʼܻᱻ
    ĸӽṹ

struct { int z[3], count; } w[] = { [0].z = {1}, [1].z[0] = 2 };

    ͨʹõָʾԴ˴顣

int z[MAX] = {1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0};

     MAX  10齫мȡֵΪԪأ MAX С
    10ǰʼṩĳЩֵʼṩֵǡ

    ϵκγԱɳʼ

union { /* ...*/ } u = { .any_member = 42 };

    ַͨ (UCN)

    UCN  C ԴʹκַӢַUCN 
    ʽ

        * \u 4_hex_digits_value
        * \U 8_hex_digits_value

    UCN ָС 00A0 ֵ0024 ($)0040 (@)  0060 (?) ⣩
    ҲָݷΧΪ D800  DFFF ֵ֮

    UCN ڱʶַַУָ C ַв
    ַ

    UCN \Unnnnnnnn ָλ̱ʶ ISO/IEC 10646 Ĺ涨Ϊ
    nnnnnnnn ַַͬͨ \unnnn ָλ̱ʶΪ nnnn
    λ̱ʶΪ 0000nnnnַ

    µ -flteval ѡ

    (Intel) ʹøѡԿʽ

     -flteval ѡĸϢμ cc(1) ֲҳ

    ͨ lint ִµİȫԼ

    This release of the lint utility features a new security-checking
    facility.ڱ֮ǰʹ -errsecurity ѡԼİȫ

    -errsecurity[={core, standard, extended, %none}]

    lint -errsecurity=core
    һ𽫼鼸Ǵڲȫ״̬֤Դṹ˼
    

        * ʽַ printf()  scanf() ϵһʹ
        *  scanf() ʹδ󶨵ַ (%s) ʽ
        * ڲȫĿģgets()cftime()ascftime()creat()
        * open()  O_CREAT ʹòȷ

    ڸüɾϢԴΪ󡣶ԿɵԴӦиġ
    £ֱӲøȫĿѡ

    lint -errsecurity=standard
    һļмԼԿܰȫиõĿѡĽ
    еļ顣ڼдĴʱһ𡣴˼Ķ
    

        * ʹó strlcpy() ַ֮ƺ
        * ʹ
        * ʹòȫĺʱļ
        * ʹ fopen() ļ
        * ʹõ shell ĺ

    ڸüϢԴ滻ΪµĻ޸ĵĴ롣ԭеĴ
    оЩʱӦȨӦóȶڵķա

    lint -errsecurity=extended
    һһļ飬Ժļͱ׼һС
    йĳЩ¿ܲȫĽṹľ档Ϊ鿴ĸ
    ɽԴϵı׼һļǳ
    á˼Ķ

        * ѭڵ getc()  fgetc()
        * ʹ׵·ĺ
        * ʹ exec() ϵ
  * stat() ֮ľ

    ڸüϢԴȷǷǱڵİȫ⡣

    δָ -errsecurity ãὫΪ
    -errsecury=%noneδָ -errsecurityǲ
    Ϊ -errsecurity=standard

     

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


            D. 

    ĿǰûµϢ

     

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


            E. ͽ취

    ֪⼰ܵĽڸºͲ
    ϢַΪ http://developers.sun.com/prodtech/cc/support_index.html

        * 5044272 -flteval=2 ڼ򵥵Ĵϵ SIGSEGV

          ɴת ldouble  doubleĲʾ
          ⣺

% cat t.c
#pragma STDC L_FENV_ACCESS ON
#pragma STDC FP_CONTRACT OFF

int NumFail = 0;
int NumPass = 0;

int main(void)
{
double d = 5.;
auto double d3_aut = 3;

d3_aut = 3;
if (d == (d3_aut += 2.L)) {
NumPass++;
} else {
NumFail++;
        }

return (NumFail);
}
% cc t.c -flteval=2
% ./a.out
% echo $status
1

        * 5044281  -flteval=2 ģʽмΪ򵥵Ľṹɵ

% more t.c
#include <stdio.h>

static const float f_one = 1.f;
static const float f_zero = 0.f;
int main(void) {
        int NumFail = 0, NumPass = 0;

if ((f_zero ? f_one :f_zero) == f_zero) {
                NumPass++;
} else {
                NumFail++;
        }
return (NumFail);
}
% cc t.c -flteval=2
% ./a.out
% echo $status
1

        * 5044322 bad code generated with -flteval=2 for:int f[1]();

ynh% cat t.c
int NumFail = 0uL;
int NumPass = 0uL;
long double ld;
float f;

int main () {
        f = 0x1p-23f / 2.f;
ld = f += 1.f;
if (ld == 1.L) {
                NumPass++;
} else {
                NumFail++;
        }

return (NumFail);
}
ynh% /set/mercury/dist/intel-S2/bin/cc t.c -flteval=2
ynh% ./a.out
ynh% echo $status
1
ynh% 

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


            F. ƺͲ

    ϵͳƺͲݡйظ÷а汾 Sun ONE Studio
    9 ϢμSun Studio 9 ˵˵ Sun Studio
    9 վҵַǣhttp://developers.sun.com/prodtech/cc/ss9/reference/docs/releasenotes.pdf
    <http://developers.sun.com/tools/cc/documentation/ss9_docs/release_notes.html>

    ڴӡĵʱδϢ

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


            G. ĵ

    ĿǰûµϢ

     

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

    Ȩ (c) 2004 Sun Microsystems, Inc. Ȩ
	֤ʹá

