BTW, to get Gambit to compile as an iOS library using this script, you need to make a small tweak to Xcode after some Xcode updates (or fresh install).  You'll get a link error to crt1.10.6 unless you make the following change in  /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk/usr/lib (or any earlier version of the SDK):<div>
<br></div><div>  sudo ln -s crt1.3.1.o crt1.10.6.o</div><div><br></div><div>Then it all compiles fine.  You don't need this change for the sim or osx as both already have that lib available.  Cheers,</div><div><br></div>
<div>   Adam<br><div><br><div class="gmail_quote">On Sun, Jul 31, 2011 at 7:58 PM, Adam King <span dir="ltr"><<a href="mailto:akingcoder@gmail.com">akingcoder@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I'm now using 'Apple LLVM compiler 3.0" to compile Gambit (osx, iOS Simulator and iOS device). I've switched to clang as my main compiler now since Apple seems to be making that their main compiler.  I use my own set of compile scripts to compile Gambit (from latest git) into a static lib that I then link into my XCode project.  I keep 3 separate builds, one for each 'platform' (osx, ios sim and ios device), each in their own directory with separate setup and config scripts.  I generally only rebuild the libs when the Gambit repo is updated.  Each script is a little different, but to compile the static Gambit lib an iOS arm device (arm7 only), I use the following 2 scripts:<div>

<br></div><div>setup.sh (to setup the env):</div><div><br></div><div><div><font face="'courier new', monospace" size="1">export PATH="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:$PATH"</font></div>

<div><font face="'courier new', monospace" size="1">export CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk"</font></div>

<div><font face="'courier new', monospace" size="1">export CXX="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/clang++ -arch armv7 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk"</font></div>

</div><div><br></div><div><div><div>compile.sh:</div><div><br></div><div><div><font face="'courier new', monospace">CFLAGS="-arch armv7" LDFLAGS="-arch armv7" ./configure --host=arm --prefix=/usr/local/Gambit-C/iPhoneOS</font></div>

<div><font face="'courier new', monospace">CFLAGS="-arch armv7" LDFLAGS="-arch armv7" make</font></div><div><font face="'courier new', monospace">sudo make install</font></div>

<div class="gmail_quote"><br></div><div class="gmail_quote">The script for each type of build is slightly different and is based on getting Gambit to build over the last year or so - and originally based on JLongster's scripts.  This is using the latest beta Xcode 4.2 with iOS 5.0 under Lion and SL - but it was working under XCode 4.0 with just changing the CC/CXX paths in setup.sh.</div>

<div class="gmail_quote"><br></div><font color="#888888"><div class="gmail_quote">   Adam</div></font><div><div></div><div class="h5"><div class="gmail_quote"><br></div><div class="gmail_quote">On Sun, Jul 31, 2011 at 6:14 PM, Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca" target="_blank">feeley@iro.umontreal.ca</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div></div><div><br>
On 2011-07-31, at 4:48 PM, mikel evins wrote:<br>
<br>
><br>
> On Jul 31, 2011, at 6:50 AM, Marc Feeley wrote:<br>
><br>
>> I have encountered this problem also (with Lion and the new Xcode).  The problem is due to LLVM gcc which is the default C compiler now and which does not compile the Gambit sources properly when the --enable-single-host configure option is given.  I've tried using gdb to find where the error is, but it is giving me an execution trace which doesn't correlate with the sources so I am confused in regards to the location of the error.<br>



>><br>
>> So to fix the problem temporarily I did<br>
>><br>
>>  CC="i686-apple-darwin11-gcc-4.2.1" ./configure --enable-single-host<br>
>>  make<br>
>>  make check<br>
>><br>
>> I also committed a patch to look for "i686-apple-darwin11-gcc-4.2.1" before "gcc", but that is not a long term solution.<br>
>><br>
>> My guess is that LLVM gcc is buggy, but I have not yet found a proof.<br>
><br>
> Using the above workaround, I certainly get farther than before. I can make it through the make check without crashes or errors.<br>
><br>
> After that, I tried this:<br>
><br>
> 1. rm examples/iOS/Prefix.pch (needed because otherwise make update fails when git is unable to update that file)<br>
><br>
> 2. make update<br>
><br>
> 3. cd examples/iOS<br>
><br>
> 4. make examples<br>
><br>
> 5. ./build-gambit-iOS<br>
><br>
><br>
> A cursory examination seems to show that these steps all succeeded, but I'm unable to run Gambit-REPL in the iPad or iPhone simulator. It launches and immediately crashes, complaining that it can't access memory address 1.<br>



><br>
> Perhaps I need to alter the Makefiles used in the iOS build to ensure that LLVM is not used? Or perhaps I overlooked some other step?<br>
<br>
</div></div>Indeed the build-gambit-iOS script also has to be modified to avoid LLVM gcc.  That can be achieved by changing the lines:<br>
<br>
  case "$kind$platform_type" in<br>
<br>
           iPhoneOS) config_options_extras=--host=arm-apple-darwin<br>
                     ;;<br>
<br>
    iPhoneSimulator) config_options_extras=<br>
                     ;;<br>
<br>
  esac<br>
<br>
  export CC="$ios_platform_dir/Developer/usr/bin/gcc -isysroot $ios_sdk_dir -arch $arch"<br>
  export CXX="$ios_platform_dir/Developer/usr/bin/g++ -isysroot $ios_sdk_dir -arch $arch"<br>
<br>
to<br>
<br>
  case "$kind$platform_type" in<br>
<br>
           iPhoneOS) config_options_extras=--host=arm-apple-darwin<br>
                     export CC="$ios_platform_dir/Developer/usr/bin/arm-apple-darwin10-gcc-4.2.1 -isysroot $ios_sdk_dir -arch $arch"<br>
                     export CXX="$ios_platform_dir/Developer/usr/bin/arm-apple-darwin10-g++-4.2.1 -isysroot $ios_sdk_dir -arch $arch"<br>
                     ;;<br>
<br>
    iPhoneSimulator) config_options_extras=<br>
                     export CC="$ios_platform_dir/Developer/usr/bin/i686-apple-darwin11-gcc-4.2.1 -isysroot $ios_sdk_dir -arch $arch"<br>
                     export CXX="$ios_platform_dir/Developer/usr/bin/i686-apple-darwin11-g++-4.2.1 -isysroot $ios_sdk_dir -arch $arch"<br>
                     ;;<br>
<br>
  esac<br>
<br>
I wonder why Apple is moving to LLVM gcc.  I've read somewhere that Apple thinks gcc is more buggy than LLVM gcc, and that it generates better code.  At least for compiling Gambit, this seems to be a mistaken belief on both counts.<br>



<font color="#888888"><br>
Marc<br>
</font><div><div></div><div><br>
_______________________________________________<br>
Gambit-list mailing list<br>
<a href="mailto:Gambit-list@iro.umontreal.ca" target="_blank">Gambit-list@iro.umontreal.ca</a><br>
<a href="https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list" target="_blank">https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list</a><br>
</div></div></blockquote></div><br>
</div></div></div></div></div>
</blockquote></div><br></div></div>