Autobuilt ld: failed to create temporary filename '/tmp/ccy4uvff'

David Marston david at illudium.org.uk
Wed Mar 6 10:08:22 PST 2002


Peter Naulls wrote:

> In message <4B1294F677%andy at sparse.net>
>           Andy Wingate <andy at sparse.net> wrote:
> 
>>This may well be known about but using an autobuilt version of gcc
>>(from the 1st March), I find that ld gives an error about failing to
>>create a temporary filename, which does appear to be created in
>><Wimp$Scrap> as you would expect (just of 0 size).
>>
> Oh dear.  I thought it was just something strange I'd done with my local
> copy (I still have a load of changes to be submitted), as no one else
> had reported this. I'll take a look ASAP.


I think you changed a mktemp to mkstemp in ld.c, so the file is already
open when ld tries to open it the first time.  I think the patch below
should fix this using mkstemp, or just change it back to mktemp.

I'm not actually sure this is the problem as I'm not near my RO machine
to try it, but it looks right to me.

D

Index: riscos-aof/ld/ld.c
===================================================================
RCS file: /usr/local/cvsroot/gccsdk/riscos-aof/ld/ld.c,v
retrieving revision 1.7.2.8
diff -c -p -r1.7.2.8 ld.c
*** riscos-aof/ld/ld.c	2002/03/01 16:48:22	1.7.2.8
--- riscos-aof/ld/ld.c	2002/03/06 17:53:49
*************** static void append_arg (args *, int *, c
*** 114,120 ****
  static void tlink_init (void);
  static int tlink_execute (char *prog, char **argv, char *redir, char *viafile);
  static void do_tlink (char *, char **, args *);
! static void choose_temp_base (void);
  static void dump_file (char *);
  static void ldversion (int);
  static void ldhelp (void);
--- 114,120 ----
  static void tlink_init (void);
  static int tlink_execute (char *prog, char **argv, char *redir, char *viafile);
  static void do_tlink (char *, char **, args *);
! static int choose_temp_base (void);
  static void dump_file (char *);
  static void ldversion (int);
  static void ldhelp (void);
*************** static void
*** 158,163 ****
--- 158,164 ----
  linker_initialise (void)
  {
    FILE *temp;
+   int temp_filedesc;
  
    c_file_name = getenv ("COLLECT_GCC");
    if (c_file_name == 0)
*************** linker_initialise (void)
*** 172,186 ****
    if (tlink_verbose >= 7)
      printf ("creating 1st temporary file\n");
  
!   choose_temp_base ();
    ldout = temp_filename;
!   temp = fopen (ldout, "w");
!   if (temp == NULL)
      {
        fprintf (stderr, "ld: failed to create temporary filename '%s'\n", ldout);
        exit (1);
      }
!   fclose (temp);
  
    if (tlink_verbose >= 7)
      printf ("creating 2nd temporary file\n");
--- 173,186 ----
    if (tlink_verbose >= 7)
      printf ("creating 1st temporary file\n");
  
!   temp_filedesc = choose_temp_base ();
    ldout = temp_filename;
!   if (temp_filedesc == -1)
      {
        fprintf (stderr, "ld: failed to create temporary filename '%s'\n", ldout);
        exit (1);
      }
!   close (temp_filedesc);
  
    if (tlink_verbose >= 7)
      printf ("creating 2nd temporary file\n");
*************** do_tlink (char *linker, char **ld_argv, 
*** 1325,1331 ****
      }
  }
  
! static void
  choose_temp_base (void)
  {
    char *base = getenv ("TMPDIR");
--- 1325,1331 ----
      }
  }
  
! static int
  choose_temp_base (void)
  {
    char *base = getenv ("TMPDIR");
*************** choose_temp_base (void)
*** 1353,1359 ****
      temp_filename[len++] = '/';
    strcpy (temp_filename + len, "ccXXXXXX");
  
!   mkstemp (temp_filename);
  }
  
  static void
--- 1353,1359 ----
      temp_filename[len++] = '/';
    strcpy (temp_filename + len, "ccXXXXXX");
  
!   return mkstemp (temp_filename);
  }
  
  static void





More information about the gcc mailing list