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

David Marston david at illudium.org.uk
Wed Mar 6 12:27:16 PST 2002


David Marston wrote:


> 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 managed to completely miss the fact that it creates 2 temporary files,
not just one.  Try this one instead.

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 20:18:18
*************** 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,199 ****
    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");
    /* Create another unique file.  */
!   choose_temp_base ();
    ld_viafile = temp_filename;
!   temp = fopen (ld_viafile, "w");
!   if (temp == NULL)
      {
        fprintf (stderr, "ld: failed to create temporary filename '%s'\n", ld_viafile);
        exit (1);
      }
!   fclose (temp);
  
    if (tlink_verbose >= 7)
      printf ("temporary files have been created\n");
--- 173,198 ----
    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");
    /* Create another unique file.  */
!   temp_filedesc = choose_temp_base ();
    ld_viafile = temp_filename;
!   if (temp_filedesc == -1)
      {
        fprintf (stderr, "ld: failed to create temporary filename '%s'\n", ld_viafile);
        exit (1);
      }
!   close(temp_filedesc);
  
    if (tlink_verbose >= 7)
      printf ("temporary files have been created\n");
*************** do_tlink (char *linker, char **ld_argv, 
*** 1325,1331 ****
      }
  }
  
! static void
  choose_temp_base (void)
  {
    char *base = getenv ("TMPDIR");
--- 1324,1330 ----
      }
  }
  
! 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
--- 1352,1358 ----
      temp_filename[len++] = '/';
    strcpy (temp_filename + len, "ccXXXXXX");
  
!   return mkstemp (temp_filename);
  }
  
  static void





More information about the gcc mailing list