- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've been playing a bit with building a Nios2 toolchain with c++ support from buildroot svn, and finally I have something that seems to be working. In case someone else are interested; here is a HOWTO:
1) To get global constructors/destructors to work, the latest uClibc snapshot (as of today) is needed. CTOR/DTOR-support must be enabled in the config. 2) UClibc provides its own crti.o/crtn.o-files, so gcc's internal ones has to be disabled. The start/end-files (ctri/crtbegin.o, crtn/ctrend.o) must always be linked in when uClibc CTOR/DTOR-support is enabled, to get rid of unresolved symbol errors. The gcc-patch below fixes these issues: diff -urN gcc-3.4.6.orig/gcc/config/nios2/nios2.h gcc-3.4.6/gcc/config/nios2/nios2.h --- gcc-3.4.6.orig/gcc/config/nios2/nios2.h 2007-01-04 09:40:02.000000000 +0100 +++ gcc-3.4.6/gcc/config/nios2/nios2.h 2007-01-04 09:49:16.000000000 +0100 @@ -88,8 +88,6 @@ N_("All ld/st instructins do not use io variants (default)") }, { "smallc", 0, N_("Link with a limited version of the C library") }, - { "ctors-in-init", 0, - "" /* undocumented: N_("Link with static constructors and destructors in init") */ }, { "", TARGET_DEFAULT, 0 } } @@ -140,12 +138,12 @@ # define STARTFILE_SPEC "%{msys-crt0=*: %*} %{!msys-crt0=*: crt1%O%s} %{msys-crt0=: %eYou need a C startup file for -msys-crt0=} - %{mctors-in-init: crti%O%s crtbegin%O%s} + crti%O%s crtbegin%O%s " # undef ENDFILE_SPEC # define ENDFILE_SPEC - "%{mctors-in-init: crtend%O%s crtn%O%s}" + " crtend%O%s crtn%O%s" /*********************** diff -urN gcc-3.4.6.orig/gcc/config/nios2/t-nios2 gcc-3.4.6/gcc/config/nios2/t-nios2 --- gcc-3.4.6.orig/gcc/config/nios2/t-nios2 2007-01-04 09:40:02.000000000 +0100 +++ gcc-3.4.6/gcc/config/nios2/t-nios2 2007-01-04 09:47:25.000000000 +0100 @@ -36,17 +36,7 @@ echo '' > ${DPBIT} cat $(srcdir)/config/fp-bit.c >> ${DPBIT} -EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o - -# Assemble startup files. -$(T)crti.o: $(srcdir)/config/nios2/crti.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) - -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/nios2/crti.asm - -$(T)crtn.o: $(srcdir)/config/nios2/crtn.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) - -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/nios2/crtn.asm - +EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o # # You may need to provide additional# defines at the beginning of # # fp-bit.c and dp-bit.c to control target endianness and other options 3) To fix gcc configuration, the buildroot gcc-patch from http://nioswiki.jot.com/wikihome/operating.../buildrootguide (http://nioswiki.jot.com/wikihome/operatingsystems/buildrootguide) must be added: Index: toolchain/gcc/3.4.6/100-uclibc-conf.patch =================================================================== --- toolchain/gcc/3.4.6/100-uclibc-conf.patch (revision 14569) +++ toolchain/gcc/3.4.6/100-uclibc-conf.patch (working copy) @@ -1,11 +1,3 @@ ---- gcc-3.4.1/gcc/config/t-linux-uclibc -+++ gcc-3.4.1/gcc/config/t-linux-uclibc -@@ -0,0 +1,5 @@ -+# Remove glibc specific files added in t-linux -+SHLIB_MAPFILES := $(filter-out $(srcdir)/config/libgcc-glibc.ver, $(SHLIB_MAPFILES)) -+ -+# Use unwind-dw2-fde instead of unwind-dw2-fde-glibc -+LIB2ADDEH := $(subst unwind-dw2-fde-glibc.c,unwind-dw2-fde.c,$(LIB2ADDEH)) --- gcc-3.4.1/gcc/config.gcc +++ gcc-3.4.1/gcc/config.gcc @@ -2310,10 +2310,16 @@ @@ -18,7 +10,7 @@ +# Rather than hook into each target, just do it after all the linux +# targets have been processed +case ${target} in -+*-linux-uclibc*) tm_defines="${tm_defines} USE_UCLIBC" ; tmake_file="${tmake_file} t-linux-uclibc" ++*-linux-uclibc*) tm_defines="${tm_defines} USE_UCLIBC" +esac # Support for --with-cpu and related options (and a few unrelated options, 4) To get rid of stdlibc++ compilation errors, this patch must be added: http://gcc.gnu.org/bugzilla/attachment.cgi?id=6132 (http://gcc.gnu.org/bugzilla/attachment.cgi?id=6132) and in addition the uClibc locale-patch (toolchain/gcc/3.4.6/200-uclibc-locale.patch) must be disabled. 5) Elf2flt fixes: Rather than using the elf2flt linker-script from http://nioswiki.jot.com/wikihome/operating.../buildrootguide (http://nioswiki.jot.com/wikihome/operatingsystems/buildrootguide) I have used the one in buildroot with an updated elf2flt.nios2.conditional patch posted in http://bugs.uclibc.org/view.php?id=618 (http://bugs.uclibc.org/view.php?id=618). Link to patch: http://bugs.uclibc.org/file_download.php?f...id=601&type=bug (http://bugs.uclibc.org/file_download.php?file_id=601&type=bug) This seems to work just fine. 6) And last, a small patch for binutils to fix compilation errors with gcc 4.x.x: --- binutils/gas/config/tc-nios2.c.orig 2006-03-13 03:39:58.000000000 +0100 +++ binutils/gas/config/tc-nios2.c 2006-11-09 15:31:46.000000000 +0100 @@ -1837,7 +1837,7 @@ /* apply the rightshift */ - (signed) fixup >>= howto->rightshift; + fixup >>= howto->rightshift; /* truncate the fixup to right size */ switch (fixP->fx_r_type) @@ -1882,7 +1882,7 @@ nios2_check_overflow (valueT fixup, reloc_howto_type * howto) { /* apply the rightshift before checking for overflow */ - (signed) fixup >>= howto->rightshift; + fixup >>= howto->rightshift; /* check for overflow - return TRUE if overflow, FALSE if not */ switch (howto->complain_on_overflow) - AtleLink Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great !! And thanks a lot. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
Could you send these patches to buildroot/uclibc ? I think Vapier will be happy to merge them. I am still waiting for the gnutools source of Altera 6.1. And I will update the wiki then.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page