changeset 447:4ed02d53fc92

Add C++ support to native compiler, based on uClibc++.
author Rob Landley <rob@landley.net>
date Mon, 03 Nov 2008 21:33:34 -0600
parents 06a005fcdacc
children 87ab57007bb3
files mini-native.sh sources/patches/uClibc++-nozdefs.patch sources/toys/gcc-uClibc.c
diffstat 3 files changed, 34 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mini-native.sh	Mon Nov 03 21:00:46 2008 -0600
+++ b/mini-native.sh	Mon Nov 03 21:33:34 2008 -0600
@@ -199,13 +199,21 @@
 
 # Build and install uClibc++
 
-#setupfor uClibc++
-#make defconfig &&
-#sed -r -i 's/(UCLIBCXX_HAS_(TLS|LONG_DOUBLE))=y/# \1 is not set/' .config &&
-#make oldconfig &&
-#CROSS="$ARCH"- make
-#install something
-#cleanup uClibc++
+setupfor uClibc++
+CROSS= make defconfig &&
+sed -r -i 's/(UCLIBCXX_HAS_(TLS|LONG_DOUBLE))=y/# \1 is not set/' .config &&
+sed -r -i '/UCLIBCXX_RUNTIME_PREFIX=/s/".*"/""/' .config &&
+CROSS= make oldconfig &&
+CROSS="$ARCH"- make &&
+CROSS= make install PREFIX="${TOOLS}/c++" &&
+
+# Move libraries somewhere useful.
+
+mv "${TOOLS}"/c++/lib/* "${TOOLS}"/lib &&
+rm -rf "${TOOLS}"/c++/{lib,bin} &&
+ln -s libuClibc++.so "${TOOLS}"/lib/libstdc++.so
+
+cleanup uClibc++
 
 # Build and install make
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/patches/uClibc++-nozdefs.patch	Mon Nov 03 21:33:34 2008 -0600
@@ -0,0 +1,11 @@
+--- uClibc++/Rules.mak	2007-06-03 17:51:12.000000000 -0500
++++ uClibc++2/Rules.mak	2008-11-03 17:43:49.000000000 -0600
+@@ -102,7 +102,7 @@
+ GEN_CFLAGS:=-fno-builtin
+ CFLAGS:=$(XWARNINGS) $(CPU_CFLAGS) -ansi
+ 
+-LDFLAGS:=-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs
++LDFLAGS:=-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc
+ 
+ ifeq ($(DODEBUG),y)
+     CFLAGS += -O0 -g3 
--- a/sources/toys/gcc-uClibc.c	Mon Nov 03 21:00:46 2008 -0600
+++ b/sources/toys/gcc-uClibc.c	Mon Nov 03 21:33:34 2008 -0600
@@ -102,14 +102,14 @@
 	int i, argcnt, liblen, lplen, sawM = 0, sawdotoa = 0, sawcES = 0;
 	char **gcc_argv, **libraries, **libpath;
 	char *dlstr, *incstr, *devprefix, *libstr;
-	char *cc, *rpath_link, *rpath, *uClibc_inc;
+	char *cc, *rpath_link, *rpath;
 	char *crtbegin_path[2], *crtend_path[2];
 	char *debug_wrapper=getenv("WRAPPER_DEBUG");
 
 	// For C++
 
 	char *crti_path, *crtn_path, *cpp = NULL;
-	int len, ctor_dtor = 1, cplusplus = 0, use_nostdinc_plus = 0;
+	int len, ctor_dtor = 1, use_nostdinc_plus = 0;
 
 	// For profiling
 	int profile = 0;
@@ -163,7 +163,6 @@
 		strcpy(cpp, cc);
 		cpp[len-1]='+';
 		cpp[len-2]='+';
-		cplusplus = 1;
 		use_nostdinc_plus = 1;
 	}
 
@@ -177,7 +176,6 @@
 
 	asprintf(&rpath_link,"-Wl,-rpath-link,%s/lib", devprefix);
 	asprintf(&rpath, "-Wl,-rpath,%s/lib", devprefix);
-	asprintf(&uClibc_inc, "%s/include/", devprefix);
 
 	asprintf(&crti_path, "%s/lib/crti.o", devprefix);
 	asprintf(&crtn_path, "%s/lib/crtn.o", devprefix);
@@ -249,9 +247,7 @@
 						use_start = 0;
 						use_stdlib = 0;
 					} else if (strcmp(nostdinc_plus,argv[i]) == 0) {
-						if (cplusplus==1) {
-							use_nostdinc_plus = 0;
-						}
+						if (cpp) use_nostdinc_plus = 0;
 					}
 					break;
 
@@ -388,7 +384,7 @@
 
 	gcc_argv[argcnt++] = cpp ? cpp : cc;
 
-	if (cplusplus) gcc_argv[argcnt++] = "-fno-use-cxa-atexit";
+	if (cpp) gcc_argv[argcnt++] = "-fno-use-cxa-atexit";
 
 	if (linking && source_count) {
 //#if defined HAS_ELF && ! defined HAS_MMU
@@ -414,16 +410,16 @@
 	if (use_stdinc && source_count) {
 		gcc_argv[argcnt++] = nostdinc;
 
-		if (cplusplus) {
+		if (cpp) {
 			if (use_nostdinc_plus) {
 				gcc_argv[argcnt++] = nostdinc_plus;
 			}
 			gcc_argv[argcnt++] = "-isystem";
-			asprintf(gcc_argv+(argcnt++), "%sc++/4.1.1", uClibc_inc);
+			asprintf(gcc_argv+(argcnt++), "%s/c++/include", devprefix);
 		}
 
 		gcc_argv[argcnt++] = "-isystem";
-		gcc_argv[argcnt++] = uClibc_inc;
+		asprintf(gcc_argv+(argcnt++), "%s/include", devprefix);
 		gcc_argv[argcnt++] = "-isystem";
 		asprintf(gcc_argv+(argcnt++), "%s/gcc/include", devprefix);
 		if(incstr) gcc_argv[argcnt++] = incstr;
@@ -459,7 +455,7 @@
 		for (i = 0 ; i < liblen ; i++)
 			if (libraries[i]) gcc_argv[argcnt++] = libraries[i];
 		if (use_stdlib) {
-			if (cplusplus) {
+			if (cpp) {
 				gcc_argv[argcnt++] = "-lstdc++";
 				gcc_argv[argcnt++] = "-lm";
 			}