firmware

changeset 447:4ed02d53fc92

Add C++ support to native compiler, based on uClibc++.
author Rob Landley <rob@landley.net>
date Mon Nov 03 21:33:34 2008 -0600 (16 months ago)
parents 06a005fcdacc
children 87ab57007bb3
files mini-native.sh sources/patches/uClibc++-nozdefs.patch sources/toys/gcc-uClibc.c
line diff
     1.1 --- a/mini-native.sh	Mon Nov 03 21:00:46 2008 -0600
     1.2 +++ b/mini-native.sh	Mon Nov 03 21:33:34 2008 -0600
     1.3 @@ -199,13 +199,21 @@
     1.4  
     1.5  # Build and install uClibc++
     1.6  
     1.7 -#setupfor uClibc++
     1.8 -#make defconfig &&
     1.9 -#sed -r -i 's/(UCLIBCXX_HAS_(TLS|LONG_DOUBLE))=y/# \1 is not set/' .config &&
    1.10 -#make oldconfig &&
    1.11 -#CROSS="$ARCH"- make
    1.12 -#install something
    1.13 -#cleanup uClibc++
    1.14 +setupfor uClibc++
    1.15 +CROSS= make defconfig &&
    1.16 +sed -r -i 's/(UCLIBCXX_HAS_(TLS|LONG_DOUBLE))=y/# \1 is not set/' .config &&
    1.17 +sed -r -i '/UCLIBCXX_RUNTIME_PREFIX=/s/".*"/""/' .config &&
    1.18 +CROSS= make oldconfig &&
    1.19 +CROSS="$ARCH"- make &&
    1.20 +CROSS= make install PREFIX="${TOOLS}/c++" &&
    1.21 +
    1.22 +# Move libraries somewhere useful.
    1.23 +
    1.24 +mv "${TOOLS}"/c++/lib/* "${TOOLS}"/lib &&
    1.25 +rm -rf "${TOOLS}"/c++/{lib,bin} &&
    1.26 +ln -s libuClibc++.so "${TOOLS}"/lib/libstdc++.so
    1.27 +
    1.28 +cleanup uClibc++
    1.29  
    1.30  # Build and install make
    1.31  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/sources/patches/uClibc++-nozdefs.patch	Mon Nov 03 21:33:34 2008 -0600
     2.3 @@ -0,0 +1,11 @@
     2.4 +--- uClibc++/Rules.mak	2007-06-03 17:51:12.000000000 -0500
     2.5 ++++ uClibc++2/Rules.mak	2008-11-03 17:43:49.000000000 -0600
     2.6 +@@ -102,7 +102,7 @@
     2.7 + GEN_CFLAGS:=-fno-builtin
     2.8 + CFLAGS:=$(XWARNINGS) $(CPU_CFLAGS) -ansi
     2.9 + 
    2.10 +-LDFLAGS:=-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs
    2.11 ++LDFLAGS:=-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc
    2.12 + 
    2.13 + ifeq ($(DODEBUG),y)
    2.14 +     CFLAGS += -O0 -g3 
     3.1 --- a/sources/toys/gcc-uClibc.c	Mon Nov 03 21:00:46 2008 -0600
     3.2 +++ b/sources/toys/gcc-uClibc.c	Mon Nov 03 21:33:34 2008 -0600
     3.3 @@ -102,14 +102,14 @@
     3.4  	int i, argcnt, liblen, lplen, sawM = 0, sawdotoa = 0, sawcES = 0;
     3.5  	char **gcc_argv, **libraries, **libpath;
     3.6  	char *dlstr, *incstr, *devprefix, *libstr;
     3.7 -	char *cc, *rpath_link, *rpath, *uClibc_inc;
     3.8 +	char *cc, *rpath_link, *rpath;
     3.9  	char *crtbegin_path[2], *crtend_path[2];
    3.10  	char *debug_wrapper=getenv("WRAPPER_DEBUG");
    3.11  
    3.12  	// For C++
    3.13  
    3.14  	char *crti_path, *crtn_path, *cpp = NULL;
    3.15 -	int len, ctor_dtor = 1, cplusplus = 0, use_nostdinc_plus = 0;
    3.16 +	int len, ctor_dtor = 1, use_nostdinc_plus = 0;
    3.17  
    3.18  	// For profiling
    3.19  	int profile = 0;
    3.20 @@ -163,7 +163,6 @@
    3.21  		strcpy(cpp, cc);
    3.22  		cpp[len-1]='+';
    3.23  		cpp[len-2]='+';
    3.24 -		cplusplus = 1;
    3.25  		use_nostdinc_plus = 1;
    3.26  	}
    3.27  
    3.28 @@ -177,7 +176,6 @@
    3.29  
    3.30  	asprintf(&rpath_link,"-Wl,-rpath-link,%s/lib", devprefix);
    3.31  	asprintf(&rpath, "-Wl,-rpath,%s/lib", devprefix);
    3.32 -	asprintf(&uClibc_inc, "%s/include/", devprefix);
    3.33  
    3.34  	asprintf(&crti_path, "%s/lib/crti.o", devprefix);
    3.35  	asprintf(&crtn_path, "%s/lib/crtn.o", devprefix);
    3.36 @@ -249,9 +247,7 @@
    3.37  						use_start = 0;
    3.38  						use_stdlib = 0;
    3.39  					} else if (strcmp(nostdinc_plus,argv[i]) == 0) {
    3.40 -						if (cplusplus==1) {
    3.41 -							use_nostdinc_plus = 0;
    3.42 -						}
    3.43 +						if (cpp) use_nostdinc_plus = 0;
    3.44  					}
    3.45  					break;
    3.46  
    3.47 @@ -388,7 +384,7 @@
    3.48  
    3.49  	gcc_argv[argcnt++] = cpp ? cpp : cc;
    3.50  
    3.51 -	if (cplusplus) gcc_argv[argcnt++] = "-fno-use-cxa-atexit";
    3.52 +	if (cpp) gcc_argv[argcnt++] = "-fno-use-cxa-atexit";
    3.53  
    3.54  	if (linking && source_count) {
    3.55  //#if defined HAS_ELF && ! defined HAS_MMU
    3.56 @@ -414,16 +410,16 @@
    3.57  	if (use_stdinc && source_count) {
    3.58  		gcc_argv[argcnt++] = nostdinc;
    3.59  
    3.60 -		if (cplusplus) {
    3.61 +		if (cpp) {
    3.62  			if (use_nostdinc_plus) {
    3.63  				gcc_argv[argcnt++] = nostdinc_plus;
    3.64  			}
    3.65  			gcc_argv[argcnt++] = "-isystem";
    3.66 -			asprintf(gcc_argv+(argcnt++), "%sc++/4.1.1", uClibc_inc);
    3.67 +			asprintf(gcc_argv+(argcnt++), "%s/c++/include", devprefix);
    3.68  		}
    3.69  
    3.70  		gcc_argv[argcnt++] = "-isystem";
    3.71 -		gcc_argv[argcnt++] = uClibc_inc;
    3.72 +		asprintf(gcc_argv+(argcnt++), "%s/include", devprefix);
    3.73  		gcc_argv[argcnt++] = "-isystem";
    3.74  		asprintf(gcc_argv+(argcnt++), "%s/gcc/include", devprefix);
    3.75  		if(incstr) gcc_argv[argcnt++] = incstr;
    3.76 @@ -459,7 +455,7 @@
    3.77  		for (i = 0 ; i < liblen ; i++)
    3.78  			if (libraries[i]) gcc_argv[argcnt++] = libraries[i];
    3.79  		if (use_stdlib) {
    3.80 -			if (cplusplus) {
    3.81 +			if (cpp) {
    3.82  				gcc_argv[argcnt++] = "-lstdc++";
    3.83  				gcc_argv[argcnt++] = "-lm";
    3.84  			}