Index: backend/Makefile
--- backend/Makefile.orig	2009-12-29 08:12:55 +0100
+++ backend/Makefile	2010-01-25 08:48:55 +0100
@@ -1,6 +1,6 @@
 CXX := c++
-CFLAGS := $(shell llvm-config --cxxflags --ldflags \
-                              --libs bitreader codegen selectiondag)
+CFLAGS := $(shell llvm-config --cxxflags)
+LDFLAGS := $(shell llvm-config --ldflags --libs bitreader codegen selectiondag)
 OBJS := \
     main.o \
     backend.o \
@@ -20,7 +20,7 @@
 all: lljvm-backend
 
 lljvm-backend: ${OBJS}
-	$(CXX) ${OBJS} ${CFLAGS} -o lljvm-backend
+	$(CXX) ${OBJS} ${CFLAGS} -o lljvm-backend $(LDFLAGS)
 
 doc:
 	doxygen
Index: libc/ctype/Makefile
--- libc/ctype/Makefile.orig	2009-12-29 08:12:55 +0100
+++ libc/ctype/Makefile	2010-01-25 08:48:55 +0100
@@ -27,9 +27,7 @@
     isxdigit.o \
     jp2uc.o \
     toascii.o \
-    _tolower.o \
     tolower.o \
-    _toupper.o \
     toupper.o \
     towctrans.o \
     towlower.o \
Index: libc/math/Makefile
--- libc/math/Makefile.orig	2009-12-29 08:12:55 +0100
+++ libc/math/Makefile	2010-01-25 08:48:55 +0100
@@ -4,7 +4,8 @@
     s_isnand.o \
     s_ldexp.o \
     s_mathcnst.o \
-    s_numtest.o
+    s_numtest.o \
+    s_fpclassify.o
 
 DIR := math
 LEVEL := ..
@@ -30,3 +31,6 @@
 
 s_numtest.o: ${SOURCE_DIR}/../libm/mathfp/s_numtest.c
 	$(CC) ${CFLAGS} -c $< -o $@
+
+s_fpclassify.o: ${SOURCE_DIR}/../libm/common/s_fpclassify.c
+	$(CC) ${CFLAGS} -c $< -o $@
Index: libc/stdlib/Makefile
--- libc/stdlib/Makefile.orig	2009-12-29 08:12:55 +0100
+++ libc/stdlib/Makefile	2010-01-25 08:51:13 +0100
@@ -61,6 +61,7 @@
     mbsrtowcs.o \
     mbstowcs.o \
     mbstowcs_r.o \
+    mbsnrtowcs.o \
     mbtowc.o \
     mbtowc_r.o \
     mlock.o \
@@ -98,6 +99,7 @@
     vallocr.o \
     wcrtomb.o \
     wcsrtombs.o \
+    wcsnrtombs.o \
     wcstol.o \
     wcstoll.o \
     wcstoll_r.o \
Index: thirdparty/Makefile
--- thirdparty/Makefile.orig	2009-12-29 08:12:55 +0100
+++ thirdparty/Makefile	2010-01-25 08:48:55 +0100
@@ -9,7 +9,7 @@
     zlib \
     libpng
 ARCHIVES := \
-    newlib-1.17.0.tar.gz \
+    newlib-1.18.0.tar.gz \
     bsd-games-2.17.tar.gz \
     jpeg-7.tar.gz \
     lua-5.1.4.tar.gz \
@@ -17,13 +17,13 @@
     zlib-1.2.3.tar.gz \
     libpng-1.2.41.tar.gz
 
-newlib: newlib-1.17.0.tar.gz
-	tar -zxvf $<
-	patch -p1 < newlib-1.17.0.patch
+newlib: newlib-1.18.0.tar.gz
+	tar -zxf $<
+	patch -p0 -d newlib-1.18.0 < newlib-1.18.0.patch
 	rm -rf newlib
-	mv -f newlib-1.17.0 newlib
+	mv -f newlib-1.18.0 newlib
 
-newlib-1.17.0.tar.gz:
+newlib-1.18.0.tar.gz:
 	wget -c ftp://sources.redhat.com/pub/newlib/$@ -O $@.part
 	mv -f $@.part $@
 
