rename.c fails to compile with mingw.org's MinGW: mingw32-gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.37/binutils -I. -I../../binutils-2.37/binutils -I../bfd -I../../binutils-2.37/binutils/../bfd -I../../binutils-2.37/binutils/../include -D__USE_MINGW_FSEEK -DLOCALEDIR="\"/mingw/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Wno-format -O2 -gdwarf-4 -g3 -MT rename.o -MD -MP -MF $depbase.Tpo -c -o rename.o ../../binutils-2.37/binutils/rename.c &&\ mv -f $depbase.Tpo $depbase.Po ../../binutils-2.37/binutils/rename.c:136:1: error: return type is an incomplete type 136 | get_stat_atime (struct stat const *st) | ^~~~~~~~~~~~~~ ../../binutils-2.37/binutils/rename.c: In function 'get_stat_atime': ../../binutils-2.37/binutils/rename.c:141:19: error: storage size of 't' isn't known 141 | struct timespec t; | ^ ../../binutils-2.37/binutils/rename.c:144:10: warning: 'return' with a value, in function returning void [-Wreturn-type] 144 | return t; | ^ ../../binutils-2.37/binutils/rename.c:136:1: note: declared here 136 | get_stat_atime (struct stat const *st) | ^~~~~~~~~~~~~~ ../../binutils-2.37/binutils/rename.c:141:19: warning: unused variable 't' [-Wunused-variable] 141 | struct timespec t; | ^ ../../binutils-2.37/binutils/rename.c: At top level: ../../binutils-2.37/binutils/rename.c:150:1: error: return type is an incomplete type 150 | get_stat_mtime (struct stat const *st) | ^~~~~~~~~~~~~~ ../../binutils-2.37/binutils/rename.c: In function 'get_stat_mtime': ../../binutils-2.37/binutils/rename.c:155:19: error: storage size of 't' isn't known 155 | struct timespec t; | ^ ../../binutils-2.37/binutils/rename.c:158:10: warning: 'return' with a value, in function returning void [-Wreturn-type] 158 | return t; | ^ ../../binutils-2.37/binutils/rename.c:150:1: note: declared here 150 | get_stat_mtime (struct stat const *st) | ^~~~~~~~~~~~~~ ../../binutils-2.37/binutils/rename.c:155:19: warning: unused variable 't' [-Wunused-variable] 155 | struct timespec t; | ^ Makefile:1101: recipe for target `rename.o' failed make[4]: *** [rename.o] Error 1 The problem is the use of 'timespec_t', which is not exposed by the MinGW headers except under certain conditions. However, the functions which use 'timespec_t' are not supposed to be compiled in the MinGW build, so it should suffice to condition those functions by the relevant preprocessor conditions: --- binutils/rename.c~0 2021-07-08 14:37:19.000000000 +0300 +++ binutils/rename.c 2021-07-31 14:27:49.111750000 +0300 @@ -102,6 +102,7 @@ simple_copy (int fromfd, const char *to, # define STAT_TIMESPEC_NS(st, st_xtim) ((st)->st_xtim.st__tim.tv_nsec) #endif +#if defined HAVE_UTIMENSAT || defined HAVE_UTIMES static inline long int get_stat_atime_ns (struct stat const *) ATTRIBUTE_UNUSED; static inline long int get_stat_mtime_ns (struct stat const *) ATTRIBUTE_UNUSED; @@ -160,6 +161,8 @@ get_stat_mtime (struct stat const *st) } /* End FIXME. */ +#endif /* HAVE_UTIMENSAT || HAVE_UTIMES */ + /* Set the times of the file DESTINATION to be the same as those in STATBUF. */
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=47fcfcbadce36c7ccc00c69b4c80717a0d6b9288 commit 47fcfcbadce36c7ccc00c69b4c80717a0d6b9288 Author: Alan Modra <amodra@gmail.com> Date: Wed Aug 4 14:44:08 2021 +0930 PR28156, rename.c doesn't compile with MinGW Guard against lack of struct timespec definition. PR 28156 * rename.c (get_stat_atime, get_stat_mtime): Don't compile unless HAVE_UTIMENSAT is defined.
Somewhat different patch committed to mainline. Please verify that it works for you on mingw, and then I'll commit it on the branch too.
(In reply to Alan Modra from comment #2) > Somewhat different patch committed to mainline. Please verify that it works > for you on mingw, and then I'll commit it on the branch too. Thanks, that patch works for me.
The binutils-2_37-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2e8e5a93a17ed97927d8ee968182994db1c915e0 commit 2e8e5a93a17ed97927d8ee968182994db1c915e0 Author: Alan Modra <amodra@gmail.com> Date: Wed Aug 4 14:44:08 2021 +0930 PR28156, rename.c doesn't compile with MinGW Guard against lack of struct timespec definition. PR 28156 * rename.c (get_stat_atime, get_stat_mtime): Don't compile unless HAVE_UTIMENSAT is defined. (cherry picked from commit 47fcfcbadce36c7ccc00c69b4c80717a0d6b9288)
Fixed