<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - MCJIT on ARM does not link correctly external functions with double-typed arguments"
   href="http://llvm.org/bugs/show_bug.cgi?id=16256">16256</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>MCJIT on ARM does not link correctly external functions with double-typed arguments
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Generic Execution Engine Support
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dmitri.rubinstein@googlemail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When external function accepts double-typed arguments MCJIT does not correctly
link it.

Following command sequence produces different results on x86_64 and ARM
(RaspberryPi VM with hard-float ABI, see below for details):

cat > printd.c <<EOF
#include <stdio.h>

double printd(double X)
{
   printf("printd: %f\n", X);
   return 0;
}
EOF

cat > print.c <<EOF
#include <stdio.h>

extern double printd(double X);

int main(int argc, char **argv)
{
   printd(123.0);
   printd(4.0);
   return 0;
}
EOF

gcc printd.c -fPIC -shared -o printd.so
clang -Wall -c -emit-llvm -O3 print.c -o print.bc
lli -use-mcjit -load=./printd.so print.bc

Correct output on x86_64:
printd: 123.000000
printd: 4.000000

Wrong output on ARM:
printd: 1.000000
printd: 0.000000

When printd definition is added into print.c everything works as expected.

ARM configuration is QEMU with RaspberryPi Raspbian “wheezy” kernel, 
hard float support:

cat /proc/cpuinfo 
Processor       : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 602.11
Features        : swp half thumb fastmult vfp edsp java tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : ARM-Versatile PB
Revision        : 0000
Serial          : 0000000000000000

LLVM datalayout and triple produced by clang are:

target datalayout = 
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64"
target triple = "armv4t-unknown-linux-gnueabihf"

LLVM was cloned from git repository, branch release_33, latest commit:
1df068064
git-svn-id: <a href="https://llvm.org/svn/llvm-project/llvm/branches/release_33@182492">https://llvm.org/svn/llvm-project/llvm/branches/release_33@182492</a>
91177308-0d34-0410-b5e6-96231b3b80d8</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>