Subject: bin/4224: gcc uses /var/tmp rather than /tmp
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ronald@demon.net>
List: netbsd-bugs
Date: 10/06/1997 05:46:34
>Number:         4224
>Category:       bin
>Synopsis:       gcc uses /var/tmp rather than /tmp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Oct  5 21:50:02 1997
>Last-Modified:
>Originator:     Ronald Khoo
>Organization:
Demon Internet
>Release:        19971001
>Environment:
Irrelevant, really.  cc on any current netbsd will have this problem.
System: NetBSD ronald.eng.demon.net 1.2G NetBSD 1.2G (GENERIC) #9: Wed Oct 1 15:58:44 PDT 1997 thorpej@icky:/local/netbsd-src/sys/arch/i386/compile/GENERIC i386


>Description:
According to hier(7):

/tmp		temporary files, usually a mfs(8) memory-based
		filesystem (the contents of /tmp are usually NOT
		preserved across a system re-boot)

/var/tmp	temporary files that are kept between system reboots

This implies that our gcc should put temp files in /tmp
rather than /var/tmp by default.  Otherwise, those who believe
that hier(7) is respected, and MFS /tmp helps are surprised :-)

>How-To-Repeat:
echo 'main(){}' > t.c
cc -v t.c
notice that the temp files used are all in /var/tmp

Looking harder at it:
gcc.c uses P_tmpdir from stdio.h which has a DO NOT USE scribbled
over the top of it:
--- quote from from stdio.h
/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */
#ifndef _ANSI_SOURCE 
#define P_tmpdir        "/var/tmp/"
#endif
--- end quote from from stdio.h

gcc looks for P_tmpdir (if defined), /usr/tmp and /tmp respectively.
The first two should probably not be searched for on NetBSD systems.
>Fix:
One *could* simply hack out the searching of P_tmpdir and /usr/tmp
in gcc.c as per the patch below.  Ugh.

I can't think of an elegant solution, sorry.

Index: /usr/src/gnu/usr.bin/gcc/cc/gcc.c
***************
*** 1573,1578 ****
--- 1573,1579 ----
    base = choose_temp_base_try (getenv ("TMP"), base);
    base = choose_temp_base_try (getenv ("TEMP"), base);
  
+ #ifndef __NetBSD__
  #ifdef P_tmpdir
    base = choose_temp_base_try (P_tmpdir, base);
  #endif
***************
*** 1580,1585 ****
--- 1581,1587 ----
    base = choose_temp_base_try (concat4 (dir_separator_str, "usr", 
                                          dir_separator_str, "tmp"), 
                                  base);
+ #endif
    base = choose_temp_base_try (concat (dir_separator_str, "tmp"), base);
   
    /* If all else fails, use the current directory! */  
>Audit-Trail:
>Unformatted: