Opened 6 years ago

Last modified 5 years ago

#12804 new Bugs

Can't compiler IPC atomic_cas32<> on AIX.ppc with GCC

Reported by: dima.ru.com@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: interprocess
Version: Boost 1.62.0 Severity: Problem
Keywords: Cc:

Description

Hello,

I'm trying to use boost::atomic<> on AIX.ppc (v7.1) box and compile code with GCC. But unfortunately, the code below fails to compile :


inline boost::uint32_t atomic_cas32
   (volatile boost::uint32_t *mem, boost::uint32_t with, boost::uint32_t cmp)
{
   boost::uint32_t prev;

   asm volatile ("1:\n\t"                          
                 "lwarx  %0,0,%1\n\t"
                 "cmpw   %0,%3\n\t"
                 "bne-   2f\n\t"                        
                 "stwcx. %2,0,%1\n\t"
                 "bne-   1b\n\t"                       
                 "2:"                          
                 : "=&r"(prev)
                 : "b" (mem), "r" (with), "r" (cmp)
                 : "cc", "memory");
   return prev;
}

AIX assembler (/usr/bin/as) execution fails with error saying that "labels need to follow the symbol rules". Simple change from "1:\n\t" to "t_1:\n\t" fixes the issue.

I have a question : Is boost::atomic<> is designed to be compiled with GCC on AIX.ppc ? Or should it be used only with native xlC compiler ?


Environment :

-bash-4.3$ as -v
as V7.1

-bash-4.3$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/freeware/libexec/gcc/powerpc-ibm-aix7.1.0.0/4.8.5/lto-wrapper
Target: powerpc-ibm-aix7.1.0.0
Configured with: ../gcc-4.8.5/configure --prefix=/opt/freeware --mandir=/opt/freeware/man --infodir=/opt/freeware/info --with-local-prefix=/opt/freeware --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=c,c++,fortran --enable-version-specific-runtime-libs --disable-nls --enable-decimal-float=dpd --with-cloog=no --with-ppl=no --disable-libstdcxx-pch --enable-__cxa_atexit
Thread model: aix
gcc version 4.8.5 (GCC)
-bash-4.3$

Attachments (1)

atomic.hpp.diff (1.7 KB ) - added by dima.ru.com@… 5 years ago.
boost/interprocess/detail/atomic.hpp patch

Download all attachments as: .zip

Change History (5)

comment:1 by anonymous, 6 years ago

Sorry for confusing, the issue is realated to IPC atomic. Here is a simple case that doesn't compile :

#include <boost/interprocess/detail/atomic.hpp>
#include <iostream>

int main()
{ boost::uint32_t o, i=0, w=1, c=2;
  o = boost::interprocess::ipcdetail::atomic_cas32(&i,w,c);
  std::cout << o << '\n';
}

and compile output :

$ /opt/gcc494/bin/g++ -maix64 -mminimal-toc -pthread  -B/opt/gcc494/bin/ -std=c++11 -fpermissive -O0 -g -Wall -Wextra -Wpedantic -Wno-unknown-pragmas -Wno-reorder -Wno-unused-parameter -Wno-unused-local-typedefs    -Wno-unused-variable -Wno-ignored-qualifiers -Wno-sign-compare -D_HAS_CPP0X=1 -I/opt/boost/boost_1_62_0/distro/aix.ppc64/include    -DWFMO -o minimal minimal.cpp
Assembler:
/tmp//ccGvRPiO.s: line 1128: 1252-142 Syntax error.
/tmp//ccGvRPiO.s: line 1131: 1252-142 Syntax error.
/tmp//ccGvRPiO.s: line 1133: 1252-142 Syntax error.
/tmp//ccGvRPiO.s: line 1134: 1252-142 Syntax error.

comment:2 by dima.ru.com@…, 6 years ago

Component: atomicinterprocess
Owner: changed from timblechmann to Ion Gaztañaga
Summary: Can't compiler boost::atomic<> on AIX.ppc with GCCCan't compiler IPC atomic_cas32<> on AIX.ppc with GCC
Version: Boost 1.63.0Boost 1.62.0

comment:3 by Ion Gaztañaga, 6 years ago

It seems that the problem is related with the assembler, the code assumes GNU as as those types of labels are typical.. I have no access to that platform so a patch from a user would be needed. Many atomic functions have a similar syntax.

by dima.ru.com@…, 5 years ago

Attachment: atomic.hpp.diff added

boost/interprocess/detail/atomic.hpp patch

comment:4 by dima.ru.com@…, 5 years ago

Please, take a look at the attached patch being applied to fix compiler error.

Note: See TracTickets for help on using tickets.