From 32fb4fe097115b23914832d26dba4d1de62f5f17 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 27 Jun 2017 11:57:47 +0200 Subject: fixdep: read the dependency files in binary mode We want to make sure that the original line endings are preserved, as fixdep hardcodes the assumption of Unix-type line endings. The symptom is this (kinda hard to understand) error when building in Git for Windows' SDK (which is a special-purpose version of MSYS2): $ make mingw64_defconfig && make -j15 HOSTCC scripts/basic/fixdep C:/git-sdk-64/mingw64/x86_64-w64-mingw32/include/ctype.h 64-w64-mingw32/include/ctype.h: Invalid argument fixdep: make[1]: *** [scripts/Makefile.host:104: scripts/basic/fixdep] Error 2 make: *** [Makefile:358: scripts_basic] Error 2 Signed-off-by: Johannes Schindelin --- scripts/basic/fixdep.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index f012551af..7bb808b9e 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -126,6 +126,10 @@ #define INT_FIG_ ntohl(0x4649475f) */ +#ifndef O_BINARY +#define O_BINARY 0 +#endif + #ifdef __MINGW32__ #define UNUSED __attribute__ ((__unused__)) @@ -337,7 +341,7 @@ void do_config_file(char *filename) int fd; void *map; - fd = open(filename, O_RDONLY); + fd = open(filename, O_RDONLY | O_BINARY); if (fd < 0) { fprintf(stderr, "fixdep: "); perror(filename); @@ -408,7 +412,7 @@ void print_deps(void) int fd; void *map; - fd = open(depfile, O_RDONLY); + fd = open(depfile, O_RDONLY | O_BINARY); if (fd < 0) { fprintf(stderr, "fixdep: "); perror(depfile); -- cgit v1.2.3-55-g6feb