[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to tell the compiler NOT to assume cpu provides atomic instructions



On Wed, 2011-03-16 at 23:33 +0000, brian m. carlson wrote:
> *Please* do not CC me.  My M-F-T is set appropriately; please respect
> it.
My apologies; it appears my mail client does not pick it up correctly.

> On Wed, Mar 16, 2011 at 11:03:17PM +0000, Martin wrote:
> > 1. SPARC V8 only has very weak atomic ops (IIRC it's only test and set)
> > which aren't sufficient to implement all of the GCC atomic built-ins
> > without some extra work.  This is why there will be a need to provide
> > your own implementation and a linking problem if you don't.
> > 
> > 2. SPARC V9 has CAS which allows most of the GCC atomic ops to be
> > emulated but is 64 bit, which may not be what you want.
> 
> Debian only supports v9 processors, but the sparc port is 32-bit.  By
> default, GCC uses -mcpu=ultrasparc and is configured for sparc-linux-gnu
> (which is 32-bit).  There is no need to specify any flags to GCC, since
> it does the right thing by default.  All UltraSPARC operations are
> supported, but the code generated is 32-bit.
<snip>
> > By default I think GCC still generates V8 code on Debian, setting
> > -mcpu=v8+ should do what you want.  Furthermore I might suggest using
> > Hans Boehm's libatomic-ops:
> 
>   blackhole no % gcc -mcpu=v8+ foo.c   
>   foo.c:1: error: bad value (v8+) for -mcpu= switch
> 
> I believe Debian's GCC does this by default already, with or without
> -mv8plus:
> 
>   blackhole ok % file a.out              
>   a.out: ELF 32-bit MSB executable, SPARC32PLUS, V8+ Required, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
> 
My apologies for posting outdated information.  I shall consider myself
corrected on this issue.

Cheers,
 - Martin



Reply to: