From: <dan...@ya...> - 2002-11-16 06:45:08
|
The problem is indeed in st_ino. Its always 0 in windows implementation of stat (unless the file doesn't exist). Using MSVCRT implemntation of _fullpath to get the absolute pathname seems to be enough to ensure uniqueness on mingw32 This patch to gcc.c solves --save-temps problem for me, but needs to be made a bit more palatable. Danny Index: gcc.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/gcc.c,v retrieving revision 1.344 diff -c -3 -p -r1.344 gcc.c *** gcc.c 14 Oct 2002 07:15:38 -0000 1.344 --- gcc.c 16 Nov 2002 06:38:33 -0000 *************** do_spec_1 (spec, inswitch, soft_matched_ *** 4668,4673 **** --- 4668,4677 ---- { struct stat st_temp; + #ifdef __MINGW32__ + char temp_fullpath[MAX_PATH]; + char input_fullpath[MAX_PATH]; + #endif /* Note, set_input() resets input_stat_set to 0. */ if (input_stat_set == 0) { *************** do_spec_1 (spec, inswitch, soft_matched_ *** 4683,4690 **** --- 4687,4702 ---- if (input_stat_set != 1 || stat (temp_filename, &st_temp) < 0 + #ifndef __MINGW32__ || input_stat.st_dev != st_temp.st_dev || input_stat.st_ino != st_temp.st_ino) + #else + || (strcmp (_fullpath (input_fullpath, + input_filename, MAX_PATH), + _fullpath (temp_fullpath, + temp_filename, MAX_PATH)) + != 0 )) + #endif { temp_filename = save_string (temp_filename, temp_filename_length + 1); > "Rekha Deshmukh" <Re...@kp...> wrote: > > > Hi Earnie, > > > > Thanks for the reply. > > From your mail I understood that the patch should be modified, > > where the st_ino of two files are compared and apply some other > > logic so as to know the file's unique existance. > > I searched through the gcc source but was unable to find the > > code, where two files were compared for uniqueness. > > The GNU ld has this problem too, when handling '.so' files > on MinGW-host, the DT_NEEDED entries in the files don't work. > The code causing this seems to be in 'emultemps/elf32.em' and > is: > > -------------------- clip --------------------------- > /* See if an input file matches a DT_NEEDED entry by running stat on > the file. */ > > static void > gld${EMULATION_NAME}_stat_needed (s) > lang_input_statement_type *s; > { > struct stat st; > const char *suffix; > const char *soname; > > if (global_found) > return; > if (s->the_bfd == NULL) > return; > > if (bfd_stat (s->the_bfd, &st) != 0) > { > einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd); > return; > } > > if (st.st_dev == global_stat.st_dev <----- !! > && st.st_ino == global_stat.st_ino) <----- !! > { > global_found = true; > return; > } > -------------------- clip --------------------------- > > If only the plain vanilla file name, without the absolute > path, is the input here, how the 'uniqueness' will be > solved ? Or is it necessary -- in this case it would be > enough if a file with the right name could be found. So > wrapping the '&& st.st_ino == global_stat.st_ino)' between > '#ifndef __MINGW32__' and '#endif' could fix this case. > Assuming that the 'st.st_dev' has the right disk number... > > Haven't tried this yet though... > > Cheers, Kai > > http://careers.yahoo.com.au - Yahoo! Careers - 1,000's of jobs waiting online for you! |