#18576: zeromq-4.0.5 fails to build on Solaris SPARC due to casting issues with
volatite integer.
-------------------------------------------------+-------------------------
       Reporter:  drkirkby                       |        Owner:
           Type:  PLEASE CHANGE                  |       Status:  new
       Priority:  major                          |    Milestone:  sage-6.8
      Component:  porting: Solaris               |   Resolution:
       Keywords:                                 |    Merged in:
        Authors:                                 |    Reviewers:
Report Upstream:  Reported upstream. No          |  Work issues:
  feedback yet.                                  |       Commit:
         Branch:                                 |     Stopgaps:
   Dependencies:                                 |
-------------------------------------------------+-------------------------
Changes (by drkirkby):

 * upstream:  Not yet reported upstream; Will do shortly. => Reported
     upstream. No feedback yet.


Old description:

> Using
>
>  * Sage 6.7
>  * Sun Blade 2000 with UltraSPARC CPU
>  * gcc 4.9.2
>
> I get a build failure on Solaris SPARC.
>
> {{{
>
> make[6]: Entering directory
> `/export/home/drkirkby/sage-6.7/local/var/tmp/sage/build/zeromq-4.0.5/src'
> make[6]: Leaving directory
> `/export/home/drkirkby/sage-6.7/local/var/tmp/sage/build/zeromq-4.0.5/src'
>   CXX    libzmq_la-address.lo
>   CXX    libzmq_la-clock.lo
>   CXX    libzmq_la-ctx.lo
> In file included from ctx.hpp:34:0,
>                  from ctx.cpp:30:
> atomic_counter.hpp: In member function 'zmq::atomic_counter_t::integer_t
> zmq::atomic_counter_t::add(zmq::atomic_counter_t::integer_t)':
> atomic_counter.hpp:87:71: error: invalid conversion from 'volatile
> integer_t* {aka volatile unsigned int*}' to 'uint32_t* {aka unsigned
> int*}' [-fpermissive]
>              integer_t new_value = atomic_add_32_nv (&value, increment_);
>                                                                        ^
> atomic_counter.hpp: In member function 'bool
> zmq::atomic_counter_t::sub(zmq::atomic_counter_t::integer_t)':
> atomic_counter.hpp:130:59: error: invalid conversion from 'volatile
> integer_t* {aka volatile unsigned int*}' to 'uint32_t* {aka unsigned
> int*}' [-fpermissive]
>              integer_t nv = atomic_add_32_nv (&value, delta);
>                                                            ^
> make[5]: *** [libzmq_la-ctx.lo] Error 1
> make[5]: Leaving directory
> `/export/home/drkirkby/sage-6.7/local/var/tmp/sage/build/zeromq-4.0.5/src/src'
> make[4]: *** [all] Error 2
> }}}
> It looks like there are assembly code that is assembled on x86 and ARM
> processors, but C++ is compiled on other processors. Here's the dodgy
> code, which appears to be casting a volatile unsigned 32-bit integer to a
> standard (non-volatile) unsigned 32-bit integer.No doubt adding
> -fpermissive would allow it to compile, but I don't know what the authors
> intended here.
>
> I will report this upstream to Martin Sustrik and Mikko Koppanen, and
> offer them access to the SPARC if they want it, although I suspect they
> will see the problem and can suggest a fix.
>
> {{{
>
>        //  Atomic addition. Returns the old value.
>
>   inline integer_t add (integer_t increment_){
>     integer_t old_value;
>
> #if defined ZMQ_ATOMIC_COUNTER_WINDOWS
>
>   old_value = InterlockedExchangeAdd ((LONG*) &value, increment_);
>
> #elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H
>
>   integer_t new_value = atomic_add_32_nv (&value, increment_); // BREAKS
> ON SOLARIS
>   old_value = new_value - increment_;
>
> #elif defined ZMQ_ATOMIC_COUNTER_TILE
>
>   old_value = arch_atomic_add (&value, increment_);
>
> #elif defined ZMQ_ATOMIC_COUNTER_X86
>
>   __asm__ volatile (
>     "lock; xadd %0, %1 \n\t": "=r" (old_value), "=m" (value): "0"
> (increment_), "m" (value): "cc", "memory");
>
> #elif defined ZMQ_ATOMIC_COUNTER_ARM
>
>   integer_t flag, tmp;__asm__ volatile (
>     "       dmb     sy\n\t"
> }}}

New description:

 Using

  * Sage 6.7
  * Sun Blade 2000 with UltraSPARC CPU
  * gcc 4.9.2

 I get a build failure on Solaris SPARC.

 {{{

 make[6]: Entering directory
 `/export/home/drkirkby/sage-6.7/local/var/tmp/sage/build/zeromq-4.0.5/src'
 make[6]: Leaving directory
 `/export/home/drkirkby/sage-6.7/local/var/tmp/sage/build/zeromq-4.0.5/src'
   CXX    libzmq_la-address.lo
   CXX    libzmq_la-clock.lo
   CXX    libzmq_la-ctx.lo
 In file included from ctx.hpp:34:0,
                  from ctx.cpp:30:
 atomic_counter.hpp: In member function 'zmq::atomic_counter_t::integer_t
 zmq::atomic_counter_t::add(zmq::atomic_counter_t::integer_t)':
 atomic_counter.hpp:87:71: error: invalid conversion from 'volatile
 integer_t* {aka volatile unsigned int*}' to 'uint32_t* {aka unsigned
 int*}' [-fpermissive]
              integer_t new_value = atomic_add_32_nv (&value, increment_);
                                                                        ^
 atomic_counter.hpp: In member function 'bool
 zmq::atomic_counter_t::sub(zmq::atomic_counter_t::integer_t)':
 atomic_counter.hpp:130:59: error: invalid conversion from 'volatile
 integer_t* {aka volatile unsigned int*}' to 'uint32_t* {aka unsigned
 int*}' [-fpermissive]
              integer_t nv = atomic_add_32_nv (&value, delta);
                                                            ^
 make[5]: *** [libzmq_la-ctx.lo] Error 1
 make[5]: Leaving directory
 `/export/home/drkirkby/sage-6.7/local/var/tmp/sage/build/zeromq-4.0.5/src/src'
 make[4]: *** [all] Error 2
 }}}
 It looks like there is assembly code that is assembled on x86 and ARM
 processors, but C++ is compiled on other processors. Here's the dodgy
 code, which appears to be casting a volatile unsigned 32-bit integer to a
 standard (non-volatile) unsigned 32-bit integer.No doubt adding
 -fpermissive would allow it to compile, but I don't know what the authors
 intended here.

 I have reported this upstream to Martin Sustrik, and offer them access to
 the SPARC if they want it, although I suspect they will see the problem
 and can suggest a fix.

 {{{

        //  Atomic addition. Returns the old value.

   inline integer_t add (integer_t increment_){
     integer_t old_value;

 #if defined ZMQ_ATOMIC_COUNTER_WINDOWS

   old_value = InterlockedExchangeAdd ((LONG*) &value, increment_);

 #elif defined ZMQ_ATOMIC_COUNTER_ATOMIC_H

   integer_t new_value = atomic_add_32_nv (&value, increment_); // BREAKS
 ON SOLARIS
   old_value = new_value - increment_;

 #elif defined ZMQ_ATOMIC_COUNTER_TILE

   old_value = arch_atomic_add (&value, increment_);

 #elif defined ZMQ_ATOMIC_COUNTER_X86

   __asm__ volatile (
     "lock; xadd %0, %1 \n\t": "=r" (old_value), "=m" (value): "0"
 (increment_), "m" (value): "cc", "memory");

 #elif defined ZMQ_ATOMIC_COUNTER_ARM

   integer_t flag, tmp;__asm__ volatile (
     "       dmb     sy\n\t"
 }}}

--

--
Ticket URL: <http://trac.sagemath.org/ticket/18576#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to