[vtkusers] VTK 5.0.2, Mac OS 10.4.8, xlc

Peter Stihl stihl at cats.rwth-aachen.de
Wed May 9 09:31:41 EDT 2007


Hi,

after some trouble with the gcc standard library I finally managed to  
build VTK on a PPC, Mac OS X 10.4.8 with IBM xlc 6.0.
I created the following workaround, but I'm very unhappy to make  
changes to standard header files.
It would be a great help  if the problems with the IBM compiler could  
be solved in VTK itself.




The steps I took:

1. CMake options:
BUILD_SHARED_LIBS OFF
CMAKE_CXX_COMPILER /opt/ibmcmp/vacpp/6.0/bin/xlc++
CMAKE_C_COMPILER /opt/ibmcmp/vacpp/6.0/bin/xlc
VTK_OSX_ARCHITECTURES ppc
VTK_USE_CARBON ON


2. Change CFSwapInt16 in /System/Library/Frameworks/ 
CoreFoundation.framework/Headers/CFByteOrder.h, l. 37: add  "&& ! 
defined(__IBMCPP__)" to the #elif-condition:

[...]
#if defined(__i386__) && defined(__GNUC__)
     __asm__("xchgb %b0, %h0" : "+q" (arg));
     return arg;
#elif defined(__ppc__) && defined(__GNUC__) && !defined(__IBMCPP__)
     uint16_t result;
     __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&arg), "m" (arg));
     return result;
#else
[...]


3. Do the same changes as in step 2 in CFSwapInt32, (line 52)

4. Replace gcc-definition  __builtin_offsetof  in /usr/lib/gcc/ 
powerpc-apple-darwin8/4.0.0/include/stddef.h (line 414):

[...]
#ifdef _STDDEF_H

/* Offset of member MEMBER in a struct of type TYPE. */
#ifdef __builtin_offsetof
#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)
#else
#define offsetof(s,m) (size_t)(unsigned long)&(((s *)0)->m)
#endif

#endif /* _STDDEF_H was defined this time */
[...]


5. In a few files (e.g. <vtk-build>/Rendering/CMakeFiles/ 
vtkRendering.dir/flags.make) there are linker flags set that are not  
recognized by xlc. In these cases prepend "-Wl," to the flag, e.g. "- 
Wl,-F/System/Library/Frameworks" instead of "-F/System/Library/ 
Frameworks" or "-Wl,-framework -Wl,CoreFoundation" instead of "- 
framework CoreFoundation".
I haven't found a cmake option to prepend the -Wl,  to the linker  
flags automatically. Is there one?


After these modifications the build process finished successful and  
the library works fine on the system.
Probably somebody has an idea to avoid the changes in the standard  
header files.


Best regards
Peter






On Jan 19, 2007, at 4:20 PM, Peter Stihl wrote:

> Hi,
> I try to build the latest CVS-version of VTK on a PowerPC-cpu with  
> IBM xlc.
> Unfortunately the following error occurs during building  
> vtkMultiThreader.o for vtkCommon (same with gcc works):
>
> [  4%] Building CXX object Common/CMakeFiles/vtkCommon.dir/ 
> vtkMultiThreader.o
> "/System/Library/Frameworks/CoreFoundation.framework/Headers/ 
> CFByteOrder.h", line 39.29: 1540-0064 (S) Syntax error:  ")" was  
> expected but ":" was found.
> "/System/Library/Frameworks/CoreFoundation.framework/Headers/ 
> CFByteOrder.h", line 54.29: 1540-0064 (S) Syntax error:  ")" was  
> expected but ":" was found.
> make[2]: *** [Common/CMakeFiles/vtkCommon.dir/vtkMultiThreader.o]  
> Error 1
> make[1]: *** [Common/CMakeFiles/vtkCommon.dir/all] Error 2
> make: *** [all] Error 2
>
> My (changed) cmake options are:
> BUILD_SHARED_LIBS OFF
> CMAKE_CXX_COMPILER /opt/ibmcmp/vacpp/6.0/bin/xlc++
> CMAKE_C_COMPILER /opt/ibmcmp/vacpp/6.0/bin/xlc
> VTK_OSX_ARCHITECTURES ppc
> VTK_USE_CARBON ON
>
> CC and CXX environment variables are set to the xlc bin before  
> running cmake.
>
> The mentioned lines of CFByteOrder.h are:
>
> CF_INLINE uint16_t CFSwapInt16(uint16_t arg) {
> #if defined(__i386__) && defined(__GNUC__)
>     __asm__("xchgb %b0, %h0" : "+q" (arg));
>     return arg;
> #elif defined(__ppc__) && defined(__GNUC__)
>     uint16_t result;
>     __asm__("lhbrx %0,0,%1" : "=r" (result) : "r" (&arg),  
> "m" (arg));         <------------------------- line 39
>     return result;
> #else
>     uint16_t result;
>     result = ((arg << 8) & 0xFF00) | ((arg >> 8) & 0xFF);
>     return result;
> #endif
> }
>
> I'm not familiar with the inline-assembler syntax and the IBM doc  
> doesn't give me a clue. When I remove the elif-block there is no  
> error at this point, but the build process breaks again the next  
> time the __GNUC__ macro is used. Do I have to make sure the  
> __GNUC__ is not defined when using xlc? And if so, how? Adding  
> cmake options CMAKE_C(XX)_FLAGS -U__GNUC__ doesn't work and I don't  
> want to make changes to the gcc limits-file.
>
> Ideas or hints to manage this situation would be great!
>
> Bests,
> Peter
>
>
>
> _______________________________________________
> This is the private VTK discussion list.Please keep messages on- 
> topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>





More information about the vtkusers mailing list