From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19787 invoked by alias); 12 Dec 2002 00:16:03 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 19742 invoked by uid 71); 12 Dec 2002 00:16:03 -0000 Date: Wed, 11 Dec 2002 16:16:00 -0000 Message-ID: <20021212001603.19741.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: =?iso-8859-1?q?Danny=20Smith?= Subject: Fwd: Re: other/5620: [3.1] GCC -save-temps foo.c fails to build foo.o Reply-To: =?iso-8859-1?q?Danny=20Smith?= X-SW-Source: 2002-12/txt/msg00680.txt.bz2 List-Id: The following reply was made to PR other/5620; it has been noted by GNATS. From: =?iso-8859-1?q?Danny=20Smith?= To: gnats Cc: dj@redhat.com, Christopher Faylor Subject: Fwd: Re: other/5620: [3.1] GCC -save-temps foo.c fails to build foo.o Date: Thu, 12 Dec 2002 11:14:10 +1100 (EST) Hello Re: http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=5620 On mingw32 PR is due to the implementation of stat() by the msvcrt C lib used by mingw32: Inodes are meaningless on windows and the value of stat.st_ino set by stat() is undefined. Using stat to determine if files were the same was causing strange results. The driver was telling cc1 to generate new file foo.s from foo.c (which cc1.did), but telling the assembler to use /.s as input. This patch replaces the use of stat for determining if files are the same with a simple comparison of full (canonical) pathnames on mingw32 host, and provides a mechanism for other hosts(?) with similar problem. I don't know if this (using EXTRA_GCC_OBJS and x-make fragment) is the best way to implement this, but is the only way I could think of without adding __MINGW32__ specific code to gcc.c ChangeLog 2002-12-11 Danny Smith PR other/5620 * config/i386/mingw32-1.c: New file. ((w32_file_id_cmp): Define. * config/i386/xm-mingw32.h (w32_file_id_cmp): Declare. (HOST_FILE_ID_CMP): Define as w32_file_id_cmp. Update copyright. * config/i386/x-mingw32: New file. Set EXTRA_GCC_OBJS to mingw32-1.o. Set rule for compiling mingw32-1.o. * config.gcc (i[34567]86-*-mingw32*): Set xmake-file to x-mingw32. Correct typo. * gcc.c (do_spec_1): Use (HOST_FILE_ID_CMP) rather than stat, if defined. Index: config/i386/xm-mingw32.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/i386/xm-mingw32.h,v retrieving revision 1.15 diff -c -3 -p -r1.15 xm-mingw32.h *** config/i386/xm-mingw32.h 10 Jan 2002 22:21:39 -0000 1.15 --- config/i386/xm-mingw32.h 11 Dec 2002 09:55:12 -0000 *************** *** 1,6 **** /* Configuration for GNU C-compiler for hosting on Windows32. using GNU tools and the Windows32 API Library. ! Copyright (C) 1997, 1998, 1999, 2001 Free Software Foundation, Inc. This file is part of GNU CC. --- 1,6 ---- /* Configuration for GNU C-compiler for hosting on Windows32. using GNU tools and the Windows32 API Library. ! Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. This file is part of GNU CC. *************** Boston, MA 02111-1307, USA. */ *** 31,33 **** --- 31,41 ---- #undef PATH_SEPARATOR #define PATH_SEPARATOR ';' + + /* This replaces the use of stat to determine if files are different + in gcc.c (do_spec_1) handling of --save-temps switch. */ + + extern int + w32_file_id_cmp PARAMS((const char *, const char *)); + + #define HOST_FILE_ID_CMP(SRC,DST) w32_file_id_cmp (SRC, DST) Index: gcc.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/gcc.c,v retrieving revision 1.349 diff -c -3 -p -r1.349 gcc.c *** gcc.c 26 Nov 2002 07:03:48 -0000 1.349 --- gcc.c 11 Dec 2002 09:55:27 -0000 *************** static int basename_length; *** 4019,4025 **** --- 4019,4027 ---- static int suffixed_basename_length; static const char *input_basename; static const char *input_suffix; + #ifndef HOST_FILE_ID_CMP static struct stat input_stat; + #endif static int input_stat_set; /* The compiler used to process the current input file. */ *************** do_spec_1 (spec, inswitch, soft_matched_ *** 4484,4490 **** *((char *) temp_filename + temp_filename_length) = '\0'; if (strcmp (temp_filename, input_filename) != 0) { ! struct stat st_temp; /* Note, set_input() resets input_stat_set to 0. */ if (input_stat_set == 0) --- 4486,4495 ---- *((char *) temp_filename + temp_filename_length) = '\0'; if (strcmp (temp_filename, input_filename) != 0) { ! #if defined HOST_FILE_ID_CMP ! if (HOST_FILE_ID_CMP(input_filename, temp_filename) != 0) ! #else ! struct stat st_temp; /* Note, set_input() resets input_stat_set to 0. */ if (input_stat_set == 0) *************** do_spec_1 (spec, inswitch, soft_matched_ *** 4503,4508 **** --- 4508,4514 ---- || stat (temp_filename, &st_temp) < 0 || input_stat.st_dev != st_temp.st_dev || input_stat.st_ino != st_temp.st_ino) + #endif { temp_filename = save_string (temp_filename, temp_filename_length + 1); Index: config.gcc =================================================================== RCS file: /cvs/gcc/gcc/gcc/config.gcc,v retrieving revision 1.266 diff -c -3 -p -r1.266 config.gcc *** config.gcc 9 Dec 2002 08:10:20 -0000 1.266 --- config.gcc 11 Dec 2002 09:55:30 -0000 *************** i[34567]86-*-mingw32*) *** 1298,1303 **** --- 1298,1304 ---- tm_file=i386/mingw32.h xm_defines=POSIX xm_file=i386/xm-mingw32.h + xmake_file=i386/x-mingw32 tmake_file="i386/t-cygwin i386/t-mingw32" extra_objs=winnt.o if test x$enable_threads = xyes; then *************** i[34567]86-*-mingw32*) *** 1308,1314 **** *mingw32crt*) tm_file="${tm_file} i386/crtdll.h" ;; ! *minwg32msv* | *mingw32*) ;; esac ;; --- 1309,1315 ---- *mingw32crt*) tm_file="${tm_file} i386/crtdll.h" ;; ! *mingw32msv* | *mingw32*) ;; esac ;; *** /dev/null Wed Dec 11 10:09:10 2002 --- config/i386/mingw32-1.c Wed Dec 11 09:15:07 2002 *************** *** 0 **** --- 1,42 ---- + /* This replaces the use of stat and struct stat.st_ino to determine if + files are different in gcc.c (do_spec_1) handling of --save-temps + switch. + Contributed by Danny Smith (dannysmith@users.sourceforge.net) + Copyright 2002 Free Software Foundation, Inc. + + This file is part of GNU CC. + + GNU CC is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + GNU CC is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU CC; see the file COPYING. If not, write to + the Free Software Foundation, 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + + #include + #include + + /* Return non-zero if src and dst filenames do not refer to same files. */ + + int + w32_file_id_cmp (src, dst) + const char * src; + const char * dst; + { + char fullpath_src[_MAX_PATH]; + char fullpath_dst[_MAX_PATH]; + + /* Just compare full pathnames. */ + _fullpath (fullpath_src, src, _MAX_PATH); + _fullpath (fullpath_dst, dst, _MAX_PATH); + return (_stricmp (fullpath_src, fullpath_dst)); + } *** /dev/null Wed Dec 11 10:12:22 2002 --- config/i386/x-mingw32 Wed Dec 11 09:52:31 2002 *************** *** 0 **** --- 1,7 ---- + # + # For HOST_FILE_ID_CMP for mingw32. + # + EXTRA_GCC_OBJS = mingw32-1.o + + mingw32-1.o: $(srcdir)/config/i386/mingw32-1.c + $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $? http://greetings.yahoo.com.au - Yahoo! Greetings - Send your seasons greetings online this year!