Second set of patches included.

My option would be to get this in SVN, then continue work on the getenv
replacement and command line option.

        Danny
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
Index: mingw/ChangeLog.mingw32ce
===================================================================
--- mingw/ChangeLog.mingw32ce	(revision 847)
+++ mingw/ChangeLog.mingw32ce	(working copy)
@@ -1,3 +1,9 @@
+2006-12-29  Danny Backx  <[EMAIL PROTECTED]>
+
+	* profile/gmon.c : Rewrite to avoid stdio, use native WinCE I/O
+	instead. Stdio doesn't work reliably in these conditions (maybe due to
+	the use of an atexit handler).
+
 2006-12-19  Pedro Alves  <[EMAIL PROTECTED]>
 
 	* dllmain.c: Call DisableThreadLibraryCalls on DLL_PROCESS_ATTACH.
Index: mingw/configure.in
===================================================================
--- mingw/configure.in	(revision 847)
+++ mingw/configure.in	(working copy)
@@ -54,7 +54,7 @@
 
 W32API_INCLUDE='-I $(srcdir)/../w32api/include'
 
-AC_CONFIG_SUBDIRS(profile mingwex)
+AC_CONFIG_SUBDIRS(mingwex)
 
 case "$target_os" in
 *cygwin*)
Index: cegcc/cegccdll/Makefile
===================================================================
--- cegcc/cegccdll/Makefile	(revision 847)
+++ cegcc/cegccdll/Makefile	(working copy)
@@ -96,6 +96,7 @@
 	rm -f ${MY_DIR}/$(IMPLIB)
 	rm -f ${MY_DIR}/$(IMPLIB).tmp
 	$(AR) q ${MY_DIR}/$(IMPLIB) ${MY_DIR}/_tmp_static/*.o
+	rm -f ${MY_DIR}/_tmp/_eprintf.o
 	$(CC) -o $@ $(LDFLAGS) -shared -nostdlib \
 	-Wl,--whole-archive ${MY_DIR}/_tmp/*.o ${LIB_PATH}/dllcrt1.o \
 	-Wl,--no-whole-archive -lcegcc -lcoredll -liphlpapi \
Index: build-mingw32ce.sh
===================================================================
--- build-mingw32ce.sh	(revision 847)
+++ build-mingw32ce.sh	(working copy)
@@ -180,6 +180,7 @@
 	--disable-interwork            \
 	--without-newlib               \
 	--enable-checking              \
+	--with-headers                 \
 	|| exit
 
 # we build libstdc++ as dll, so we don't need this.    
@@ -271,6 +272,30 @@
     tar cf - images | (cd ${PREFIX}/share; tar xf -) || exit 1
 }
 
+function build_profile()
+{
+    echo ""
+    echo "BUILDING profiling libraries --------------------------"
+    echo ""
+    echo ""
+
+    mkdir -p ${BUILD_DIR}/profile || exit 1
+    cd ${BUILD_DIR}/profile || exit 1
+
+    PREV_CFLAGS=${CFLAGS}
+    export CFLAGS="-DNO_UNDERSCORES" 
+
+    ${BASE_DIRECTORY}/profile/configure  \
+	--host=${TARGET}             \
+	--prefix=${PREFIX}             \
+	|| exit
+
+    export CFLAGS=${PREV_CFLAGS}
+
+    make         || exit 1
+    make install || exit 1
+}
+
 function build_all
 {
     build_binutils
@@ -280,9 +305,10 @@
     build_bootstrap_gcc
     build_mingw_runtime
     build_gcc
+    build_docs
+    build_profile
     build_gdb
     build_gdbstub
-    build_docs
 }
 
 case $BUILD_OPT in
@@ -301,6 +327,7 @@
  gdb) build_gdb ;;
  gdbstub) build_gdbstub ;;
  docs) build_docs ;;
+ profile) build_profile ;;
  all) build_all ;;
  *) echo "Please enter a valid build option." ;;
 esac
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 847)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2006-12-24  Danny Backx <[EMAIL PROTECTED]>
+
+	* build-mingw32ce.sh, build-cegcc.sh (build_profile) : Add.
+	* build-mingw32ce.sh, build-cegcc.sh (build_gcc) : Add --with-headers
+	option so -Dinhibit_libc isn't triggered.
+
 2006-12-19  Pedro Alves  <[EMAIL PROTECTED]>
 
 	* build-mingw32ce.sh (build-w32api): New function.
Index: build-cegcc.sh
===================================================================
--- build-cegcc.sh	(revision 847)
+++ build-cegcc.sh	(working copy)
@@ -165,6 +165,7 @@
 	--disable-interwork            \
 	--without-newlib               \
 	--enable-checking              \
+	--with-headers                 \
 	|| exit 1
 
 
@@ -277,6 +278,30 @@
     cd ${BASE_DIRECTORY} || exit 1
 }
 
+function build_profile()
+{
+    echo ""
+    echo "BUILDING profiling libraries --------------------------"
+    echo ""
+    echo ""
+
+    mkdir -p ${BUILD_DIR}/profile || exit 1
+    cd ${BUILD_DIR}/profile || exit 1
+
+    PREV_CFLAGS=${CFLAGS}
+    export CFLAGS="-DNO_UNDERSCORES"
+
+    ${BASE_DIRECTORY}/profile/configure  \
+	--host=${TARGET}             \
+	--prefix=${PREFIX}             \
+	|| exit
+
+    export CFLAGS=${PREV_CFLAGS}
+
+    make         || exit 1
+    make install || exit 1
+}
+
 function build_docs()
 {
     echo ""
@@ -293,7 +318,7 @@
     tar cf - images | (cd ${PREFIX}/share; tar xf -) || exit 1
 }
 
-function buildall()
+function build_all()
 {
     build_binutils
     build_import_libs
@@ -305,9 +330,10 @@
     build_cegccdll
     build_cegccthrddll
     build_libstdcppdll
+    build_profile
+    build_docs
     build_gdb
     build_gdbstub
-    build_docs
 }
 
 case $BUILD_OPT in
@@ -328,7 +354,8 @@
  gdb) build_gdb ;;
  gdbstub) build_gdbstub ;;
  docs) build_docs ;;
- all) buildall ;;
+ profile) build_profile ;;
+ all) build_all ;;
  *) echo "Please enter a valid build option." ;;
 esac
 
Index: gcc/gcc/doc/gcov.texi
===================================================================
--- gcc/gcc/doc/gcov.texi	(revision 847)
+++ gcc/gcc/doc/gcov.texi	(working copy)
@@ -544,7 +544,8 @@
 to create the needed directory structure, if it is not already present.
 
 To support cross-profiling, a program compiled with @option{-fprofile-arcs}
-can relocate the data files based on two environment variables: 
+can relocate the data files based on two environment variables on the target
+platform, or one on the host platform: 
 
 @itemize @bullet
 @item
@@ -558,6 +559,11 @@
 
 @emph{Note:} GCOV_PREFIX_STRIP has no effect if GCOV_PREFIX is undefined, empty
 or non-absolute.
+
[EMAIL PROTECTED]
+GCOV_CROSS_PREFIX is a host platform environment variable. Use it to specify
+a target directory to prefix the compiled file name with, replacing the
+compile directory.
 @end itemize
 
 For example, if the object file @file{/user/build/foo.o} was built with
@@ -568,6 +574,13 @@
 @samp{GCOV_PREFIX=/target/run} and @samp{GCOV_PREFIX_STRIP=1}.  Such a
 setting will name the data file @file{/target/run/build/foo.gcda}.
 
+Alternatively, you can set @samp{GCOV_CROSS_PREFIX=/target/run/build} when
+compiling, to achieve the same effect. The object file will no longer contain
+the information @file{/user/build/foo.o} but @file{/target/run/build/foo.o}.
+
+The host and target mechanisms are independent of each other, so they can be
+used together.
+
 You must move the data files to the expected directory tree in order to
 use them for profile directed optimizations (@option{--use-profile}), or to
 use the @command{gcov} tool.
Index: gcc/gcc/ChangeLog.ce
===================================================================
--- gcc/gcc/ChangeLog.ce	(revision 847)
+++ gcc/gcc/ChangeLog.ce	(working copy)
@@ -1,3 +1,21 @@
+2006-12-21  Danny Backx  <[EMAIL PROTECTED]>
+
+	* config/arm/t-strongarm-pe config/arm/t-strongarm-elf config/arm/t-pe
+	config/arm/t-arm-elf config/arm/t-xscale-elf config/arm/t-xscale-coff
+	config/arm/t-arm-coff config/arm/t-wince-pe : Remove inhibit_libc .
+
+	* coverage.c (build_gcov_info) : Add more support for dealing with
+	directory names in cross-debugging environment. Main difference
+	is that this is specified on the host, not the target platform.
+
+	* doc/gcov.texi : Add documentation for GCOV_CROSS_PREFIX.
+
+	* tsystem.h : Don't include <errno.h> when __MINGW32CE__ is defined.
+
+	* gcov-io.c (gcov_open) : Call setvbuf instead of setbuf in mingw32ce.
+
+	* libgcov.c (gcov_exit) : Don't call getenv and setenv in mingw32ce.
+
 2006-12-03  Pedro Alves  <[EMAIL PROTECTED]>
 
 	* config/arm/arm.c (arm_major_arch, arm_thumb_arch_p): New
Index: gcc/gcc/gcov-io.c
===================================================================
--- gcc/gcc/gcov-io.c	(revision 847)
+++ gcc/gcc/gcov-io.c	(working copy)
@@ -134,7 +134,11 @@
     return 0;
 #endif
 
+#ifdef	__MINGW32CE__
+  setvbuf (gcov_var.file, (char *)0, _IONBF, (size_t)0);
+#else
   setbuf (gcov_var.file, (char *)0);
+#endif
   
   return 1;
 }
Index: gcc/gcc/coverage.c
===================================================================
--- gcc/gcc/coverage.c	(revision 847)
+++ gcc/gcc/coverage.c	(working copy)
@@ -776,6 +776,7 @@
   unsigned n_fns;
   const struct function_list *fn;
   tree string_type;
+  char *gcov_cross_prefix;
 
   /* Count the number of active counters.  */
   for (n_ctr_types = 0, ix = 0; ix != GCOV_COUNTERS; ix++)
