I am in the process of reconfiguring the build environment for the BioConductor packages on Mac OS X Leopard and am having an issue with the compilation of assembly instruction using the GNU gcc/g++ version 2.4.1 (Apple Inc. build 5531) compiler and can't tell if this is a bug in the compiler, problem with the assembly code, or compiler flag misspecification. To demonstrate the issue I have taken a standard hello world application and injected some assembly instruction into a header file. I have two versions of GNU gcc/g++ compilers:

Leopard$ g++-4.2 --version
i686-apple-darwin9-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5531)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Leopard$ g++-4.0 --version
i686-apple-darwin9-g++-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5465)
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

When I try to compile the "mutant" hello world application on the 4.2.1 version I get the following error message:

Leopard$ g++-4.2 -arch x86_64 -g -O2 -march=nocona -fasm-blocks hello.cpp
In file included from hello.cpp:2:
hello.hpp: In function β€˜int atomic_exchange_and_add(int*, int)’:
hello.hpp:15: error: expected `)' before β€˜:’ token

and I have no issue when I compile on the 4.0.1 version

Leopard$ g++-4.0 -arch x86_64 -g -O2 -march=nocona -fasm-blocks hello.cpp
{...object file created without issue...}


The "mutant" hello world application compiles using gcc/g++ 4.2.1 compilers on SUSE Linux and MinGW for Windows environments so it looks like there is something about the Apple port that is causing this issue. Does anybody have any insight on this matter? I would rather not rollback to the 4.0.1 compilers.


Patrick

#include <iostream>
#include "hello.hpp"

using namespace std;

main()
{
  cout << "Hello World!";
  return 0;
}
#include <typeinfo>

inline int atomic_exchange_and_add( int * pw, int dv )
{
  // int r = *pw;
  // *pw += dv;
  // return r;

  int r;

  __asm__ __volatile__
  (
     "lock\n\t"
     "xadd %1, %0"
     : "=m"( *pw ), "=r"( r ) // outputs (%0, %1)
     : "m"( *pw ), "1"( dv ) // inputs (%2, %3 == %1)
     : "memory", "cc" // clobbers
  );

  return r;
}
_______________________________________________
R-SIG-Mac mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-mac

Reply via email to