title: How to (cross-)compile to both ARM hard- and soft-float (softfp) with a single GCC (cross-)compiler?
body: <p>I'd like to use a single (cross-)compiler to compile code for different ARM calling conventions: since I always want to use floating point and NEON instructions, I just want to select the hard-float calling convention or the soft-float (softfp) calling convention.</p>
  
  <p>My compiler defaults to hard-float, but it supports both architectures that I need:</p>
  
  <pre><code>$ arm-linux-gnueabihf-gcc -print-multi-lib
  .;
  arm-linux-gnueabi;@marm@march=armv4t@mfloat-abi=soft
  $
  </code></pre>
  
  <p>When I compile with the default parameters:</p>
  
  <pre><code>$ arm-linux-gnueabihf-g++ -Wall -o hello_world_armhf hello_world.cpp
  </code></pre>
  
  <p>It succeeds without any errors.</p>
  
  <p>If I compile with the parameters returned by -print-multi-lib:</p>
  
  <pre><code>$ arm-linux-gnueabihf-g++ -marm -march=armv4t -mfloat-abi=soft -Wall -o hello_world hello_world.cpp
  </code></pre>
  
  <p>It again compiles without error (By the way, how can I test that the resultant code is hard- or soft-float?)</p>
  
  <p>Unfortunately, if I try this:</p>
  
  <pre><code>$ arm-linux-gnueabihf-g++ -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon -Wall -o hello_world hello_world.cpp
  [...]/gcc/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: error: hello_world uses VFP register arguments, /tmp/ccwvfDJo.o does not
  [...]/gcc/bin/../lib/gcc/arm-linux-gnueabihf/4.7.3/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file /tmp/ccwvfDJo.o
  collect2: error: ld returned 1 exit status
  $
  </code></pre>
  
  <p>I've tested some other permutations of the parameters, but it seems that anything other than the combination shown by -print-multi-lib results in an error.</p>
  
  <p>I've read <a href="https://stackoverflow.com/questions/9753749/arm-compilation-error-vpf-registered-used-by-executable-not-object-file">ARM compilation error, VFP registered used by executable, not object file</a> but the problem there was that some parts of the binary were soft- and some were hard-float. I have a single C++ file to compile...</p>
  
  <p>What parameter(s) I miss to be able to compile with -march=armv7-a -mthumb-interwork -mfloat-abi=softfp -mfpu=neon?</p>
  
  <p>How is it possible that the error is about VFP register arguments while I explicitly have -mfloat-abi=softfp in the command line which prohibits VFP register arguments?</p>
  
  <p>Thanks!</p>
  
  <p>For the records, hello_world.cpp contains the following:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  int main()
  {
    std::cout &lt;&lt; "Hello, world!" &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>