This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[VXWORKS PPC 2.95.3] vxworks-exeproblem.patch



  Because it runs under Cygwin, the powerpc compiler adds a '.exe'
extension to linked output files it generates for which no extension is
specified in the command line.  Really, the output file should be build
with an extension suitable for the target, not the host.

  This patch is quite a crude kludge but it does the job for our purposes.

  The correct way to deal with this issue would be configure-time stuff
that differentiates between host and target executable file extensions,
but there you go. This works OK.

           DaveK

diff -c3prN /gcc.orig/gcc/gcc/config/rs6000/vxppc.h
/gcc.dev/gcc/gcc/config/rs6000/vxppc.h
*** /gcc.orig/gcc/gcc/config/rs6000/vxppc.h Mon May 17 02:30:56 1999
--- /gcc.dev/gcc/gcc/config/rs6000/vxppc.h Mon Jan 29 23:41:20 2001
*************** Boston, MA 02111-1307, USA.  */
*** 71,73 ****
--- 71,79 ----
  /* We use stabs-in-elf for debugging */
  #undef PREFERRED_DEBUGGING_TYPE
  #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+
+ /*  Stop g++ outputting .exe files */
+
+ #define TARGET_EXECUTABLE_SUFFIX ""
+ #define TARGET_OBJECT_SUFFIX ".o"
+
diff -c3prN /gcc.orig/gcc/gcc/gcc.c /gcc.dev/gcc/gcc/gcc.c
*** /gcc.orig/gcc/gcc/gcc.c Wed Dec 20 04:57:51 2000
--- /gcc.dev/gcc/gcc/gcc.c Fri Jan 26 00:30:17 2001
***************
*** 1,5 ****
  /* Compiler driver program that can handle many languages.
!    Copyright (C) 1987, 89, 92-98, 1999 Free Software Foundation, Inc.

  This file is part of GNU CC.

--- 1,6 ----
  /* Compiler driver program that can handle many languages.
!    Copyright (C) 1987, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
!    2000 Free Software Foundation, Inc.

  This file is part of GNU CC.

*************** compilation is specified by a string cal
*** 57,62 ****
--- 58,85 ----
  #define OBJECT_SUFFIX ".o"
  #endif

+ /*  If we have *no* target suffixes, we use the old dubious mechanism of
+   using the host suffixes.  For a native compiler, it isn't even dubious.
+   But for a cross compiler if either target suffix is defined, we use
+   them instead           */
+ #if defined (CROSS_COMPILE) && (defined(TARGET_EXECUTABLE_SUFFIX) || defined(TARGET_OBJECT_SUFFIX))
+
+ #define USE_TARGET_SUFFIXES
+
+ #ifdef TARGET_EXECUTABLE_SUFFIX
+ #define HAVE_TARGET_EXECUTABLE_SUFFIX
+ #else
+ #define TARGET_EXECUTABLE_SUFFIX EXECUTABLE_SUFFIX
+ #endif
+
+ #ifdef TARGET_OBJECT_SUFFIX
+ #define HAVE_TARGET_OBJECT_SUFFIX
+ #else
+ #define TARGET_OBJECT_SUFFIX OBJECT_SUFFIX
+ #endif
+
+ #endif
+
  /* By default, colon separates directories in a path.  */
  #ifndef PATH_SEPARATOR
  #define PATH_SEPARATOR ':'
*************** convert_filename (name, do_exe)
*** 2456,2461 ****
--- 2479,2537 ----
    return name;
  }
  #endif
+
+ #if defined(HAVE_TARGET_OBJECT_SUFFIX) ||
defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
+
+ /* Convert NAME to a new name if it is the standard suffix.  DO_EXE
+    is true if we should look for an executable suffix as well.  */
+
+ static char *
+ convert_target_filename (name, do_exe)
+      char *name;
+      int do_exe;
+ {
+   int i;
+   int len;
+
+   if (name == NULL)
+     return NULL;
+
+   len = strlen (name);
+
+ #ifdef HAVE_TARGET_OBJECT_SUFFIX
+   /* Convert x.o to x.obj if TARGET_OBJECT_SUFFIX is ".obj".  */
+   if (len > 2
+       && name[len - 2] == '.'
+       && name[len - 1] == 'o')
+     {
+       obstack_grow (&obstack, name, len - 2);
+       obstack_grow0 (&obstack, TARGET_OBJECT_SUFFIX, strlen (TARGET_OBJECT_SUFFIX));
+       name = obstack_finish (&obstack);
+     }
+ #endif
+ #ifdef HAVE_TARGET_EXECUTABLE_SUFFIX
+   /* If there is no filetype, make it the executable suffix (which includes
+      the ".").  But don't get confused if we have just "-o".  */
+   if (! do_exe || TARGET_EXECUTABLE_SUFFIX[0] == 0 || (len == 2 && name[0] == '-'))
+     return name;
+
+   for (i = len - 1; i >= 0; i--)
+     if (IS_DIR_SEPARATOR (name[i]))
+       break;
+
+   for (i++; i < len; i++)
+     if (name[i] == '.')
+       return name;
+
+   obstack_grow (&obstack, name, len);
+   obstack_grow0 (&obstack, TARGET_EXECUTABLE_SUFFIX, strlen (TARGET_EXECUTABLE_SUFFIX));
+   name = obstack_finish (&obstack);
+ #endif
+
+   return name;
+ }
+ #endif
+

  /* Display the command line switches accepted by gcc.  */
  static void
*************** process_command (argc, argv)
*** 3022,3033 ****
--- 3098,3122 ----
        }
    }
  #endif
+     /* DK: I think we should care about target suffixes, not
+            host suffixes, at this point. For minimal intrusiveness
+            we retain old dodgy behaviour but allow target specific
+            .h file to override it thusly: */
+ #ifdef USE_TARGET_SUFFIXES
+ #if defined(HAVE_TARGET_EXECUTABLE_SUFFIX) || defined(HAVE_TARGET_OBJECT_SUFFIX)
+        if (p[1] == 0)
+   argv[i+1] = convert_target_filename (argv[i+1], ! have_c);
+        else
+   argv[i] = convert_target_filename (argv[i], ! have_c);
+ #endif
+ #else /* !USE_TARGET_SUFFIXES */
  #if defined(HAVE_EXECUTABLE_SUFFIX) || defined(HAVE_OBJECT_SUFFIX)
         if (p[1] == 0)
    argv[i+1] = convert_filename (argv[i+1], ! have_c);
         else
    argv[i] = convert_filename (argv[i], ! have_c);
  #endif
+ #endif /* !USE_TARGET_SUFFIXES */
         goto normal_switch;

       default:




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]