@@ -68,9 +68,17 @@ string patchLines(string inFile, string outFile, LineTransformer lineTransformer
68
68
// Preprocesses a 'foo.def.in' file to 'foo.def'.
69
69
void generateDef (string inFile, string outFile)
70
70
{
71
- const includeDir = buildPath(dirName(dirName(inFile)), " def-include" );
71
+ const patchedInFile = outFile ~ " .in" ;
72
+ const realInFile = patchLines(inFile, patchedInFile, (line)
73
+ {
74
+ // The MinGW-w64 .def.in files use 'F_X86_ANY(DATA)' to hide functions
75
+ // overridden by the MinGW runtime, primarily math functions.
76
+ return line.replace(" F_X86_ANY(DATA)" , " " );
77
+ });
78
+
79
+ const includeDir = buildPath(inFile.dirName.dirName, " def-include" );
72
80
const archDefine = x64 ? " DEF_X64" : " DEF_I386" ;
73
- runShell(` cl /EP /D` ~ archDefine ~ ` =1 "/I` ~ includeDir ~ ` " "` ~ inFile ~ ` " > "` ~ outFile ~ ` "` );
81
+ runShell(` cl /EP /D` ~ archDefine ~ ` =1 "/I` ~ includeDir ~ ` " "` ~ realInFile ~ ` " > "` ~ outFile ~ ` "` );
74
82
}
75
83
76
84
void sanitizeDef (string defFile)
@@ -97,6 +105,15 @@ void sanitizeDef(string defFile)
97
105
}
98
106
}
99
107
108
+ // The MinGW runtime apparently replaces ceil(f)/floor(f) and hides the original functions via DATA.
109
+ if (line == " ceil DATA" || line == " ceilf DATA" ||
110
+ line == " floor DATA" || line == " floorf DATA" )
111
+ return line[0 .. $- 5 ];
112
+
113
+ // MinGW apparently also replaces ucrtbase.dll's '_tzset'.
114
+ if (line == " _tzset DATA" )
115
+ return " _tzset" ;
116
+
100
117
// Don't export function 'atexit'; we have our own in msvc_atexit.c.
101
118
if (line == " atexit" )
102
119
return " " ;
@@ -259,6 +276,6 @@ void main(string[] args)
259
276
buildUuid(outDir);
260
277
261
278
// version (verbose) {} else
262
- foreach (f; std.file.dirEntries (outDir, " *.def" , SpanMode.shallow))
279
+ foreach (f; std.file.dirEntries (outDir, " *.def* " , SpanMode.shallow))
263
280
std.file.remove (f.name);
264
281
}
0 commit comments