2008/10/26
Fixing eCos warnings
If you build eCos with a GCC 4.x compiler, you'll see new warnings as GCC 4.x series are stricter about C syntax.
The following patch fixes up several warnings:
Index: trunk/ecos/packages/kernel/current/include/instrument_desc.h =================================================================== --- trunk/ecos/packages/kernel/current/include/instrument_desc.h (revision 2) +++ trunk/ecos/packages/kernel/current/include/instrument_desc.h (revision 4513) @@ -3,7 +3,7 @@ /* Install tree : INSTALL/include/cyg/kernel/instrument_desc.h */ struct instrument_desc_s { - char * msg; + const char * msg; CYG_WORD num; }; Index: trunk/ecos/packages/kernel/current/include/instrmnt.h =================================================================== --- trunk/ecos/packages/kernel/current/include/instrmnt.h (revision 4) +++ trunk/ecos/packages/kernel/current/include/instrmnt.h (revision 4513) @@ -87,7 +87,7 @@ #endif #ifdef CYGDBG_KERNEL_INSTRUMENT_MSGS -externC char * cyg_instrument_msg(CYG_WORD16 type); +externC const char * cyg_instrument_msg(CYG_WORD16 type); #endif // ------------------------------------------------------------------------- Index: trunk/ecos/packages/kernel/current/src/debug/dbg_gdb.cxx =================================================================== --- trunk/ecos/packages/kernel/current/src/debug/dbg_gdb.cxx (revision 1926) +++ trunk/ecos/packages/kernel/current/src/debug/dbg_gdb.cxx (revision 4513) @@ -229,7 +229,7 @@ //-------------------------------------------------------------------------- // Some support routines for manufacturing thread info strings -static char *dbg_addstr(char *s, char *t) +static char *dbg_addstr(char *s, const char *t) { while( (*s++ = *t++) != 0 ); @@ -241,7 +241,7 @@ char buf[16]; char sign = '+'; cyg_count8 bpos; - char *digits = "0123456789ABCDEF"; + const char *digits = "0123456789ABCDEF"; if( n < 0 ) n = -n, sign = '-'; @@ -292,7 +292,7 @@ info->context_exists = 1; char *sbp = statebuf; - char *s; + const char *s; if( thread->get_state() & Cyg_Thread::SUSPENDED ) { Index: trunk/ecos/packages/kernel/current/src/instrmnt/meminst.cxx =================================================================== --- trunk/ecos/packages/kernel/current/src/instrmnt/meminst.cxx (revision 1926) +++ trunk/ecos/packages/kernel/current/src/instrmnt/meminst.cxx (revision 4513) @@ -227,7 +227,7 @@ #define CYGDBG_KERNEL_INSTRUMENT_MSGS_DEFINE_TABLE #include-externC char * cyg_instrument_msg(CYG_WORD16 type) { +externC const char * cyg_instrument_msg(CYG_WORD16 type) { struct instrument_desc_s *record; struct instrument_desc_s *end_record; Index: trunk/ecos/packages/services/threadload/current/src/threadload.cxx =================================================================== --- trunk/ecos/packages/services/threadload/current/src/threadload.cxx (revision 1926) +++ trunk/ecos/packages/services/threadload/current/src/threadload.cxx (revision 4513) @@ -125,10 +125,11 @@ */ static void cyg_threadload_startup(void) { + static const char * name = "THREADLOAD"; cyg_thread_create( 30, // Just before Idle task cyg_threadload_init, 0, - "THREADLOAD", + (char *)name, // ugly? yes, eCos &threadload_stack[0], sizeof(threadload_stack), &threadload_thread, Index: trunk/ecos/packages/services/memalloc/common/current/include/dlmallocimpl.hxx =================================================================== --- trunk/ecos/packages/services/memalloc/common/current/include/dlmallocimpl.hxx (revision 4) +++ trunk/ecos/packages/services/memalloc/common/current/include/dlmallocimpl.hxx (revision 4513) @@ -108,7 +108,7 @@ Cyg_dlmalloc_size_t size; /* Size in bytes, including overhead. */ struct malloc_chunk* fd; /* double links -- used only if free. */ struct malloc_chunk* bk; - }; + } malloc_chunk; protected: /* The first value returned from sbrk */ Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoll.cxx =================================================================== --- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoll.cxx (revision 1926) +++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoll.cxx (revision 4513) @@ -175,7 +175,7 @@ break; if (c >= base) break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtol.cxx =================================================================== --- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtol.cxx (revision 1926) +++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtol.cxx (revision 4513) @@ -179,7 +179,7 @@ break; if (c >= base) break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoull.cxx =================================================================== --- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoull.cxx (revision 1926) +++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoull.cxx (revision 4513) @@ -151,7 +151,7 @@ break; if (c >= base) break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1; Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoul.cxx =================================================================== --- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoul.cxx (revision 1926) +++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoul.cxx (revision 4513) @@ -155,7 +155,7 @@ break; if (c >= base) break; - if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) any = -1; else { any = 1;
Make eCos compile quietly
It would be nice that eCos offers an option to build quietly.
eCos Makefiles always print out the very long GCC command line to build every single file. This may lead to leave warning messages unnoticed, buried under the numerous lines of regular GCC option switches:
arm-elf-gcc -c -I/tmp/build/ecos_build/../ecos_install/include -I/tmp/ecos/packages/infra/current -I/tmp/ecos/packages/infra/current/src -I/tmp/ecos/packages/infra/current/tests -I. -I/tmp/ecos/packages/infra/current/src/ -finline-limit=7000 -g -O0 -Wall -Wpointer-arith -Wno-inline -Wundef -Woverloaded-virtual -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -Wp,-MD,src/delete.tmp -o src/infra_delete.o /tmp/ecos/packages/infra/current/src/delete.cxx arm-elf-gcc -c -I/tmp/build/ecos_build/../ecos_install/include -I/tmp/ecos/packages/infra/current -I/tmp/ecos/packages/infra/current/src -I/tmp/ecos/packages/infra/current/tests -I. -I/tmp/ecos/packages/infra/current/src/ -finline-limit=7000 -g -O0 -Wall -Wpointer-arith -Wstrict-prototypes -Wno-inline -Wundef -ffunction-sections -fdata-sections -fno-exceptions -Wp,-MD,src/eprintf.tmp -o src/infra_eprintf.o /tmp/ecos/packages/infra/current/src/eprintf.c arm-elf-gcc -c -I/tmp/build/ecos_build/../ecos_install/include -I/tmp/ecos/packages/infra/current -I/tmp/ecos/packages/infra/current/src -I/tmp/ecos/packages/infra/current/tests -I. -I/tmp/ecos/packages/infra/current/src/ -finline-limit=7000 -g -O0 -Wall -Wpointer-arith -Wno-inline -Wundef -Woverloaded-virtual -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -Wp,-MD,src/pure.tmp -o src/infra_pure.o /tmp/ecos/packages/infra/current/src/pure.cxx
The following patch tells eCos to build quielty, only showing the source files being compiled and linked up:
[CC] infra/current/src/delete.cxx [CC] infra/current/src/eprintf.c [CC] infra/current/src/pure.cxx
To restore the original behaviour, simply runs make from within the eCos build tree with the VERBOSE=1 option.
Note that the patch requires to modify several files. If you use another processor but an ARM, you may need to tweak other files, using the same rules.
Index: ecos/host/tools/configtool/common/common/build.cxx =================================================================== --- ecos/host/tools/configtool/common/common/build.cxx (revision 1925) +++ ecos/host/tools/configtool/common/common/build.cxx (revision 4424) @@ -454,7 +454,12 @@ fprintf (stream, "OBJECTS := $(OBJECTS:.c=.o.d)\n"); fprintf (stream, "OBJECTS := $(OBJECTS:.S=.o.d)\n\n"); fprintf (stream, "$(LIBRARY).stamp: $(OBJECTS)\n"); + fprintf (stream, "ifeq ($(VERBOSE),1)\n"); fprintf (stream, "\t$(AR) rcs $(PREFIX)/lib/$(@:.stamp=) $(foreach obj,$?,$(dir $(obj))$(OBJECT_PREFIX)_$(notdir $(obj:.o.d=.o)))\n"); + fprintf (stream, "else\n"); + fprintf (stream, "\t@echo \" [AR] $(subst $(REPOSITORY)/,,$(LIBRARY))\"\n"); + fprintf (stream, "\t@$(AR) rcs $(PREFIX)/lib/$(@:.stamp=) $(foreach obj,$?,$(dir $(obj))$(OBJECT_PREFIX)_$(notdir $(obj:.o.d=.o)))\n"); + fprintf (stream, "endif\n"); fprintf (stream, "\t@cat $^ > $(@:.stamp=.deps)\n"); fprintf (stream, "\t@touch $@\n\n"); } @@ -560,16 +565,28 @@ fprintf (stream, "build: headers $(PREFIX)/include/pkgconf/ecos.mak\n"); for (make = 0; make < info_make_vector.size (); make++) { // for each make if (info_make_vector [make].loadable->makes [info_make_vector [make].make].priority < 100) { // if priority higher than default complilation + fprintf (stream, "ifeq ($(VERBOSE),1)\n"); fprintf (stream, "\t$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ()); + fprintf (stream, "else\n"); + fprintf (stream, "\t@$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ()); + fprintf (stream, "endif\n"); } } for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package const std::string source_path = info_vector [loadable].directory; + fprintf (stream, "ifeq ($(VERBOSE),1)\n"); fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "else\n"); + fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "endif\n"); } for (make = 0; make < info_make_vector.size (); make++) { // for each make if (info_make_vector [make].loadable->makes [info_make_vector [make].make].priority >= 100) { // if priority lower than or equal to default complilation + fprintf (stream, "ifeq ($(VERBOSE),1)\n"); fprintf (stream, "\t$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ()); + fprintf (stream, "else\n"); + fprintf (stream, "\t@$(MAKE) -r -C %s %s\n", info_make_vector [make].loadable->directory.c_str (), resolve_tokens (info_make_vector [make].loadable->makes [info_make_vector [make].make].target).c_str ()); + fprintf (stream, "endif\n"); } } fprintf (stream, "\t@echo $@ finished\n\n"); @@ -577,21 +594,33 @@ fprintf (stream, "clean:\n"); for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package const std::string source_path = info_vector [loadable].directory; + fprintf (stream, "ifeq ($(VERBOSE),1)\n"); fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "else\n"); + fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "endif\n"); } fprintf (stream, "\t@echo $@ finished\n\n"); fprintf (stream, "tests: build\n"); for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package const std::string source_path = info_vector [loadable].directory; + fprintf (stream, "ifeq ($(VERBOSE),1)\n"); fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "else\n"); + fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "endif\n"); } fprintf (stream, "\t@echo $@ finished\n\n"); fprintf (stream, "headers:\n"); for (loadable = 0; loadable < info_vector.size (); loadable++) { // for each buildable loaded package const std::string source_path = info_vector [loadable].directory; + fprintf (stream, "ifeq ($(VERBOSE),1)\n"); fprintf (stream, "\t$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "else\n"); + fprintf (stream, "\t@$(MAKE) -r -C %s $@\n", source_path.c_str ()); + fprintf (stream, "endif\n"); } fprintf (stream, "\t@echo $@ finished\n\n"); Index: ecos/packages/services/memalloc/common/current/cdl/memalloc.cdl =================================================================== --- ecos/packages/services/memalloc/common/current/cdl/memalloc.cdl (revision 1926) +++ ecos/packages/services/memalloc/common/current/cdl/memalloc.cdl (revision 4423) @@ -271,7 +271,8 @@ make -priority 50 { heapgeninc.tcl :/src/heapgen.cpp - $(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heapgen.tmp -E $< -o $@ + @echo " [CC] $(subst $(REPOSITORY)/,,$<)" + @$(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heapgen.tmp -E $< -o $@ @sed -e '/^ *\\/d' -e "s#.*: #$@: #" heapgen.tmp > $(notdir $@).deps @rm heapgen.tmp } @@ -283,6 +284,7 @@ # an absolute path. make -priority 50 { heaps.cxx : heapgeninc.tcl /src/heapgen.tcl + @echo " [CC] $(subst $(REPOSITORY)/,,$<)" XPWD=`pwd` ; cd $(REPOSITORY)/$(PACKAGE)/src ; sh heapgen.tcl "$(PREFIX)" "$$XPWD" @cp heaps.hxx "$(PREFIX)"/include/pkgconf/heaps.hxx @chmod u+w "$(PREFIX)"/include/pkgconf/heaps.hxx @@ -290,7 +292,8 @@ make_object { heaps.o.d : heaps.cxx - $(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heaps.tmp -c -o $(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< + @echo " [CC] $(subst $(REPOSITORY)/,,$<)" + @$(CC) $(ACTUAL_CXXFLAGS) $(INCLUDE_PATH) -Wp,-MD,heaps.tmp -c -o $(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< @sed -e '/^ *\\/d' -e "s#.*: #$@: #" heaps.tmp > $@ @rm heaps.tmp } Index: ecos/packages/pkgconf/rules.mak =================================================================== --- ecos/packages/pkgconf/rules.mak (revision 1930) +++ ecos/packages/pkgconf/rules.mak (revision 4423) @@ -91,7 +91,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +else + @echo " [CC] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@ @rm $(@:.o.d=.tmp) @@ -101,7 +106,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +else + @echo " [CC] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@ @rm $(@:.o.d=.tmp) @@ -111,7 +121,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +else + @echo " [CC] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@ @rm $(@:.o.d=.tmp) @@ -121,7 +136,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +else + @echo " [AS] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.o.d=.tmp) -o $(dir $@)$(OBJECT_PREFIX)_$(notdir $(@:.o.d=.o)) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.o.d=.tmp) > $@ @rm $(@:.o.d=.tmp) @@ -134,7 +154,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +else + @echo " [DEP] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@ @rm $(@:.d=.tmp) @@ -144,7 +169,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +else + @echo " [DEP] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@ @rm $(@:.d=.tmp) @@ -154,7 +184,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +else + @echo " [DEP] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CXXFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@ @rm $(@:.d=.tmp) @@ -164,7 +199,12 @@ else @mkdir -p $(dir $@) endif +ifeq ($(VERBOSE),1) $(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +else + @echo " [DEP] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -c $(INCLUDE_PATH) -I$(dir $<) $(ACTUAL_CFLAGS) -Wp,-MD,$(@:.d=.tmp) -o $(@:.d=.o) $< +endif @sed -e '/^ *\\/d' -e "s#.*: #$@: #" $(@:.d=.tmp) > $@ @rm $(@:.d=.tmp) @@ -176,9 +216,19 @@ @mkdir -p $(dir $@) endif ifneq ($(IGNORE_LINK_ERRORS),) +ifeq ($(VERBOSE),1) -$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS) else + @echo " [LD] $(subst $(REPOSITORY)/,,$<)" + @-$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS) +endif +else +ifeq ($(VERBOSE),1) $(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS) +else + @echo " [LD] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -L$(PREFIX)/lib -Ttarget.ld -o $@ $(<:.d=.o) $(LDFLAGS) +endif endif # rule to generate all tests and create a dependency file "tests.deps" by Index: ecos/packages/hal/arm/arch/current/cdl/hal_arm.cdl =================================================================== --- ecos/packages/hal/arm/arch/current/cdl/hal_arm.cdl (revision 1926) +++ ecos/packages/hal/arm/arch/current/cdl/hal_arm.cdl (revision 4423) @@ -67,8 +67,9 @@ # n.b. grep does not behave itself under win32 make -priority 1 { arm.inc : /src/hal_mk_defs.c - $(CC) $(ACTUAL_CFLAGS) $(INCLUDE_PATH) -Wp,-MD,arm.tmp -o hal_mk_defs.tmp -S $< - fgrep .equ hal_mk_defs.tmp | sed s/#// > $@ + @echo " [CPP] $(subst $(REPOSITORY)/,,$<)" + @$(CC) $(ACTUAL_CFLAGS) $(INCLUDE_PATH) -Wp,-MD,arm.tmp -o hal_mk_defs.tmp -S $< + @fgrep .equ hal_mk_defs.tmp | sed s/#// > $@ @echo $@ ": \\" > $(notdir $@).deps @tail -n +2 arm.tmp >> $(notdir $@).deps @echo >> $(notdir $@).deps @@ -77,7 +78,8 @@ make { /lib/vectors.o : /src/vectors.S - $(CC) -Wp,-MD,vectors.tmp $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -c -o $@ $< + @echo " [AS] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -Wp,-MD,vectors.tmp $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -c -o $@ $< @echo $@ ": \\" > $(notdir $@).deps @tail -n +2 vectors.tmp >> $(notdir $@).deps @echo >> $(notdir $@).deps @@ -86,7 +88,8 @@ make { /lib/target.ld: /src/arm.ld - $(CC) -E -P -Wp,-MD,target.tmp -xc $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -o $@ $< + @echo " [CPP] $(subst $(REPOSITORY)/,,$<)" + @$(CC) -E -P -Wp,-MD,target.tmp -xc $(INCLUDE_PATH) $(ACTUAL_CFLAGS) -o $@ $< @echo $@ ": \\" > $(notdir $@).deps @tail -n +2 target.tmp >> $(notdir $@).deps @echo >> $(notdir $@).deps Index: ecos/packages/hal/common/current/cdl/hal.cdl =================================================================== --- ecos/packages/hal/common/current/cdl/hal.cdl (revision 1926) +++ ecos/packages/hal/common/current/cdl/hal.cdl (revision 4423) @@ -71,7 +71,8 @@ make -priority 250 { /lib/extras.o: /lib/libextras.a - $(CC) $(CFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive -o $@ $< + @echo " [LD] $(subst $(REPOSITORY)/,,$<)" + @$(CC) $(CFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive -o $@ $< }
Building eCos toolchain for Mac OSX, Linux and Cygwin
The following document explains how to rebuild your own tool chain for an ARM v4/v5 processor in a Unix environment for the eCos platform. The toolchains have been successfully rebuilt on the following host platforms:
- Mac OS X 10.5.5
- Linux 2.6.26
- Cygwin / WinXP Pro SP3
Prerequisites
It is assumed that you have a valid environment for native compilation, with
- GNU C compiler suite
- GNU Make
- texinfo
- flex/bison
- gettext (including the 'development' version)
- m4
- makeinfo
If Insight is to be installed
- Tcl/Tk
- expat
- ncurses, including the development package
If you wish to build GCC 4.3.0 or later, you also need two mathematical libraries: GMP and MPFR
- if these libraries are not available on your host, you can recompile them from the source.
- it is recommended to install them into the same directory than the GCC tool chain if you are not using a package manager.
Getting the source code
The following source distribution are required:
- Binutils (assembler, linker and other binary file tools)
- Go to http://www.gnu.org/software/binutils and grab the latest release
- GNU C compiler core
- Go to http://gcc.gnu.org then pick up a mirror, go down the releases directory and grab the latest release that starts with gcc-core
- GNU C++ compiler extension
- same as above, download the archive that starts with gcc-g++
- Newlib
- Go to http://sourceware.org/newlib, follow the download link then the FTP directory link and grab the latest release
- Insight & GDB [optional]
- Go to http://sourceware.org/insight, follow the FTP directory link and grab the latest release
- GMP [only if not already available on your platform]
- Go to http://gmplib.org/#DOWNLOAD and download the latest version
- MPFR [only if not already available on your platform]
- Go to http://www.mpfr.org/mpfr-current/#download and download the latest version
- Be sure to also download the cumulative patch from the same page
Note
- Insight and the GDB debugger are not required to build ARM libraries and applications. However it is useful to build GDB and the Insight GUI to enable application debugging.
The GNU tool chain has been rebuilt with the following versions of the tools
- Binutils 2.18: binutils-2.18.tar.bz2
- GMP 4.2.4: gmp-4.2.4.tar.bz2
- MPFR 2.3.2: mpfr-2.3.2.tar.bz2
- GNU C/C++ 4.2.4: gcc-core-4.2.4.tar.bz2, gcc-g++-4.2.4.tar.bz2
- GNU C/C++ 4.3.2: gcc-core-4.3.2.tar.bz2, gcc-g++-4.3.2.tar.bz2
- Newlib 1.16: newlib-1.16.0.tar.gz
- Insight 6.8: insight-6.8.tar.bz2
cd $HOME/tmp wget
mkdir src build cd src for a in ../*.bz2; do tar xjvf $a; done for a in ../*.gz; do tar xzvf $a; done for d in *; do mkdir ../build/$d; done cd gcc* ln -s ../newlib*/libgloss ln -s ../newlib*/newlib cd ../..
Defining the global parameters
Here we define where the toolchain will be installed (PREFIX) and the target (TARGET) for which we want to build the toolchain.
- You can change the installation prefix, although depending on the OS (Linux, Windows, ...) you should follow the installation path guidelines...
- Never change the target, as long as you build a toolchain for an ARM processor
export PREFIX=/usr/local/gnu export TARGET=arm-elf
Clean up your PATH environment. You need to be sure that no other cross-compiler for the same target already exists in your executable path.
Typical settings, YMMV:
- Windows/Cygwin
export PATH=/usr/bin:/bin:/cygdrive/c/WINDOWS/System32:/cygdrive/c/WINDOWS
- Linux
export PATH=/usr/bin:/bin
Note
Keep in mind that these environment variables are only valid within the current shell, so if you close the session before the tool chain compilation is complete, you need to redefine these values in the new session before resuming the compilation
Compiling the tool chain
Preliminary notes
- On Mac OS X, it is recommended to build with the new GCC compiler, so prefix each ./configure statement with
CC=gcc-4.2 ./configure ...
- On 64-bit hosts (Core2 Duo for ex.), you may want to compile the toolchain in 64-bit mode.
Add the following flag before the ./configure statement
CFLAGS="-O2 -m64" ./configure ...
Compiling the binutils
Configuration options
- discard native language support (all execution messages are dumped in english)
- ensure we used shared libraries to save space (and SDK size)
Building
cd build/binutils* ../../src/binutils*/configure --prefix=$PREFIX --target=$TARGET \ --enable-shared --enable-serial-configure --disable-nls make sudo make install cd ../..
Notes
- On Cygwin, you do not need the sudo command to install the toolchain.
- Replace sudo make install with make install in the the following instructions
- On Mac OS X, you need to build the static version of binutils (or fear compilation issues of the GCC cross compiler)
- Replace --enabled-shared with --disabled-shared in the above configuration line. All the other tools of the toolchain may be built as shared libraries.
- On some Linux host, the configure script fails to detect the installed makeinfo tool, and in turn prevent from building the binutils.
As a dirty hack you can replace the ../../src/binutils-2.18/missing file with the env command, so that it actually invoke the makeinfo tool - be sure it is installed though
(cd ../../src/binutils-2.18 && mv missing missing.old && ln -s /usr/bin/env missing)
Compiling the GMP library
This extra step is only required if GMP is already available on your platform.
Before rebuilding it from the sources, please check your favorite package manager cannot install it from your distribution server.
Note that many Linux distributions still offer outdated versions of these libraries which are too old for rebuilding GCC.
Cygwin package manager -setup.exe- now offers the GMP amd MPFR libraries.
Building GMP
cd build/gmp* ../../src/gmp*/configure --prefix=$PREFIX --disable-nls make make check sudo make install cd ../..
Compiling the MPFR library
This extra step is only required if MPFR is already available on your platform.
Before rebuilding it from the sources, please check your favorite package manager cannot install it from your distribution server.
Configuration options
- MPFR need to know where GMP has been installed
Building MPFR
cd build/mpfr* ../../src/mpfr*/configure --prefix=$PREFIX --with-gmp=$PREFIX make sudo make install cd ../..
Compiling the GNU C/C++ compiler
Updating the execution path
Now that the binutils have been installed, the PATH environment variable needs to be updated so that the compiler may find them to generate the required libraries:
export PATH=$PATH:$PREFIX/bin
Configuration options
- discard native language support (all execution messages are dumped in english)
- ensure we used shared libraries to save space (and SDK size)
- enable compiler support for both C and C++ language (the latter is required to build the eCos kernel)
- both the assembler and the linker are part of the GNU tool chain (i.e. the GNU binutils)
- use the newlib library rather than the GNU libc library
- use a custom build string to differentiate this custom build from the official binary release
- do no build all the variants of the libraries (save a lot of time and space)
- the ARMv4/v5 processors do not sport a floating-point hardware unit (FPU)
- define the default settings for the ARMv4/v5 processor:
- endianess: little
- no support for Thumb 16-bit instruction set
- GNU ABI
Building
cd build/gcc* ../../src/gcc*/configure --prefix=$PREFIX --target=$TARGET --enable-shared --enable-languages=c,c++ \ --disable-nls --with-gnu-as --with-gnu-ld --with-newlib --with-pkgversion=eCos-SDK \ --with-gxx-include-dir=$PREFIX/$TARGET/include --disable-multilib --enable-softfloat \ --disable-bigendian --disable-fpu --disable-interwork --disable-underscore \ --with-float=soft --with-abi=apcs-gnu --with-fpu=fpa --with-mode=arm --disable-__cxa_atexit make suo make install cd ../..
Notes
- same remark as for binutils about the super-user requirement
- if you have recompiled GMP and MPFR from the sources, you also need to tell the configure script where to find these libraries; append the following option switches to the configure parameters:
--with-gmp=$PREFIX --with-mpfr=$PREFIX
- if you have chosen to build in 64-bit mode (-m64), you need to:
- Append the following flags before the ./configure command:
CFLAGS_FOR_BUILD="-O2 -m64" CFLAGS_FOR_TARGET="-O2" CFLAGS="-O2 -m64"
- Tweak the generated arm-elf/libgcc/Makefile, as gcc configure script fails to deal with some cross-compilation setting, and attempts to apply the -m64 flag to the ARM compiler.
Add the following line right before the INTERNAL_CFLAGS = line, to strip out the -m64 flag.
override LIBGCC2_CFLAGS := $(filter-out -m64,$(LIBGCC2_CFLAGS))
- Append the following flags before the ./configure command:
Compiling the GDB debugger with Insight graphical user interface
Configuration options
- The default configuration settings for Insight GDB do not require further customization.
- If you use a recent (4.x) GCC compiler to build up GDB, you'll need to tweak the generated Makefile: it enables the 'stop on warning' GCC compiler option, however the GDB source code does not compile without warnings with a recent GCC compiler:
After running the GDB configure script, and before invoking make, execute the following actions:
- Edit the generated gdb/Makefile file
- Search for occurences of -Werror and remove them
- Save the file
Building
cd build/insight* ../../src/insight*/configure --prefix=$PREFIX --target=$TARGET make sudo make install cd ../..
Fixing build issues
You may have to edit a couple of Makefile to fix up the definitions (before invoking make)
- gdb/Makefile: remove the "-Werror" option, as GDB cannot be built without warnings with a GCC 4.x compiler
- on Mac OS X, add the path to the X11 library: add LDFLAGS=-L/usr/X11R6/lib before the ./configure statement
Saving space
All the executable files are built with optimization and debugger symbols enabled. There is no need to keep those debugging symbols except if the GNU compiler suite itself is to be debugged.
Several dozens of megabytes can be saved off the generated executable files, hence producing a smaller GNU tool suite and a more compact installer file.
Stripping down application files
find $PREFIX -path "*bin/"* -exec strip {} \; 2> /dev/null
Verifying the GNU tool chain
Automatic test suite cannot be run as the tool chain being built is a cross-compilation tool chain, i.e. it produces applications that may not be run on the machine where the applications are buit.
However the compiler configuration can be dumped and verified this way:
arm-elf-gcc -v --help 2>&1 | less
Final notes
Please remember to add the installation prefix to your PATH before building application, i.e. $PREFIX/bin
Windows users: You may want to consider using a virtual machine with a Linux guest OS to build up eCos projects rather than using Cygwin. Cygwin is a clever way to run software designed for Unix in a Windows environment, but it dramatically slows down compilation - a typical build runs 8 to 10 times slower than Linux on the same host machine. Using a Windows VM to run Linux brings compilation time close to the native compilation time.
2008/10/25
Make ecosconfig tool play fair with a Subversion repository
eCos ecosconfig tool has been designed with CVS repository in mind.
However, if you need to store your eCos base code into a Subversion repository, ecosconfig goes mad: it considers any hidden directory, such as .svn SVN administrative dir from a SVN working copy, as an eCos package candidate for inclusion in the eCos build system.
The net result is a ton of stupid warning messages that plague the log output of an eCos code build session.
The following patch prevent ecosconfig from parsing .svn directories.
Note that a better, more generic fix would be to actually ignore any hidden directory, that is a directory which starts with a dot character.
diff -r -u -x '*.svn*' vendor/ecos/host/libcdl/database.cxx new/ecos/host/libcdl/database.cxx --- vendor/ecos/host/libcdl/database.cxx 2008-10-25 17:15:22.000000000 +0200 +++ new/ecos/host/libcdl/database.cxx 2008-10-14 00:35:28.000000000 +0200 @@ -221,7 +221,8 @@ unsigned int i; interp->locate_subdirs(pkgdir, subdirs); for (i = 0; i < subdirs.size(); i++) { - if (("CVS" == subdirs[i]) || ("cvs" == subdirs[i])) { + if (("CVS" == subdirs[i]) || ("cvs" == subdirs[i]) || \ + (".svn" == subdirs[i])) { continue; } if ("" != package.script) { Only in branches/host_tools/ecostools/host/libcdl/doc: .cvsignore diff -r -u -x '*.svn*' vendor/ecos/host/libcdl/interp.cxx new/ecos/host/libcdl/interp.cxx --- vendor/ecos/host/libcdl/interp.cxx 2008-10-25 17:15:22.000000000 +0200 +++ new/ecos/host/libcdl/interp.cxx 2008-10-14 00:35:28.000000000 +0200 @@ -1179,7 +1179,7 @@ foreach entry [glob -nocomplain -- $pattern] { \n\ if ([file isdirectory $entry]) { \n\ set entry [file tail $entry] \n\ - if {($entry != \"CVS\") && ($entry != \"cvs\")} { \n\ + if {($entry != \"CVS\") && ($entry != \"cvs\") && ($entry != \".svn\")} { \n\ lappend result $entry \n\ } \n\ } \n\
YAFFS2 for eCos
As requested on the YAFFS2 mailing-list, I've posted the first alpha release of YAFFS2 wrapper for the eCos file system API. You can download it from here.
Do not forget to read the README file included in the tarball. It contains important information about how to build the source code.
Important note:
YAFFS2 is released under a dual-license scheme. If you ever use the eCos port of YAFFS2, be sure to carefully understand the implications of such licenses. If you add YAFFS2 code to your eCos-based application, your code should either comply with the GPL license - i.e. it requires that you publish the source code of the whole application, or you should buy a commercial license from Aleph One.
Check out the mailing list thread about licensing YAFFS2 w/ eCos.
Building Subversion 1.5 on a Mac
I often need the latest SVN client and server tools on my Mac, but I do not need nor want the fink or macports tools. SVN 1.5 brings very nice features, such as merging.
The following instructions are for Leopard machines. Instructions won't work on a Tiger or earlier OS X releases.
You'll need a working development environment - the following instructions assume you've already installed the GNU toolchain which comes with Xcode (GCC 4.0)
# Download the latest SVN 1.5.x archive # replace 'x' with the actual release (1.5.4 by the time of writing)
wget http://subversion.tigris.org/downloads/subversion-1.5.x.tar.bz2# Download the latest companion archive for SVN 1.5.x
wget http://subversion.tigris.org/downloads/subversion-deps-1.5.x.tar.bz2# Untar the main archive
tar xjvf ../subversion-1.5.?.tar.bz2# Untar the missing dependencies (and only these ones)
tar xjvf ../subversion-deps-1.5.?.tar.bz2 subversion-1.5.?/neon subversion-1.5.?/serf# Let's start. It would be nice to perform an out-of-source build of SVN, but early SVN 1.5.x release simply do not build in an out-of-source environment. So fall back to a in-source build for now
cd subversion-1.5.?/# Be sure to use the simplest PATH environment. # If you have installed other tools (such as MacPorts or fink, you might run into dependencies nightmares)
export PATH=/usr/bin:/bin:/usr/sbin:/sbin# Use the following configure settings. SVN will be installed in /usr/local/subversion, so it's easy to get rid of this version and/or replace it with a future release
./configure --enable-shared --disable-static --with-apxs --with-ssl --with-apr=/usr/bin/apr-1-config --with-apr-util=/usr/bin/apu-1-config --prefix=/usr/local/subversion# Before starting to build SVN, you need to edit serf/Makefile, and remove every single occurence of "-static", or the build would fail
vim serf/Makefile :%s/-static//g :wq# Start the build. # Nearly everyone owns a multi-core CPU Mac nowadays, so let speed up the build, spawning several processes at once
make -j2# Optional: if you need the Python modules, let's build them
make -j2 swig-py# Leopard comes with a built-in release of Subversion (1.4.x) # Let's backup the Apache modules first
pushd /usr/libexec/apache2/ sudo mv mod_authz_svn.so mod_authz_svn.so.orig sudo mv mod_dav_svn.so mod_dav_svn.so.orig popd# Install the fresh built version of Subversion to /usr/local/
subversion sudo make install# Optional: install Python Subversion wrapper
sudo make install-swig-py# Optional: replace the default Python wrapper with the new ones pushd /System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python
sudo mv svn svn.orig sudo mv libsvn libsvn.orig sudo ln -s /usr/local/subversion/lib/svn-python/svn sudo ln -s /usr/local/subversion/lib/svn-python/libsvn popd# Optional but recommended: # SVN 1.5 working copies cannot be used with a prior release of SVN, such as the one that comes with Leopard. If you access a 1.4 WC with a 1.5 client, the WC is automatically updated to the 1.5 format, which prevent any further access from the default 1.4 tools. To avoid compatibility issue, I recommend you only use *one* major release of SVN tools on your machine # Replace the pristine release of SVN with the new one
pushd /usr/bin for f in svn*; do sudo mv $f $f.orig; sudo ln -s /usr/local/subversion/bin/$f; done popd# Once you double check SVN 1.5.x is up and running, you can get rid of your source+build directory
cd .. rm -rf subversion-*Enjoy !
$> svn --version svn, version 1.5.4 (r33841) compiled Oct 24 2008, 23:31:22