@@ -811,12 +812,26 @@
   field = build_decl (FIELD_DECL, NULL_TREE, string_type);
   TREE_CHAIN (field) = fields;
   fields = field;
-  filename = getpwd ();
-  filename = (filename && da_file_name[0] != '/'
+
+  /*
+   * Additional environment variable for cross-development.
+   */
+  if (gcov_cross_prefix = getenv ("GCOV_CROSS_PREFIX"))
+    {
+      filename = concat (gcov_cross_prefix, "/", da_file_name, NULL);
+      filename_len = strlen (filename);
+      filename_string = build_string (filename_len + 1, filename);
+    }
+  else
+    {
+      filename = getpwd ();
+      filename = (filename && da_file_name[0] != '/'
 	      ? concat (filename, "/", da_file_name, NULL)
 	      : da_file_name);
-  filename_len = strlen (filename);
-  filename_string = build_string (filename_len + 1, filename);
+      filename_len = strlen (filename);
+      filename_string = build_string (filename_len + 1, filename);
+    }
+
   if (filename != da_file_name)
     free (filename);
   TREE_TYPE (filename_string) = build_array_type
Index: gcc/gcc/libgcov.c
===================================================================
--- gcc/gcc/libgcov.c	(revision 847)
+++ gcc/gcc/libgcov.c	(working copy)
@@ -194,6 +194,12 @@
 	}
     }
 
