[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [microblaze-uclinux] C++?



Hi again Yashi,

I wrote:

> Yasushi SHOJI wrote:

>> is anyone successfully compiled and run c++ program?
> 
> I've fiddled, got hello world to compile and mostly link.  Need to port 
> the crtn.S and crti.S init/fini stubs for uClibc.  I had to make a 
> couple of changes to make it go, I'll make a diff and post it if you 
> want to keep going with it.  Another item for the wishlist perhaps? :)

Note to everyone, this c++ stuff is experimental, and completely broken. 
  Don't apply this patch unless you are ready to get your hands dirty 
fixing things!

Attached are cpp-test.tar.gz which should drop into /users, it has the 
makefile I used to at least compile the thing.  You will see a horrible 
hard-coded include and lib path, adjust as required.  To fix this 
properly you would work in vendors/Xilinx/common/common-config.arch

Also attached is a patch on uClibc, it goes into 
uClibc/libc/sysdeps/linux/microblaze.  It just tweaks the Makefile and 
adds (broken) instances of crti.S and crtn.S.  These were just copied 
from the v850 tree.

CAUTION I strongly recommend you just look at the patch and apply the 
Makefile changes by hand, else you'll probably end up breaking it.  It's 
been generated against a clean CVS, not the one with the "critical 
patch" applied.  You will get conflicts!

To be honest I'm not even sure what crtn and crti are supposed to do.  A 
dig through the other arch's didn't enlighten me in the slightest, they 
are all completely different!  I think the trick will be to grab the 
microblaze gcc and libs sources, and trawl through there looking for the 
relevant code.  It will be tightly coupled to the mb-gcc C++ ABI 
implementation.

Have fun,

John
diff -Nur /opt/src/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/crti.S uClibc/libc/sysdeps/linux/microblaze/crti.S
--- /opt/src/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/crti.S	1970-01-01 10:00:00.000000000 +1000
+++ uClibc/libc/sysdeps/linux/microblaze/crti.S	2004-03-18 23:07:05.000000000 +1000
@@ -0,0 +1,27 @@
+	.file	"initfini.c"
+#APP
+	
+	.section .init
+#NO_APP
+	.align 1
+	.global __init
+	.type	__init, @function
+__init:
+	jarl __save_r31, r10
+#APP
+	
+	.align 1
+	
+	
+	.section .fini
+#NO_APP
+	.align 1
+	.global __fini
+	.type	__fini, @function
+__fini:
+	jarl __save_r31, r10
+#APP
+	.align 1
+	
+	
+	.ident	"GCC: (GNU) 3.3.2"
diff -Nur /opt/src/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/crtn.S uClibc/libc/sysdeps/linux/microblaze/crtn.S
--- /opt/src/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/crtn.S	1970-01-01 10:00:00.000000000 +1000
+++ uClibc/libc/sysdeps/linux/microblaze/crtn.S	2004-03-18 23:07:10.000000000 +1000
@@ -0,0 +1,24 @@
+	.file	"initfini.c"
+#APP
+	
+	.section .init
+#NO_APP
+	.align 1
+	.global __init
+	.type	__init, @function
+#NO_APP
+	jr __return_r31
+	.size	__init, .-__init
+#APP
+	
+	.section .fini
+#NO_APP
+	.align 1
+	.global __fini
+	.type	__fini, @function
+#NO_APP
+	jr __return_r31
+	.size	__fini, .-__fini
+#APP
+	
+	.ident	"GCC: (GNU) 3.3.2"
diff -Nur /opt/src/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/Makefile uClibc/libc/sysdeps/linux/microblaze/Makefile
--- /opt/src/uClinux-dist/uClibc/libc/sysdeps/linux/microblaze/Makefile	2003-09-02 15:14:27.000000000 +1000
+++ uClibc/libc/sysdeps/linux/microblaze/Makefile	2004-03-19 09:03:30.000000000 +1000
@@ -27,22 +27,23 @@
 
 CRT0_SRC = crt0.S
 CRT0_OBJ = crt0.o crt1.o
+CTOR_TARGETS=$(TOPDIR)lib/crti.o $(TOPDIR)lib/crtn.o
 
 SSRC = setjmp.S __longjmp.S vfork.S
 SOBJS = $(patsubst %.S,%.o, $(SSRC))
 
-CSRC = _mmap.c syscall.c clone.c
+CSRC = _mmap.c syscall.c clone.c # fixdfsi.c
 COBJS = $(patsubst %.c,%.o, $(CSRC))
 
 OBJS = $(SOBJS) $(COBJS)
 
-
 all: $(OBJS) $(LIBC)
 
 $(LIBC): ar-target 
 
-ar-target: $(OBJS) $(CRT0_OBJ)
+ar-target: $(OBJS) $(CRT0_OBJ) $(CTOR_TARGETS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
+	mkdir -p $(TOPDIR)lib/
 	cp $(CRT0_OBJ) $(TOPDIR)lib/
 
 $(CRT0_OBJ): $(CRT0_SRC)
@@ -57,9 +58,33 @@
 	$(CC) $(CFLAGS) -c $< -o $@
 	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
+ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
+crti.o: crti.S
+	$(CC) $(CFLAGS) -c crti.S -o crti.o
+
+$(TOPDIR)lib/crti.o: crti.o
+	$(INSTALL) -d $(TOPDIR)lib/
+	cp crti.o $(TOPDIR)lib/
+
+crtn.o: crtn.S
+	$(CC) $(CFLAGS) -c crtn.S -o crtn.o
+
+$(TOPDIR)lib/crtn.o: crtn.o
+	$(INSTALL) -d $(TOPDIR)lib/
+	cp crtn.o $(TOPDIR)lib/
+else
+$(TOPDIR)lib/crti.o:
+	$(INSTALL) -d $(TOPDIR)lib/
+	$(AR) $(ARFLAGS) $(TOPDIR)lib/crti.o
+$(TOPDIR)lib/crtn.o:
+	$(INSTALL) -d $(TOPDIR)lib/
+	$(AR) $(ARFLAGS) $(TOPDIR)lib/crtn.o
+endif
+
+
 headers:
 
 clean:
-	rm -f *.[oa] *~ core
-	rm -f bits/sysnum.h
+	$(RM) *.[oa] *~ core
+	$(RM) bits/sysnum.h
 

Attachment: user_cpptest.tar.gz
Description: GNU Zip compressed data