Discussion:
[CMake] Specifying build architectures on Mac OS X (ppc7400 does not work?)
Sean McBride
2007-05-07 15:26:59 UTC
Permalink
Hi all,

Has anyone tried to build a Universal Binary with the following:

CMAKE_OSX_ARCHITECTURES:STRING=ppc7400;i386

instead of the usual:

CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386

If I do a 'lipo -info' on the build result it tells me "Architectures in
the fat file: foo.a are: ppc i386". It should say "ppc7400 i386", which
I do get when I build with Xcode instead of CMake.

(ppc7400 is for the G4, which is the oldest CPU I want to target, I
don't care about the G3.)

Anyone else tried this? Thanks,
--
____________________________________________________________
Sean McBride, B. Eng ***@rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
Sean McBride
2007-05-15 18:13:46 UTC
Permalink
Post by Sean McBride
CMAKE_OSX_ARCHITECTURES:STRING=ppc7400;i386
CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386
If I do a 'lipo -info' on the build result it tells me "Architectures in
the fat file: foo.a are: ppc i386". It should say "ppc7400 i386", which
I do get when I build with Xcode instead of CMake.
(ppc7400 is for the G4, which is the oldest CPU I want to target, I
don't care about the G3.)
Anyone else tried this? Thanks,
Replying to myself... :(

It seems this actually partly works. Let's say I'm building VTK. I've
set CMAKE_OSX_ARCHITECTURES:STRING=ppc7400;i386. I do 'make' and in the
resulting /bin directory are, amongst other files:

CommonCxxTests (an executable)
libvtkRendering.a (a static lib)

If I do 'lipo -info' on each, I learn:

$ lipo -info /Users/sean/kitware/VTK-pristine-bin/bin/CommonCxxTests
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/bin/
CommonCxxTests are: ppc7400 i386

$ lipo -info /Users/sean/kitware/VTK-pristine-bin/bin/libvtkRendering.a
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/bin/
libvtkRendering.a are: ppc i386

Very strange! It seems that for all executables it is 'ppc7400' as
expected, but for all static libs it is 'ppc'.

Any ideas why?? Thanks,
--
____________________________________________________________
Sean McBride, B. Eng ***@rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
Bill Hoffman
2007-05-15 18:22:30 UTC
Permalink
Post by Sean McBride
Post by Sean McBride
CMAKE_OSX_ARCHITECTURES:STRING=ppc7400;i386
CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386
If I do a 'lipo -info' on the build result it tells me "Architectures in
the fat file: foo.a are: ppc i386". It should say "ppc7400 i386", which
I do get when I build with Xcode instead of CMake.
(ppc7400 is for the G4, which is the oldest CPU I want to target, I
don't care about the G3.)
Anyone else tried this? Thanks,
Replying to myself... :(
It seems this actually partly works. Let's say I'm building VTK. I've
set CMAKE_OSX_ARCHITECTURES:STRING=ppc7400;i386. I do 'make' and in the
CommonCxxTests (an executable)
libvtkRendering.a (a static lib)
$ lipo -info /Users/sean/kitware/VTK-pristine-bin/bin/CommonCxxTests
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/bin/
CommonCxxTests are: ppc7400 i386
$ lipo -info /Users/sean/kitware/VTK-pristine-bin/bin/libvtkRendering.a
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/bin/
libvtkRendering.a are: ppc i386
Very strange! It seems that for all executables it is 'ppc7400' as
expected, but for all static libs it is 'ppc'.
Any ideas why?? Thanks,
Did you try a make VERBOSE=1 to see what flags were being used during
the building of stuff to find out where it went wrong?

-Bill
Sean McBride
2007-05-15 19:17:14 UTC
Permalink
Post by Bill Hoffman
Did you try a make VERBOSE=1 to see what flags were being used during
the building of stuff to find out where it went wrong?
Hi Bill,

Thanks for your quick reply. I have just tried your suggestion. I
changed one vtk source file: vtkImageReslice.cxx. I did "make
VERBOSE=1". It sure is verbose. :) The relevant parts seem to be:

---------
[ 20%] Building CXX object Imaging/CMakeFiles/vtkImaging.dir/vtkImageReslice.o

/usr/bin/c++ -arch ppc7400 -arch i386 -isysroot /Developer/SDKs/
MacOSX10.4u.sdk <SNIP>

Linking CXX static library ../bin/libvtkImaging.a

cd /Users/sean/kitware/VTK-pristine-bin/Imaging && /Users/sean/kitware/
CMake-install/bin/cmake -P CMakeFiles/vtkImaging.dir/cmake_clean_target.cmake

cd /Users/sean/kitware/VTK-pristine-bin/Imaging && /Users/sean/kitware/
CMake-install/bin/cmake -E cmake_link_script CMakeFiles/vtkImaging.dir/
link.txt --verbose=1

/usr/bin/ar cr ../bin/libvtkImaging.a <SNIP> "CMakeFiles/vtkImaging.dir/
vtkImageReslice.o" <SNIP>

/usr/bin/ranlib ../bin/libvtkImaging.a
---------

It seems to be passing "-arch ppc7400" correctly. Also,

lipo -info /Users/sean/kitware/VTK-pristine-bin/Imaging/CMakeFiles/
vtkImaging.dir/vtkImageReslice.o

says:

Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/
Imaging/CMakeFiles/vtkImaging.dir/vtkImageReslice.o are: ppc7400 i386

Good, the .o file is ok! Yet,

lipo -info /Users/sean/kitware/VTK-pristine-bin/bin/libvtkImaging.a

incorrectly gives:

Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/bin/
libvtkImaging.a are: ppc i386

Could 'ar' or 'ranlib' have done something weird?
--
____________________________________________________________
Sean McBride, B. Eng ***@rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
Bill Hoffman
2007-05-15 20:52:56 UTC
Permalink
Post by Sean McBride
Post by Bill Hoffman
Did you try a make VERBOSE=1 to see what flags were being used during
the building of stuff to find out where it went wrong?
Hi Bill,
Thanks for your quick reply. I have just tried your suggestion. I
changed one vtk source file: vtkImageReslice.cxx. I did "make
---------
[ 20%] Building CXX object Imaging/CMakeFiles/vtkImaging.dir/vtkImageReslice.o
/usr/bin/c++ -arch ppc7400 -arch i386 -isysroot /Developer/SDKs/
MacOSX10.4u.sdk <SNIP>
Linking CXX static library ../bin/libvtkImaging.a
cd /Users/sean/kitware/VTK-pristine-bin/Imaging && /Users/sean/kitware/
CMake-install/bin/cmake -P CMakeFiles/vtkImaging.dir/cmake_clean_target.cmake
cd /Users/sean/kitware/VTK-pristine-bin/Imaging && /Users/sean/kitware/
CMake-install/bin/cmake -E cmake_link_script CMakeFiles/vtkImaging.dir/
link.txt --verbose=1
/usr/bin/ar cr ../bin/libvtkImaging.a <SNIP> "CMakeFiles/vtkImaging.dir/
vtkImageReslice.o" <SNIP>
/usr/bin/ranlib ../bin/libvtkImaging.a
---------
It seems to be passing "-arch ppc7400" correctly. Also,
lipo -info /Users/sean/kitware/VTK-pristine-bin/Imaging/CMakeFiles/
vtkImaging.dir/vtkImageReslice.o
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/
Imaging/CMakeFiles/vtkImaging.dir/vtkImageReslice.o are: ppc7400 i386
Good, the .o file is ok! Yet,
lipo -info /Users/sean/kitware/VTK-pristine-bin/bin/libvtkImaging.a
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/bin/
libvtkImaging.a are: ppc i386
Could 'ar' or 'ranlib' have done something weird?
I can't see how ar or ranlib could change the nature of .a files. I
think you can use ar to extract the .o files back out of a .a. ar x,
sort of like tar. Maybe it is just a bug in lipo and the libs are
really ok. Actually that seems far more likely as the executables are
created from the .a files are fine.

-Bill
Pascal Fleury
2007-05-16 10:02:41 UTC
Permalink
Post by Sean McBride
It seems to be passing "-arch ppc7400" correctly. Also,
lipo -info /Users/sean/kitware/VTK-pristine-bin/Imaging/CMakeFiles/
vtkImaging.dir/vtkImageReslice.o
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/
Imaging/CMakeFiles/vtkImaging.dir/vtkImageReslice.o are: ppc7400 i386
Good, the .o file is ok! Yet,
lipo -info /Users/sean/kitware/VTK-pristine-bin/bin/libvtkImaging.a
Architectures in the fat file: /Users/sean/kitware/VTK-pristine-bin/bin/
libvtkImaging.a are: ppc i386
Could 'ar' or 'ranlib' have done something weird?
I think that this should be no problem. Is a *.a file not just like a tar
file ? It does not change the nature of the files it contains, and the
packaging format has probably not changed in years for that.

Maybe lipo even outputs some default value if the file is not architecture
dependent (I think the *.a file is not architecture dependent, its content
definitely is though).

You should be fine.

--paf

Loading...