title: Mac OSX 10.6 compiler: a puzzling experience with 32 vs 64 bit
body: <p>I have trouble understanding the gcc compiler provided by OSX 10.6 snow leopard, mainly because of my lack of experience with 64 bits environments.</p>
  
  <pre><code>$ cat &gt;foo.c
  main() {}
  $ gcc foo.c -o foo
  $ file foo
  foo: Mach-O 64-bit executable x86_64
  $ lipo -detailed_info foo
  input file foo is not a fat file
  Non-fat file: foo is architecture: x86_64
  </code></pre>
  
  <p>However, my architecture is seen as an intel i386 type (I have one of the latest Intel Core2 duo MacBook) </p>
  
  <pre><code>$ arch
  i386
  </code></pre>
  
  <p>and the compiler targets i686-apple-darwin10</p>
  
  <pre><code>$ gcc --version 
  i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646)
  </code></pre>
  
  <p>Of course, if I compile 32 bits I get a 32 bit executable.</p>
  
  <pre><code>$ gcc -m32 foo.c -o foo
  $ file foo
  foo: Mach-O executable i386
  </code></pre>
  
  <p>but I don't get the big picture. The default setup for the compiler is to produce x86_64 executables, even if I have arch saying I have a 32 bit machine (why? Core2 is 64); even if (I guess) I am running a 32 bit kernel; even if I have a compiler targeting the i686-apple-darwin platform. Why? How can they run ? Should I compile 64 or 32 ?</p>
  
  <p>This question is due to my attempt to compile gcc 4.2.3 on the mac, but I am having a bunch of issues with gmp, mpfr and libiberty getting (in some cases) compiled for x86_64. Should I compile everything x86_64 ? If so, what's the target (not i686-apple-darwin10 I guess)?</p>
  
  <p>Thanks for the help</p>