Commit a9024779 by Danny Smith Committed by Danny Smith

re PR other/5620 (GCC -save-temps foo.c fails to build foo.o)

	PR 5620
	* gcc.c (struct stat input_stat): Don't define if
	HOST_LACKS_INODE_NUMBERS
	(do_spec_1): If HOST_LACKS_INODE_NUMBERS, use lrealpath rather
	than stat to determine if temp file is same as input file.
	* doc/hostconfig.texi: Document HOST_LACKS_INODE_NUMBERS.
	* config/i386/xm-mingw32.h: Define HOST_LACKS_INODE_NUMBERS

From-SVN: r86311
parent c0ca2795
2004-08-20 Danny Smith <dannysmith@users.sourceforge.net>
PR 5620
* gcc.c (struct stat input_stat): Don't define if
HOST_LACKS_INODE_NUMBERS
(do_spec_1): If HOST_LACKS_INODE_NUMBERS, use lrealpath rather
than stat to determine if temp file is same as input file.
* doc/hostconfig.texi: Document HOST_LACKS_INODE_NUMBERS.
* config/i386/xm-mingw32.h: Define HOST_LACKS_INODE_NUMBERS
2004-08-20 Richard Sandiford <rsandifo@redhat.com> 2004-08-20 Richard Sandiford <rsandifo@redhat.com>
* configure.ac (mips*-*-*): Print an error if not using GAS. * configure.ac (mips*-*-*): Print an error if not using GAS.
......
...@@ -27,3 +27,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -27,3 +27,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
/* This is the name of the null device on windows. */ /* This is the name of the null device on windows. */
#define HOST_BIT_BUCKET "nul" #define HOST_BIT_BUCKET "nul"
/* The st_ino field of struct stat is always 0. */
#define HOST_LACKS_INODE_NUMBERS
...@@ -163,6 +163,10 @@ If you do not define this macro, GCC will use the default version. You ...@@ -163,6 +163,10 @@ If you do not define this macro, GCC will use the default version. You
should define this macro if the default version does not reliably remove should define this macro if the default version does not reliably remove
the temp file as, for example, on VMS which allows multiple versions the temp file as, for example, on VMS which allows multiple versions
of a file. of a file.
@item HOST_LACKS_INODE_NUMBERS
Define this macro if the host filesystem does not report meaningful inode
numbers in struct stat.
@end ftable @end ftable
@node Host Misc @node Host Misc
......
...@@ -4195,7 +4195,9 @@ static int basename_length; ...@@ -4195,7 +4195,9 @@ static int basename_length;
static int suffixed_basename_length; static int suffixed_basename_length;
static const char *input_basename; static const char *input_basename;
static const char *input_suffix; static const char *input_suffix;
#ifndef HOST_LACKS_INODE_NUMBERS
static struct stat input_stat; static struct stat input_stat;
#endif
static int input_stat_set; static int input_stat_set;
/* The compiler used to process the current input file. */ /* The compiler used to process the current input file. */
...@@ -4759,6 +4761,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) ...@@ -4759,6 +4761,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
*((char *) temp_filename + temp_filename_length) = '\0'; *((char *) temp_filename + temp_filename_length) = '\0';
if (strcmp (temp_filename, input_filename) != 0) if (strcmp (temp_filename, input_filename) != 0)
{ {
#ifndef HOST_LACKS_INODE_NUMBERS
struct stat st_temp; struct stat st_temp;
/* Note, set_input() resets input_stat_set to 0. */ /* Note, set_input() resets input_stat_set to 0. */
...@@ -4773,11 +4776,19 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) ...@@ -4773,11 +4776,19 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
and we can do the stat for the temp_filename and we can do the stat for the temp_filename
then the they could still refer to the same then the they could still refer to the same
file if st_dev/st_ino's are the same. */ file if st_dev/st_ino's are the same. */
if (input_stat_set != 1 if (input_stat_set != 1
|| stat (temp_filename, &st_temp) < 0 || stat (temp_filename, &st_temp) < 0
|| input_stat.st_dev != st_temp.st_dev || input_stat.st_dev != st_temp.st_dev
|| input_stat.st_ino != st_temp.st_ino) || input_stat.st_ino != st_temp.st_ino)
#else
/* Just compare canonical pathnames. */
char* input_realname = lrealpath (input_filename);
char* temp_realname = lrealpath (temp_filename);
bool files_differ = strcmp (input_realname, temp_realname);
free (input_realname);
free (temp_realname);
if (files_differ)
#endif
{ {
temp_filename = save_string (temp_filename, temp_filename = save_string (temp_filename,
temp_filename_length + 1); temp_filename_length + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment