Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: More about cross compiling



As far as I know, this is no magic command-line switch that can be passed to
gcc to have it generate code targetting a different CPU.

From the gcc man page:
-b machine
The argument machine specifies the target machine for compilation.

I've also fiddled with this, some time ago.
But I wasn't able to tell XCode to use this argument correctly.
It is important that the target options ("-b" and "-V") are set before any other options. I.e. before the "-x" argument.


Here is what XCode executes when building a standard tool:
--------------------
CompileC build/Test.build/Test.build/Objects-normal/ppc/main.o main.c normal ppc c com.apple.compilers.gcc.3_3
cd /Test
/usr/bin/gcc-3.3 -x c -arch ppc -pipe -Wno-trigraphs -fasm-blocks -fpascal-strings -Os -mtune=G4 -fmessage-length=0 -F/Test/build -I/Test/build/include -I/Test/build/Test.build/Test.build/DerivedSources -Wp,-header-mapfile,/Test/build/Test.build/Test.build/Test.hmap -c /Test/main.c -o /Test/build/Test.build/Test.build/Objects-normal/ppc/main.o


Ld /Test/build/Test
cd /Test
/usr/bin/gcc-3.3 -o /Test/build/Test -L/Test/build -F/Test/build -filelist /Test/build/Test.build/Test.build/Objects-normal/Test.LinkFileList -arch ppc -prebind -Wl,-no_arch_warnings
--------------------



If you set the target options using the "Other C Flags" in the build settings (here "-b m68k-atari-mint -V 3.3.3"), you encounter the following problem:
--------------------
CompileC build/Test.build/Test.build/Objects-normal/ppc/main.o main.c normal ppc c com.apple.compilers.gcc.3_3
cd /Test
/usr/bin/gcc-3.3 -x c -arch ppc -pipe -Wno-trigraphs -fasm-blocks -fpascal-strings -Os -mtune=G4 -fmessage-length=0 -F/Test/build -I/Test/build/include -I/Test/build/Test.build/Test.build/DerivedSources -Wp,-header-mapfile,/Test/build/Test.build/Test.build/Test.hmap -b m68k-atari-mint -V 3.3.3 -c /Test/main.c -o /Test/build/Test.build/Test.build/Objects-normal/ppc/main.o
gcc-3.3: `-b' must come at the start of the command line
--------------------


So the "Other C Flags" is no solution for our problem, as they are added after the "-x c" flag.

And if you've found a solution for the problem above, you'll have to solve the next problem:
"Not Apple-GCC" (=GCC from Free Software Foundation) does not understand many of the apple specific parameters. E.g. "-arch ppc" "-fpascal-strings" "-mtune=G4"... So you'll have get XCode to a point where it doesn't add these parameters to the command line.
Probably you'll try to resolve this by defining your own compiler specification "gcc.pbcompspec". (That's what I tried to do.)
After lots of crashes, you'll perhaps get to a point where it calls your cross-compiler with the correct arguments.
Being happy about your success, you'll try to create a cross-compiler project with more than a simple "Hello World" program.
There I encountered the next problem: When building, Xcode calls correctly your compiler for the first file. But after that it calls again Apples own GCC (for compiling or linking, I don't remember exactly). => no success.


That's where I stopped my effort in making Xcode the universal cross-compiling tool. I even trashed my compiler specification... Stupid, he?

With Xcode Apple has created a nice development tool. It would be great if they added cross-compiler support (e.g. support for FSF GCC). This would make Mac OS X a great platform for developing for any target platform (e.g. embedded systems)!


Philipp

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/xcode-users/email@hidden

This email sent to email@hidden
References: 
 >RE: More about cross compiling (From: Jeff Laing <email@hidden>)
 >Re: More about cross compiling (From: Prachi Gauriar <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.