[LLVMdev] [cfe-dev] Clang, #include <math.h>

James Molloy James.Molloy at arm.com
Tue Oct 11 03:13:52 PDT 2011


Hi,

[Re-cc'ing list - please hit "reply to all"! :) ]

You can't just use your system C and maths libraries when cross-compiling. The C and especially math libraries make lots of assumptions about the underlying system - ABI, endianness and most importantly the assembly language for inline assembly.

You will need to cross-compile a C or math library.

Cheers,

James

From: Jonas Paulsson [mailto:jnspaulsson at hotmail.com]
Sent: 11 October 2011 09:50
To: James Molloy
Subject: RE: [cfe-dev] Clang, #include <math.h>

well,

I really just need a standard C library, to be able to do calls such as sqrt() and more. So I just want to use the standard C library already present on my (Suse11) system. The math.h file is found, but Clang has problems with it...

clang -cc1 aritm.c  -o ./aritm.ll -triple=albo -emit-llvm -O3
In file included from aritm.c:2:
In file included from /usr/include/math.h:409:
/usr/include/bits/mathinline.h:530:1: error: invalid output constraint '=t' in asm
__inline_mathcodeNP (floor, __x, \
^
/usr/include/bits/mathinline.h:220:3: note: instantiated from:
  __inline_mathcodeNP_ (double, func, arg, code)                              \
  ^
/usr/include/bits/mathinline.h:530:1: note: instantiated from:
__inline_mathcodeNP (floor, __x, \
^
/usr/include/bits/mathinline.h:543:9: note: instantiated from:
                    : "=t" (__value), "=&q" (__ignore), "=m" (__cwtmp),       \
                      ^
/usr/include/bits/mathinline.h:530:1: error: invalid output constraint '=t' in asm
__inline_mathcodeNP (floor, __x, \
^
...

any idea?

thanks,

Jonas
________________________________
From: James.Molloy at arm.com
To: jnspaulsson at hotmail.com; cfe-dev at cs.uiuc.edu
Date: Tue, 11 Oct 2011 08:34:15 +0100
Subject: RE: [cfe-dev] Clang, #include <math.h>
Hi,

<math.h> is part of the C standard library, not part of the compiler headers. Clang does not provide it.

You could look into one of the "standard" standard libraries, such as RedHat Newlib or Glibc, compile that yourself for your target and point Clang at its /include directory.

Cheers,

James

From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On Behalf Of Jonas Paulsson
Sent: 11 October 2011 08:24
To: cfe-dev at cs.uiuc.edu
Subject: [cfe-dev] Clang, #include <math.h>

Hi,

I'm working on a new llc target and would like to generate .ll code with Clang.

I find that I can't #include <math.h>, if I specify my target, or eg mips, arm, bfin...

What must be done in order to do this?

Thank you,

Jonas Paulsson

-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111011/e205e1e0/attachment.html>


More information about the llvm-dev mailing list