Index: thirdparty/newlib-1.18.0.patch
--- thirdparty/newlib-1.18.0.patch.orig	2010-01-25 08:48:55 +0100
+++ thirdparty/newlib-1.18.0.patch	2010-01-25 08:48:55 +0100
@@ -0,0 +1,135 @@
+Index: newlib/libc/include/machine/setjmp.h
+--- newlib/libc/include/machine/setjmp.h.orig	2009-12-17 20:24:22 +0100
++++ newlib/libc/include/machine/setjmp.h	2010-01-25 08:30:08 +0100
+@@ -258,6 +258,13 @@
+ #define _JBLEN 0x44
+ #endif
+ 
++#ifdef __LLJVM__
++#ifdef _JBLEN
++#undef _JBLEN
++#endif
++#define _JBLEN 2
++#endif
++
+ #ifdef _JBLEN
+ #ifdef _JBTYPE
+ typedef	_JBTYPE jmp_buf[_JBLEN];
+Index: newlib/libc/include/sys/_types.h
+--- newlib/libc/include/sys/_types.h.orig	2007-09-18 22:05:17 +0200
++++ newlib/libc/include/sys/_types.h	2010-01-25 08:30:08 +0100
+@@ -62,6 +62,11 @@
+ #define __need_wint_t
+ #include <stddef.h>
+ 
++#ifndef _WINT_T
++#define _WINT_T
++typedef unsigned int wint_t;
++#endif
++
+ #ifndef __mbstate_t_defined
+ /* Conversion state information.  */
+ typedef struct
+Index: newlib/libc/include/sys/config.h
+--- newlib/libc/include/sys/config.h.orig	2009-12-10 18:12:11 +0100
++++ newlib/libc/include/sys/config.h	2010-01-25 08:30:08 +0100
+@@ -145,6 +145,11 @@
+ #define __CUSTOM_FILE_IO__
+ #endif
+ 
++#ifdef __LLJVM__
++#define _LONG_DOUBLE double
++#undef __LARGE64_FILES
++#endif
++
+ /* This block should be kept in sync with GCC's limits.h.  The point
+    of having these definitions here is to not include limits.h, which
+    would pollute the user namespace, while still using types of the
+Index: newlib/libc/include/sys/signal.h
+--- newlib/libc/include/sys/signal.h.orig	2009-10-13 19:31:49 +0200
++++ newlib/libc/include/sys/signal.h	2010-01-25 08:30:08 +0100
+@@ -181,6 +181,10 @@
+ 
+ #endif /* defined(__CYGWIN__) || defined(__rtems__) */
+ 
++#ifdef __LLJVM__
++int _EXFUN(kill, (int, int));
++#endif
++
+ /* #endif __STRICT_ANSI__ */
+ 
+ #if defined(___AM29K__)
+Index: newlib/libc/include/wchar.h
+--- newlib/libc/include/wchar.h.orig	2009-10-15 10:23:27 +0200
++++ newlib/libc/include/wchar.h	2010-01-25 08:30:08 +0100
+@@ -13,6 +13,11 @@
+ #define __need___va_list
+ #include <stdarg.h>
+ 
++#ifndef _WINT_T
++#define _WINT_T
++typedef unsigned int wint_t;
++#endif
++
+ /* For _mbstate_t definition. */
+ #include <sys/_types.h>
+ 
+Index: newlib/libc/include/wctype.h
+--- newlib/libc/include/wctype.h.orig	2002-11-07 01:44:31 +0100
++++ newlib/libc/include/wctype.h	2010-01-25 08:30:08 +0100
+@@ -7,6 +7,11 @@
+ #define __need_wint_t
+ #include <stddef.h>
+ 
++#ifndef _WINT_T
++#define _WINT_T
++typedef unsigned int wint_t;
++#endif
++
+ #ifndef WEOF
+ # define WEOF ((wint_t)-1)
+ #endif
+Index: newlib/libc/reent/reent.c
+--- newlib/libc/reent/reent.c.orig	2009-11-23 18:02:20 +0100
++++ newlib/libc/reent/reent.c	2010-01-25 08:30:08 +0100
+@@ -23,7 +23,7 @@
+ 
+ /* We use the errno variable used by the system dependent layer.  */
+ #undef errno
+-int errno;
++extern int errno;
+ 
+ #endif
+ 
+Index: newlib/libc/reent/renamer.c
+--- newlib/libc/reent/renamer.c.orig	2008-11-24 22:27:33 +0100
++++ newlib/libc/reent/renamer.c	2010-01-25 08:30:08 +0100
+@@ -5,6 +5,10 @@
+ #include <sys/stat.h>
+ #include <_syslist.h>
+ 
++#ifdef HAVE_RENAME
++int _rename(const char *oldpath, const char *newpath);
++#endif
++
+ /* Some targets provides their own versions of these functions.  Those
+    targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
+ 
+Index: newlib/libc/include/stdlib.h
+--- newlib/libc/include/stdlib.h.orig	2009-12-17 20:43:43 +0100
++++ newlib/libc/include/stdlib.h	2010-01-25 08:35:39 +0100
+@@ -101,12 +101,12 @@
+ char *	_EXFUN(mkdtemp,(char *));
+ int	_EXFUN(mkstemp,(char *));
+ int	_EXFUN(mkstemps,(char *, int));
+-char *	_EXFUN(mktemp,(char *) _ATTRIBUTE ((warning ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
++char *	_EXFUN(mktemp,(char *));
+ #endif
+ char *	_EXFUN(_mkdtemp_r, (struct _reent *, char *));
+ int	_EXFUN(_mkstemp_r, (struct _reent *, char *));
+ int	_EXFUN(_mkstemps_r, (struct _reent *, char *, int));
+-char *	_EXFUN(_mktemp_r, (struct _reent *, char *) _ATTRIBUTE ((warning ("the use of `mktemp' is dangerous; use `mkstemp' instead"))));
++char *	_EXFUN(_mktemp_r, (struct _reent *, char *));
+ #endif
+ _VOID	_EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, int(*_compar)(const _PTR, const _PTR)));
+ int	_EXFUN(rand,(_VOID));