+#ifdef	__MINGW32CE__
+  /* No getenv support, so disable this. */
+  gcov_prefix = (char *)0;
+  gcov_prefix_strip = 0;
+  prefix_length = 0;
+#else
   /* Get file name relocation prefix.  Non-absolute values are ignored. */
   gcov_prefix = getenv("GCOV_PREFIX");
   if (gcov_prefix && IS_ABSOLUTE_PATH (gcov_prefix))
@@ -216,6 +222,7 @@
     }
   else
     prefix_length = 0;
+#endif
   
   /* Allocate and initialize the filename scratch space.  */
   gi_filename = alloca (prefix_length + gcov_max_filename + 1);
@@ -310,6 +317,15 @@
 	      continue;
 	    }
 #endif
+#ifdef	UNDER_CE
+	  {
+            wchar_t	x[256];
+	    int		l = strlen(gi_filename);
+	    l = (l < 256) ? l : 255;
+	    wcstombs(x, gi_filename, l);
+	    MessageBoxW(0, L"gcov_open", x, 0);
+	  }
+#endif
 	  if (!gcov_open (gi_filename))
 	    {
               fprintf (stderr, "profiling:%s:Cannot open\n", gi_filename);
Index: gcc/gcc/config/arm/t-strongarm-pe
===================================================================
--- gcc/gcc/config/arm/t-strongarm-pe	(revision 847)
+++ gcc/gcc/config/arm/t-strongarm-pe	(working copy)
@@ -35,4 +35,4 @@
 # Currently there is a bug somewhere in GCC's alias analysis
 # or scheduling code that is breaking _fpmul_parts in fp-bit.c.
 # Disabling function inlining is a workaround for this problem.
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
+TARGET_LIBGCC2_CFLAGS = -fno-inline
Index: gcc/gcc/config/arm/t-strongarm-elf
===================================================================
--- gcc/gcc/config/arm/t-strongarm-elf	(revision 847)
+++ gcc/gcc/config/arm/t-strongarm-elf	(working copy)
@@ -32,7 +32,7 @@
 # Currently there is a bug somewhere in GCC's alias analysis
 # or scheduling code that is breaking _fpmul_parts in fp-bit.c.
 # Disabling function inlining is a workaround for this problem.
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
+TARGET_LIBGCC2_CFLAGS = -fno-inline
 
 # Assemble startup files.
 $(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
Index: gcc/gcc/config/arm/t-pe
===================================================================
--- gcc/gcc/config/arm/t-pe	(revision 847)
+++ gcc/gcc/config/arm/t-pe	(working copy)
@@ -47,4 +47,3 @@
 
 LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc
Index: gcc/gcc/config/arm/t-xscale-elf
===================================================================
--- gcc/gcc/config/arm/t-xscale-elf	(revision 847)
+++ gcc/gcc/config/arm/t-xscale-elf	(working copy)
@@ -54,7 +54,7 @@
 # Currently there is a bug somewhere in GCC's alias analysis
 # or scheduling code that is breaking _fpmul_parts in fp-bit.c.
 # Disabling function inlining is a workaround for this problem.
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
+TARGET_LIBGCC2_CFLAGS = -fno-inline
 
 # Assemble startup files.
 $(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
Index: gcc/gcc/config/arm/t-arm-elf
===================================================================
--- gcc/gcc/config/arm/t-arm-elf	(revision 847)
+++ gcc/gcc/config/arm/t-arm-elf	(working copy)
@@ -67,7 +67,7 @@
 # Currently there is a bug somewhere in GCC's alias analysis
 # or scheduling code that is breaking _fpmul_parts in fp-bit.c.
 # Disabling function inlining is a workaround for this problem.
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
+TARGET_LIBGCC2_CFLAGS = -fno-inline
 
 # Assemble startup files.
 $(T)crti.o: $(srcdir)/config/arm/crti.asm $(GCC_PASSES)
Index: gcc/gcc/config/arm/t-xscale-coff
===================================================================
--- gcc/gcc/config/arm/t-xscale-coff	(revision 847)
+++ gcc/gcc/config/arm/t-xscale-coff	(working copy)
@@ -42,4 +42,4 @@
 # Currently there is a bug somewhere in GCC's alias analysis
 # or scheduling code that is breaking _fpmul_parts in fp-bit.c.
 # Disabling function inlining is a workaround for this problem.
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
+TARGET_LIBGCC2_CFLAGS = -fno-inline
Index: gcc/gcc/config/arm/t-arm-coff
===================================================================
--- gcc/gcc/config/arm/t-arm-coff	(revision 847)
+++ gcc/gcc/config/arm/t-arm-coff	(working copy)
@@ -31,4 +31,4 @@
 # Currently there is a bug somewhere in GCC's alias analysis
 # or scheduling code that is breaking _fpmul_parts in fp-bit.c.
 # Disabling function inlining is a workaround for this problem.
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc -fno-inline
+TARGET_LIBGCC2_CFLAGS = -fno-inline
Index: gcc/gcc/config/arm/t-wince-pe
===================================================================
--- gcc/gcc/config/arm/t-wince-pe	(revision 847)
+++ gcc/gcc/config/arm/t-wince-pe	(working copy)
@@ -55,4 +55,4 @@
 LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib
 
-TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc
+TARGET_LIBGCC2_CFLAGS =
Index: gcc/gcc/tsystem.h
===================================================================
--- gcc/gcc/tsystem.h	(revision 847)
+++ gcc/gcc/tsystem.h	(working copy)
@@ -92,12 +92,14 @@
 /* All systems have this header.  */
 #include <sys/types.h>
 
-/* All systems have this header.  */
+#ifndef	__MINGW32CE__
+/* All systems except Windows CE have this header.  */
 #include <errno.h>
 
 #ifndef errno
 extern int errno;
 #endif
+#endif
 
 /* GCC (fixproto) guarantees these system headers exist.  */
 #include <string.h>

Attachment: profile.tar.gz
Description: application/compressed-tar

Attachment: signature.asc
Description: This is a digitally signed message part

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Cegcc-devel mailing list
Cegcc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cegcc-devel

Reply via email to