From a138c35b4c2d345df84e0e7f00ffb1161c7515b0 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 21 Oct 2018 17:45:56 +0200 Subject: [PATCH 01/20] Switch from MinGW to MinGW-w64 * Proper support for Win64 * Way more libs (900 for x64, 591 for x86) * No stdcall mangling in .def files * Partial (?) support for UCRT --- azure-pipelines.yml | 2 +- windows/build_mingw.bat | 25 +-- windows/build_mingw.sha256sums | 3 +- windows/mingw/buildsdk.d | 269 ++++++++++++++------------------- 4 files changed, 121 insertions(+), 178 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 92d9aef0..fb8501d6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -16,7 +16,7 @@ jobs: vmImage: 'vs2017-win2016' variables: VSINSTALLDIR: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\ - MINGW_VER: 5.0.2 + MINGW_VER: 6.0.0 D_VERSION: 2.077.1 steps: - template: .azure-pipelines/build-mingw-libs.yml diff --git a/windows/build_mingw.bat b/windows/build_mingw.bat index 8cd8d90c..2ac2e7fb 100644 --- a/windows/build_mingw.bat +++ b/windows/build_mingw.bat @@ -8,39 +8,28 @@ powershell -Command "Invoke-WebRequest %DMD_URL% -OutFile dmd2.7z" || exit /B 1 7z x dmd2.7z || exit /B 1 set PATH=%ROOT%\dmd2\windows\bin;%PATH% -set MINGW_BASEURL=https://netix.dl.sourceforge.net/project/mingw/MinGW/Base/ -set W32API_URL=%MINGW_BASEURL%/w32api/w32api-%MINGW_VER%/w32api-%MINGW_VER%-mingw32-src.tar.xz -set MINGWRT_URL=%MINGW_BASEURL%/mingwrt/mingwrt-%MINGW_VER%/mingwrt-%MINGW_VER%-mingw32-src.tar.xz +set MINGW_URL=https://netix.dl.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v%MINGW_VER%.tar.bz2 set USER_AGENT=[Microsoft.PowerShell.Commands.PSUserAgent]::FireFox -powershell -Command "Invoke-WebRequest %W32API_URL% -OutFile w32api.src.tar.xz -UserAgent %User_Agent%" || exit /B 1 -powershell -Command "Invoke-WebRequest %MINGWRT_URL% -OutFile mingwrt.src.tar.xz -UserAgent %User_Agent%" || exit /B 1 +powershell -Command "Invoke-WebRequest %MINGW_URL% -FileName mingw-w64.tar.bz2 -UserAgent %User_Agent%" || exit /B 1 :: e.g. from git installation dos2unix "%ROOT%\windows\build_mingw.sha256sums" sha256sum -c "%ROOT%\windows\build_mingw.sha256sums" || exit /B 1 -7z x w32api.src.tar.xz || exit /B 1 -7z x w32api.src.tar || exit /B 1 +7z x mingw-w64.tar.bz2 || exit /B 1 +7z x mingw-w64.tar || exit /B 1 -7z x mingwrt.src.tar.xz || exit /B 1 -7z x mingwrt.src.tar || exit /B 1 - -move w32api-%MINGW_VER% w32api -move mingwrt-%MINGW_VER% mingwrt - -cd windows\mingw -set w32api_lib=../../w32api/lib -set msvcrt_def_in=../../mingwrt/msvcrt-xref/msvcrt.def.in +move mingw-w64-v%MINGW_VER% mingw-w64 call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 rem CWD might be changed by vcvars64.bat cd %ROOT%\windows\mingw -dmd -run buildsdk.d x64 %w32api_lib% dmd2\windows\lib64\mingw %msvcrt_def_in% || exit /B 1 +dmd -run buildsdk.d x64 %ROOT%\mingw-w64 dmd2\windows\lib64\mingw || exit /B 1 call "%VSINSTALLDIR%\VC\Auxiliary\Build\vcvarsall.bat" x86 cd %ROOT%\windows\mingw -dmd -run buildsdk.d x86 %w32api_lib% dmd2\windows\lib32mscoff\mingw %msvcrt_def_in% || exit /B 1 +dmd -run buildsdk.d x86 %ROOT%\mingw-w64 dmd2\windows\lib32mscoff\mingw || exit /B 1 mkdir "%ROOT%\artifacts" 7z a %ROOT%\artifacts\mingw-libs-%MINGW_VER%.zip dmd2\windows diff --git a/windows/build_mingw.sha256sums b/windows/build_mingw.sha256sums index 0bb99035..3cefc7bc 100644 --- a/windows/build_mingw.sha256sums +++ b/windows/build_mingw.sha256sums @@ -1,2 +1 @@ -b80b0c9d0158f9125e482b50fe00b70dde11d7a015ee687ca455fe2ea2ec8733 w32api.src.tar.xz -77233333f5440287840d134804bcecf3144ec3efc7fd7f7c6dce318e4e7146ee mingwrt.src.tar.xz +805e11101e26d7897fce7d49cbb140d7bac15f3e085a91e0001e80b2adaf48f0 mingw-w64.tar.bz2 diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 8fedad40..0dbc61a3 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -1,205 +1,160 @@ // -// Convert MingGW definition files to COFF import librries +// Convert MingGW-w64 definition files to COFF import librries // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// usage: buildsdk [x86|x64] [def-folder] [output-folder] [msvcrt.def.in] +// usage: buildsdk [x86|x64] [mingw-w64-folder] [output-folder] // -// Source files extracted from the MinGW reositories -// -// def-folder: https://sourceforge.net/p/mingw/mingw-org-wsl/ci/5.0-active/tree/w32api/lib/ -// msvcrt.def.in: https://sourceforge.net/p/mingw/mingw-org-wsl/ci/5.0-active/tree/mingwrt/msvcrt-xref/msvcrt.def.in +// source files extracted from MinGW-w64: +// https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v6.0.0.tar.bz2 // // assumes VC tools cl,link,lib and ml installed and found through path // and configured to the appropriate architecture // -import std.file; -import std.regex; -import std.string; -import std.stdio; -import std.path; -import std.process; -import std.algorithm; +import std.algorithm; +import std.array; +import std.file; +import std.path; +import std.process; +import std.stdio; +import std.string; version = verbose; void runShell(string cmd) { - version(verbose) + version (verbose) writeln(cmd); - auto rc = executeShell(cmd); - if (rc.status) - { + const rc = executeShell(cmd); + if (rc.status) + { writeln("'", cmd, "' failed with status ", rc.status); - writeln(rc.output); - throw new Exception("'" ~ cmd ~ "' failed"); + writeln(rc.output); + throw new Exception("'" ~ cmd ~ "' failed"); } } -// x86: the exported symbols have stdcall mangling (including trailing @n) -// but the internal names of the platform DLLs have names with @n stripped off -// lib /DEF doesn't support renaming symbols so we have to go through compiling -// a C file with the symbols and building a DLL with renamed exports to get -// the appropriate import library -// -// x64: strip any @ from the symbol names -bool def2implib(bool x64, string f, string dir, string linkopt = null) -{ - static auto re = regex(r"@?([a-zA-Z0-9_]+)(@[0-9]*)"); - char[] content = cast(char[])std.file.read(f); - auto pos = content.indexOf("EXPORTS"); - if (pos < 0) - return false; - - string base = stripExtension(baseName(f)); - if (x64 && base == "user32") +// Preprocesses a 'foo.def.in' file to 'foo.def'. +void generateDef(bool x64, string inFile, string outFile) +{ + const includeDir = buildPath(dirName(dirName(inFile)), "def-include"); + const archDefine = x64 ? "DEF_X64" : "DEF_I386"; + runShell(`cl /EP /D` ~ archDefine ~ `=1 "/I` ~ includeDir ~ `" "` ~ inFile ~ `" > "` ~ outFile ~ `"`); +} + +// The MinGW-w64 .def files specify renamings as 'exportedName == realName'. +// The MS format is 'exportedName=realName'. +void sanitizeDef(string defFile) +{ + const data = std.file.readText(defFile); + const newData = data.replace(" == ", "="); + if (newData !is data) + std.file.write(defFile, newData); +} + +void copyDefs(bool x64, string inDir, string outDir) +{ + mkdirRecurse(outDir); + + foreach (f; std.file.dirEntries(inDir, SpanMode.shallow)) { - // missing definitions in mingw def files - content ~= "GetClassLongPtrA\n"; - content ~= "GetClassLongPtrW\n"; - content ~= "SetClassLongPtrA\n"; - content ~= "SetClassLongPtrW\n"; - content ~= "GetWindowLongPtrA\n"; - content ~= "GetWindowLongPtrW\n"; - content ~= "SetWindowLongPtrA\n"; - content ~= "SetWindowLongPtrW\n"; - } - - char[] def = content[0..pos]; - char[] csrc; - bool[string] written; - auto lines = content[pos..$].splitLines; - foreach(line; lines) - { - line = line.strip; - if (line.length == 0 || line[0] == ';') - continue; - const(char)[] sym; - char[] cline; - auto m = matchFirst(line, re); - if (m) - { - if (x64) - def ~= m[1] ~ "\n"; - else - def ~= m[0] ~ "=" ~ m[1] ~ "\n"; - sym = m[1]; - cline = "void " ~ m[1] ~ "() {}\n"; - } - else + const path = f.name; + const lowerPath = toLower(path); + string outFile; + + if (lowerPath.endsWith(".def.in")) { - def ~= line ~ "\n"; - if (line.endsWith(" DATA")) - { - sym = strip(line[0..$-5]); - cline = "int " ~ sym ~ ";\n"; - } - else - { - auto idx = line.indexOf('='); - if (idx > 0) - sym = line[idx+1 .. $].strip; - else - sym = line; - cline = "void " ~ sym ~ "() {}\n"; - } + outFile = buildPath(outDir, baseName(f.name)[0 .. $-7] ~ ".def"); + generateDef(x64, path, outFile); } - if(sym.length && sym !in written) + else if (lowerPath.endsWith(".def")) { - csrc ~= cline; - written[sym.idup] = true; + outFile = buildPath(outDir, baseName(f.name)); + std.file.copy(path, outFile); } + + if (outFile !is null) + sanitizeDef(outFile); } - string dirbase = dir ~ base; - std.file.write(dirbase ~ ".def", def); - std.file.write(dirbase ~ ".c", csrc); - - runShell("cl /c /Fo" ~ dirbase ~ ".obj " ~ dirbase ~ ".c"); - runShell("link /NOD /NOENTRY /DLL " ~ dirbase ~ ".obj /out:" ~ dirbase ~ ".dll /def:" ~ dirbase ~ ".def" ~ linkopt); - - // cleanup - std.file.remove(dirbase ~ ".def"); - std.file.remove(dirbase ~ ".c"); - std.file.remove(dirbase ~ ".obj"); - std.file.remove(dirbase ~ ".dll"); - std.file.remove(dirbase ~ ".exp"); - return true; -} - -void buildLibs(bool x64, string defdir, string dir) -{ - mkdirRecurse(dir); +} - //goto LnoDef; - foreach(f; std.file.dirEntries(defdir, SpanMode.shallow)) - if (extension(f).toLower == ".def") - def2implib(x64, f, dir); - foreach(f; std.file.dirEntries(defdir ~ "/directx", SpanMode.shallow)) - if (extension(f).toLower == ".def") - def2implib(x64, f, dir); +void def2implib(bool x64, string defFile) +{ + const libFile = setExtension(defFile, ".lib"); + const arch = x64 ? "X64" : "X86"; + runShell(`lib /MACHINE:` ~ arch ~ ` "/DEF:` ~ defFile ~ `" "/OUT:` ~ libFile ~ `"`); + std.file.remove(setExtension(defFile, ".exp")); +} - version(DDK) // disable for now +void defs2implibs(bool x64, string dir) +{ + foreach (f; std.file.dirEntries(dir, SpanMode.shallow)) { - mkdirRecurse(dir ~ ddk); - foreach(f; std.file.dirEntries(defdir ~ "/ddk", SpanMode.shallow)) - if (extension(f).toLower == ".def") - def2implib(x64, f, dir ~ "ddk/"); + const path = f.name; + if (toLower(path).endsWith(".def")) + def2implib(x64, path); } } -void buildMsvcrt(bool x64, string dir, string msvcdef) +void buildMsvcrt(bool x64, string outDir) { - string arch = x64 ? "x64" : "x86"; - string lib = "lib /MACHINE:" ~ arch ~ " "; - string msvcrtlib = "msvcrt100.lib"; - - // build msvcrt.lib for VS2010 - runShell("cl /EP -D__MSVCRT_VERSION__=0x10000000UL -D__DLLNAME__=msvcr100 " ~ msvcdef ~ " >" ~ dir ~ "msvcrt.def"); - runShell(lib ~ "/OUT:" ~ dir ~ msvcrtlib ~ " /DEF:" ~ dir ~ "msvcrt.def"); // no translation necessary - runShell("cl /c /Zl /Fo" ~ dir ~ "msvcrt_stub0.obj /D_APPTYPE=0 msvcrt_stub.c"); - runShell("cl /c /Zl /Fo" ~ dir ~ "msvcrt_stub1.obj /D_APPTYPE=1 msvcrt_stub.c"); - runShell("cl /c /Zl /Fo" ~ dir ~ "msvcrt_stub2.obj /D_APPTYPE=2 msvcrt_stub.c"); - runShell("cl /c /Zl /Fo" ~ dir ~ "msvcrt_data.obj msvcrt_data.c"); - runShell("cl /c /Zl /Fo" ~ dir ~ "msvcrt_atexit.obj msvcrt_atexit.c"); - auto files = ["msvcrt_stub0.obj", "msvcrt_stub1.obj", "msvcrt_stub2.obj", "msvcrt_data.obj", "msvcrt_atexit.obj" ]; + outDir ~= "/"; + const cl = "cl /c /Zl "; + const lib = "lib /MACHINE:" ~ (x64 ? "X64" : "X86") ~ " "; + + // compile some additional objects to be merged into the msvcr*.lib files + runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_stub0.obj /D_APPTYPE=0 msvcrt_stub.c"); + runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_stub1.obj /D_APPTYPE=1 msvcrt_stub.c"); + runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_stub2.obj /D_APPTYPE=2 msvcrt_stub.c"); + runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_data.obj msvcrt_data.c"); + runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_atexit.obj msvcrt_atexit.c"); + auto objs = [ "msvcrt_stub0.obj", "msvcrt_stub1.obj", "msvcrt_stub2.obj", "msvcrt_data.obj", "msvcrt_atexit.obj" ]; if (!x64) { - runShell("ml /c /Fo" ~ dir ~ "msvcrt_abs.obj msvcrt_abs.asm"); - files ~= "msvcrt_abs.obj"; + runShell("ml /c /Fo" ~ outDir ~ "msvcrt_abs.obj msvcrt_abs.asm"); + objs ~= "msvcrt_abs.obj"; } - auto objs = files.map!(a => dir ~ a).join(" "); - runShell(lib ~ dir ~ msvcrtlib ~ " " ~ objs); + + // merge into libs + const additionalMsvcrtObjs = objs.map!(a => outDir ~ a).join(" "); + foreach (f; std.file.dirEntries(outDir[0 .. $-1], "msvcr*.lib", SpanMode.shallow)) + runShell(lib ~ f.name ~ " " ~ additionalMsvcrtObjs); // create oldnames.lib (expected by dmd) - runShell("cl /c /Zl /Fo" ~ dir ~ "oldnames.obj oldnames.c"); - runShell(lib ~ "/OUT:" ~ dir ~ "oldnames.lib " ~ dir ~ "oldnames.obj"); + runShell(cl ~ "/Fo" ~ outDir ~ "oldnames.obj oldnames.c"); + runShell(lib ~ "/OUT:" ~ outDir ~ "oldnames.lib " ~ outDir ~ "oldnames.obj"); + objs ~= "oldnames.obj"; // create empty uuid.lib (expected by dmd, but UUIDs already in druntime) - std.file.write(dir ~ "empty.c", ""); - runShell("cl /c /Zl /Fo" ~ dir ~ "uuid.obj " ~ dir ~ "empty.c"); - runShell(lib ~ "/OUT:" ~ dir ~ "uuid.lib " ~ dir ~ "uuid.obj"); - - foreach(f; files) - std.file.remove(dir ~ f); - std.file.remove(dir ~ stripExtension(msvcrtlib) ~ ".exp"); - std.file.remove(dir ~ "msvcrt.def"); - std.file.remove(dir ~ "oldnames.obj"); - std.file.remove(dir ~ "uuid.obj"); - std.file.remove(dir ~ "empty.c"); + std.file.write(outDir ~ "empty.c", ""); + runShell(cl ~ "/Fo" ~ outDir ~ "uuid.obj " ~ outDir ~ "empty.c"); + runShell(lib ~ "/OUT:" ~ outDir ~ "uuid.lib " ~ outDir ~ "uuid.obj"); + objs ~= "uuid.obj"; + std.file.remove(outDir ~ "empty.c"); + + foreach (f; objs) + std.file.remove(outDir ~ f); } -void main(string[] args) +void main(string[] args) { - bool x64 = (args.length > 1 && args[1] == "x64"); - string defdir = (args.length > 2 ? args[2] : "def"); - string outdir = x64 ? "lib64/" : "lib32mscoff/"; + const x64 = (args.length > 1 && args[1] == "x64"); + const mingwDir = (args.length > 2 ? args[2] : "mingw-w64"); + string outDir = x64 ? "lib64" : "lib32"; if (args.length > 3) - outdir = args[3] ~ "/"; - string msvcdef = (args.length > 4 ? args[4] : "msvcrt.def.in"); + outDir = args[3]; + + copyDefs(x64, buildPath(mingwDir, "mingw-w64-crt", "lib-common"), outDir); + copyDefs(x64, buildPath(mingwDir, "mingw-w64-crt", "lib" ~ (x64 ? "64" : "32")), outDir); + + defs2implibs(x64, outDir); + + buildMsvcrt(x64, outDir); - buildLibs(x64, defdir, outdir); - buildMsvcrt(x64, outdir, msvcdef); + //version (verbose) {} else + foreach (f; std.file.dirEntries(outDir, "*.def", SpanMode.shallow)) + std.file.remove(f.name); } From f06e8c4f92da6ca7d4803dc35413f0da11d21acd Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 21 Oct 2018 21:50:37 +0200 Subject: [PATCH 02/20] Patch .def files - don't export default atexit, export __chkstk --- windows/mingw/buildsdk.d | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 0dbc61a3..963ea3b7 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -45,14 +45,36 @@ void generateDef(bool x64, string inFile, string outFile) runShell(`cl /EP /D` ~ archDefine ~ `=1 "/I` ~ includeDir ~ `" "` ~ inFile ~ `" > "` ~ outFile ~ `"`); } -// The MinGW-w64 .def files specify renamings as 'exportedName == realName'. -// The MS format is 'exportedName=realName'. void sanitizeDef(string defFile) { - const data = std.file.readText(defFile); - const newData = data.replace(" == ", "="); - if (newData !is data) - std.file.write(defFile, newData); + const lines = std.file.readText(defFile).splitLines; + + bool touched = false; + const newLines = lines.map!((const string line) + { + string l = line; + + // The MinGW-w64 .def files specify renamings as 'exportedName == realName'. + // The MS format is 'exportedName=realName'. + l = l.replace(" == ", "="); + + // Don't export function 'atexit'; we have our own in msvc_atexit.c. + if (l == "atexit" /* 120 */ || l == "atexit DATA" /* < 120 */) + l = ""; + + // Do export function '__chkstk' (ntdll.dll). + // LLVM emits calls to it to detect stack overflows with '_alloca'. + if (l == ";__chkstk") + l = "__chkstk"; + + if (l !is line) + touched = true; + + return l; + }).array; + + if (touched) + std.file.write(defFile, newLines.join("\n")); } void copyDefs(bool x64, string inDir, string outDir) From 5e32f0b06ef56f54c5206b4c3063e4e9d8484070 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Mon, 22 Oct 2018 01:04:35 +0200 Subject: [PATCH 03/20] Auto-generate oldnames.c from special MinGW .def directives --- windows/mingw/buildsdk.d | 100 +++++++++++++++++++--------- windows/mingw/oldnames.c | 140 --------------------------------------- 2 files changed, 68 insertions(+), 172 deletions(-) delete mode 100644 windows/mingw/oldnames.c diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 963ea3b7..f69b7390 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -10,7 +10,7 @@ // source files extracted from MinGW-w64: // https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v6.0.0.tar.bz2 // -// assumes VC tools cl,link,lib and ml installed and found through path +// assumes VC tools cl, lib and ml installed and found through path // and configured to the appropriate architecture // @@ -24,6 +24,10 @@ import std.string; version = verbose; +bool x64; +string[string] weakSymbols; // weak name => real name + + void runShell(string cmd) { version (verbose) @@ -38,7 +42,7 @@ void runShell(string cmd) } // Preprocesses a 'foo.def.in' file to 'foo.def'. -void generateDef(bool x64, string inFile, string outFile) +void generateDef(string inFile, string outFile) { const includeDir = buildPath(dirName(dirName(inFile)), "def-include"); const archDefine = x64 ? "DEF_X64" : "DEF_I386"; @@ -54,12 +58,22 @@ void sanitizeDef(string defFile) { string l = line; - // The MinGW-w64 .def files specify renamings as 'exportedName == realName'. - // The MS format is 'exportedName=realName'. - l = l.replace(" == ", "="); + // The MinGW-w64 .def files specify weak external symbols as 'alias == realName'. + if (l.length > 1 && l[0] != ';') + { + const i = l.indexOf(" == "); + if (i > 0) + { + const weakName = l[0 .. i]; + const realName = l[i+4 .. $]; + weakSymbols[weakName] = realName; + + l = ";" ~ l; + } + } // Don't export function 'atexit'; we have our own in msvc_atexit.c. - if (l == "atexit" /* 120 */ || l == "atexit DATA" /* < 120 */) + if (l == "atexit" /* msvcr120 */ || l == "atexit DATA" /* < 120 */) l = ""; // Do export function '__chkstk' (ntdll.dll). @@ -77,7 +91,7 @@ void sanitizeDef(string defFile) std.file.write(defFile, newLines.join("\n")); } -void copyDefs(bool x64, string inDir, string outDir) +void copyDefs(string inDir, string outDir) { mkdirRecurse(outDir); @@ -90,7 +104,7 @@ void copyDefs(bool x64, string inDir, string outDir) if (lowerPath.endsWith(".def.in")) { outFile = buildPath(outDir, baseName(f.name)[0 .. $-7] ~ ".def"); - generateDef(x64, path, outFile); + generateDef(path, outFile); } else if (lowerPath.endsWith(".def")) { @@ -103,7 +117,7 @@ void copyDefs(bool x64, string inDir, string outDir) } } -void def2implib(bool x64, string defFile) +void def2implib(string defFile) { const libFile = setExtension(defFile, ".lib"); const arch = x64 ? "X64" : "X86"; @@ -111,49 +125,44 @@ void def2implib(bool x64, string defFile) std.file.remove(setExtension(defFile, ".exp")); } -void defs2implibs(bool x64, string dir) +void defs2implibs(string dir) { foreach (f; std.file.dirEntries(dir, SpanMode.shallow)) { const path = f.name; if (toLower(path).endsWith(".def")) - def2implib(x64, path); + def2implib(path); } } -void buildMsvcrt(bool x64, string outDir) +void buildMsvcrt(string outDir) { outDir ~= "/"; const cl = "cl /c /Zl "; const lib = "lib /MACHINE:" ~ (x64 ? "X64" : "X86") ~ " "; // compile some additional objects to be merged into the msvcr*.lib files - runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_stub0.obj /D_APPTYPE=0 msvcrt_stub.c"); - runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_stub1.obj /D_APPTYPE=1 msvcrt_stub.c"); - runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_stub2.obj /D_APPTYPE=2 msvcrt_stub.c"); - runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_data.obj msvcrt_data.c"); - runShell(cl ~ "/Fo" ~ outDir ~ "msvcrt_atexit.obj msvcrt_atexit.c"); + runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_stub0.obj" /D_APPTYPE=0 msvcrt_stub.c`); + runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_stub1.obj" /D_APPTYPE=1 msvcrt_stub.c`); + runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_stub2.obj" /D_APPTYPE=2 msvcrt_stub.c`); + runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_data.obj" msvcrt_data.c`); + runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_atexit.obj" msvcrt_atexit.c`); auto objs = [ "msvcrt_stub0.obj", "msvcrt_stub1.obj", "msvcrt_stub2.obj", "msvcrt_data.obj", "msvcrt_atexit.obj" ]; if (!x64) { - runShell("ml /c /Fo" ~ outDir ~ "msvcrt_abs.obj msvcrt_abs.asm"); + runShell(`ml /c "/Fo` ~ outDir ~ `msvcrt_abs.obj" msvcrt_abs.asm`); objs ~= "msvcrt_abs.obj"; } // merge into libs - const additionalMsvcrtObjs = objs.map!(a => outDir ~ a).join(" "); + const additionalMsvcrtObjs = objs.map!(a => `"` ~ outDir ~ a ~ `"`).join(" "); foreach (f; std.file.dirEntries(outDir[0 .. $-1], "msvcr*.lib", SpanMode.shallow)) - runShell(lib ~ f.name ~ " " ~ additionalMsvcrtObjs); - - // create oldnames.lib (expected by dmd) - runShell(cl ~ "/Fo" ~ outDir ~ "oldnames.obj oldnames.c"); - runShell(lib ~ "/OUT:" ~ outDir ~ "oldnames.lib " ~ outDir ~ "oldnames.obj"); - objs ~= "oldnames.obj"; + runShell(lib ~ `"` ~ f.name ~ `" ` ~ additionalMsvcrtObjs); // create empty uuid.lib (expected by dmd, but UUIDs already in druntime) std.file.write(outDir ~ "empty.c", ""); - runShell(cl ~ "/Fo" ~ outDir ~ "uuid.obj " ~ outDir ~ "empty.c"); - runShell(lib ~ "/OUT:" ~ outDir ~ "uuid.lib " ~ outDir ~ "uuid.obj"); + runShell(cl ~ `"/Fo` ~ outDir ~ `uuid.obj" "` ~ outDir ~ `empty.c"`); + runShell(lib ~ `"/OUT:` ~ outDir ~ `uuid.lib" "` ~ outDir ~ `uuid.obj"`); objs ~= "uuid.obj"; std.file.remove(outDir ~ "empty.c"); @@ -161,20 +170,47 @@ void buildMsvcrt(bool x64, string outDir) std.file.remove(outDir ~ f); } +void buildOldnames(string outDir) +{ + const cPrefix = x64 ? "" : "_"; + const oldnames_c = + // access this __ref_oldnames symbol to drag in the generated linker directives (msvcrt_stub.c) + "int __ref_oldnames;\n" ~ + weakSymbols.byKeyValue.map!(pair => + `__pragma(comment(linker, "/alternatename:` ~ cPrefix ~ pair.key ~ `=` ~ cPrefix ~ pair.value ~ `"));` + ).join("\n"); + + version (verbose) + writeln("\nAuto-generated oldnames.c:\n----------\n", oldnames_c, "\n----------\n"); + + const src = buildPath(outDir, "oldnames.c"); + std.file.write(src, oldnames_c); + + const obj = setExtension(src, ".obj"); + runShell(`cl /c /Zl "/Fo` ~ obj ~ `" "` ~ src ~ `"`); + + const lib = setExtension(src, ".lib"); + runShell(`lib /MACHINE:` ~ (x64 ? "X64" : "X86") ~ ` "/OUT:` ~ lib ~ `" "` ~ obj ~ `"`); + + std.file.remove(src); + std.file.remove(obj); +} + void main(string[] args) { - const x64 = (args.length > 1 && args[1] == "x64"); + x64 = (args.length > 1 && args[1] == "x64"); const mingwDir = (args.length > 2 ? args[2] : "mingw-w64"); string outDir = x64 ? "lib64" : "lib32"; if (args.length > 3) outDir = args[3]; - copyDefs(x64, buildPath(mingwDir, "mingw-w64-crt", "lib-common"), outDir); - copyDefs(x64, buildPath(mingwDir, "mingw-w64-crt", "lib" ~ (x64 ? "64" : "32")), outDir); + copyDefs(buildPath(mingwDir, "mingw-w64-crt", "lib-common"), outDir); + copyDefs(buildPath(mingwDir, "mingw-w64-crt", "lib" ~ (x64 ? "64" : "32")), outDir); - defs2implibs(x64, outDir); + defs2implibs(outDir); - buildMsvcrt(x64, outDir); + buildMsvcrt(outDir); + buildOldnames(outDir); //version (verbose) {} else foreach (f; std.file.dirEntries(outDir, "*.def", SpanMode.shallow)) diff --git a/windows/mingw/oldnames.c b/windows/mingw/oldnames.c deleted file mode 100644 index 83e092b5..00000000 --- a/windows/mingw/oldnames.c +++ /dev/null @@ -1,140 +0,0 @@ - -#if defined _M_IX86 - #define C_PREFIX "_" -#elif defined _M_X64 || defined _M_ARM || defined _M_ARM64 - #define C_PREFIX "" -#else - #error Unsupported architecture -#endif - -#define DECLARE_ALTERNATE_NAME(name, alternate_name) \ - __pragma(comment(linker, "/alternatename:" C_PREFIX #name "=" C_PREFIX #alternate_name)) -#define DECLARE_ALTERNATE__(name) DECLARE_ALTERNATE_NAME(name, _##name) - -DECLARE_ALTERNATE_NAME(time, _time32); -DECLARE_ALTERNATE_NAME(ftime, _ftime32); -DECLARE_ALTERNATE_NAME(utime, _utime32); -DECLARE_ALTERNATE_NAME(stat, _stat32); -DECLARE_ALTERNATE_NAME(fstat, _fstat32); -DECLARE_ALTERNATE_NAME(strcmpi, _stricmp); -DECLARE_ALTERNATE_NAME(localtime, _localtime32); - -DECLARE_ALTERNATE__(fcloseall ); -DECLARE_ALTERNATE__(tzset ); -DECLARE_ALTERNATE__(execvpe ); -DECLARE_ALTERNATE__(execvp ); -DECLARE_ALTERNATE__(execve ); -DECLARE_ALTERNATE__(execv ); -DECLARE_ALTERNATE__(execlpe ); -DECLARE_ALTERNATE__(execlp ); -DECLARE_ALTERNATE__(execle ); -DECLARE_ALTERNATE__(execl ); -DECLARE_ALTERNATE__(control87); -DECLARE_ALTERNATE__(sys_errlist); -DECLARE_ALTERNATE__(filelength); -DECLARE_ALTERNATE__(control87 ); -DECLARE_ALTERNATE__(_wcsicoll ); -DECLARE_ALTERNATE__(_wcsupr ); -DECLARE_ALTERNATE__(_wcslwr ); -DECLARE_ALTERNATE__(_wcsset ); -DECLARE_ALTERNATE__(_wcsrev ); -DECLARE_ALTERNATE__(_wcsnset ); -DECLARE_ALTERNATE__(_wcsnicmp ); -DECLARE_ALTERNATE__(_wcsicmp ); -DECLARE_ALTERNATE__(_wcsdup ); -DECLARE_ALTERNATE__(_dup ); -DECLARE_ALTERNATE__(_tzset ); -DECLARE_ALTERNATE__(_tzname ); -DECLARE_ALTERNATE__(_timezone ); -DECLARE_ALTERNATE__(_strupr ); -DECLARE_ALTERNATE__(_strset ); -DECLARE_ALTERNATE__(_strrev ); -DECLARE_ALTERNATE__(_strnset ); -DECLARE_ALTERNATE__(_strnicmp ); -DECLARE_ALTERNATE__(_strlwr ); -DECLARE_ALTERNATE__(_strdup ); -DECLARE_ALTERNATE__(_stricmp ); -DECLARE_ALTERNATE__(_tempnam ); -DECLARE_ALTERNATE__(_rmtmp ); -DECLARE_ALTERNATE__(_putw ); -DECLARE_ALTERNATE__(_getw ); -DECLARE_ALTERNATE__(_fputchar ); -DECLARE_ALTERNATE__(_flushall ); -DECLARE_ALTERNATE__(_fileno ); -DECLARE_ALTERNATE__(_fgetchar ); -DECLARE_ALTERNATE__(_fdopen ); -DECLARE_ALTERNATE__(_ultoa ); -DECLARE_ALTERNATE__(_swab ); -DECLARE_ALTERNATE__(_putenv ); -DECLARE_ALTERNATE__(_onexit ); -DECLARE_ALTERNATE__(_ltoa ); -DECLARE_ALTERNATE__(_itoa ); -DECLARE_ALTERNATE__(_yn ); -DECLARE_ALTERNATE__(_y1 ); -DECLARE_ALTERNATE__(_y0 ); -DECLARE_ALTERNATE__(_jn ); -DECLARE_ALTERNATE__(_j1 ); -DECLARE_ALTERNATE__(_j0 ); -DECLARE_ALTERNATE__(_cabs ); -DECLARE_ALTERNATE__(_HUGE ); -DECLARE_ALTERNATE__(_gcvt ); -DECLARE_ALTERNATE__(_fcvt ); -DECLARE_ALTERNATE__(_ecvt ); -DECLARE_ALTERNATE__(_lsearch ); -DECLARE_ALTERNATE__(_lfind ); -DECLARE_ALTERNATE__(_spawnvpe ); -DECLARE_ALTERNATE__(_spawnvp ); -DECLARE_ALTERNATE__(_spawnve ); -DECLARE_ALTERNATE__(_spawnv ); -DECLARE_ALTERNATE__(_spawnlpe ); -DECLARE_ALTERNATE__(_spawnlp ); -DECLARE_ALTERNATE__(_spawnle ); -DECLARE_ALTERNATE__(_spawnl ); -DECLARE_ALTERNATE__(_getpid ); -DECLARE_ALTERNATE__(_cwait ); -DECLARE_ALTERNATE__(_memicmp ); -DECLARE_ALTERNATE__(_memccpy ); -DECLARE_ALTERNATE__(_write ); -DECLARE_ALTERNATE__(_unlink ); -DECLARE_ALTERNATE__(_umask ); -DECLARE_ALTERNATE__(_tell ); -DECLARE_ALTERNATE__(_sys_nerr ); -DECLARE_ALTERNATE__(_sopen ); -DECLARE_ALTERNATE__(_setmode ); -DECLARE_ALTERNATE__(_read ); -DECLARE_ALTERNATE__(_open ); -DECLARE_ALTERNATE__(_mktemp ); -DECLARE_ALTERNATE__(_lseek ); -DECLARE_ALTERNATE__(_locking ); -DECLARE_ALTERNATE__(_isatty ); -DECLARE_ALTERNATE__(_eof ); -DECLARE_ALTERNATE__(_dup2 ); -DECLARE_ALTERNATE__(_creat ); -DECLARE_ALTERNATE__(_close ); -DECLARE_ALTERNATE__(_chsize ); -DECLARE_ALTERNATE__(_chmod ); -DECLARE_ALTERNATE__(_access ); -DECLARE_ALTERNATE__(_rmdir ); -DECLARE_ALTERNATE__(_mkdir ); -DECLARE_ALTERNATE__(_getcwd ); -DECLARE_ALTERNATE__(_chdir ); -DECLARE_ALTERNATE__(_ungetch ); -DECLARE_ALTERNATE__(_putch ); -DECLARE_ALTERNATE__(_kbhit ); -DECLARE_ALTERNATE__(_getche ); -DECLARE_ALTERNATE__(_fpreset ); -DECLARE_ALTERNATE__(_getch ); -DECLARE_ALTERNATE__(_environ ); -DECLARE_ALTERNATE__(_daylight ); -DECLARE_ALTERNATE__(_cscanf ); -DECLARE_ALTERNATE__(_cputs ); -DECLARE_ALTERNATE__(_cprintf ); -DECLARE_ALTERNATE__(_cgets ); - -// access this symbol to drag in the generated linker directives -int __ref_oldnames; - -#if defined _M_X64 -int _isnan(double); -int _isnanf(float f) { return _isnan(f); } -#endif From 7278e0373ecbfb6309860f57b22ef6a3f74be320 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 23 Oct 2018 01:58:01 +0200 Subject: [PATCH 04/20] Fixup vcruntime140_app.def --- windows/mingw/buildsdk.d | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index f69b7390..76ef2102 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -58,6 +58,9 @@ void sanitizeDef(string defFile) { string l = line; + if (l == "LIBRARY vcruntime140_app") + l = `LIBRARY "VCRUNTIME140.dll"`; + // The MinGW-w64 .def files specify weak external symbols as 'alias == realName'. if (l.length > 1 && l[0] != ';') { @@ -103,12 +106,16 @@ void copyDefs(string inDir, string outDir) if (lowerPath.endsWith(".def.in")) { - outFile = buildPath(outDir, baseName(f.name)[0 .. $-7] ~ ".def"); + auto base = baseName(path)[0 .. $-7]; + if (base == "vcruntime140_app") + base = "vcruntime140"; + + outFile = buildPath(outDir, base ~ ".def"); generateDef(path, outFile); } else if (lowerPath.endsWith(".def")) { - outFile = buildPath(outDir, baseName(f.name)); + outFile = buildPath(outDir, baseName(path)); std.file.copy(path, outFile); } From 70cd2ae7233809bb5fc2c6b5372a936dfbc94555 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 23 Oct 2018 02:01:44 +0200 Subject: [PATCH 05/20] Merge extra objects into ucrtbase.lib too --- windows/mingw/buildsdk.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 76ef2102..e845a35d 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -163,8 +163,12 @@ void buildMsvcrt(string outDir) // merge into libs const additionalMsvcrtObjs = objs.map!(a => `"` ~ outDir ~ a ~ `"`).join(" "); - foreach (f; std.file.dirEntries(outDir[0 .. $-1], "msvcr*.lib", SpanMode.shallow)) - runShell(lib ~ `"` ~ f.name ~ `" ` ~ additionalMsvcrtObjs); + foreach (f; std.file.dirEntries(outDir[0 .. $-1], "*.lib", SpanMode.shallow)) + { + const lowerBase = toLower(baseName(f.name)); + if (lowerBase.startsWith("msvcr") || lowerBase.startsWith("ucrtbase")) + runShell(lib ~ `"` ~ f.name ~ `" ` ~ additionalMsvcrtObjs); + } // create empty uuid.lib (expected by dmd, but UUIDs already in druntime) std.file.write(outDir ~ "empty.c", ""); From eb9aa867c67d83fb7d03588f80448fe3a6463435 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 23 Oct 2018 02:51:15 +0200 Subject: [PATCH 06/20] Build legacy_stdio_definitions.lib for VS 2015+ --- windows/mingw/buildsdk.d | 63 +++++++++++++++--------- windows/mingw/legacy_stdio_definitions.c | 33 +++++++++++++ 2 files changed, 74 insertions(+), 22 deletions(-) create mode 100644 windows/mingw/legacy_stdio_definitions.c diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index e845a35d..b566f257 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -142,18 +142,35 @@ void defs2implibs(string dir) } } +void cl(string outObj, string args) +{ + runShell(`cl /c /Zl "/Fo` ~ outObj ~ `" ` ~ args); +} + +string quote(string arg) +{ + return `"` ~ arg ~ `"`; +} + +void c2lib(string outDir, string cFile) +{ + const obj = buildPath(outDir, baseName(cFile).setExtension(".obj")); + const lib = setExtension(obj, ".lib"); + cl(obj, quote(cFile)); + runShell(`lib /MACHINE:` ~ (x64 ? "X64" : "X86") ~ ` "/OUT:` ~ lib ~ `" "` ~ obj ~ `"`); + std.file.remove(obj); +} + void buildMsvcrt(string outDir) { outDir ~= "/"; - const cl = "cl /c /Zl "; - const lib = "lib /MACHINE:" ~ (x64 ? "X64" : "X86") ~ " "; // compile some additional objects to be merged into the msvcr*.lib files - runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_stub0.obj" /D_APPTYPE=0 msvcrt_stub.c`); - runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_stub1.obj" /D_APPTYPE=1 msvcrt_stub.c`); - runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_stub2.obj" /D_APPTYPE=2 msvcrt_stub.c`); - runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_data.obj" msvcrt_data.c`); - runShell(cl ~ `"/Fo` ~ outDir ~ `msvcrt_atexit.obj" msvcrt_atexit.c`); + cl(outDir ~ "msvcrt_stub0.obj", "/D_APPTYPE=0 msvcrt_stub.c"); + cl(outDir ~ "msvcrt_stub1.obj", "/D_APPTYPE=1 msvcrt_stub.c"); + cl(outDir ~ "msvcrt_stub2.obj", "/D_APPTYPE=2 msvcrt_stub.c"); + cl(outDir ~ "msvcrt_data.obj", "msvcrt_data.c"); + cl(outDir ~ "msvcrt_atexit.obj", "msvcrt_atexit.c"); auto objs = [ "msvcrt_stub0.obj", "msvcrt_stub1.obj", "msvcrt_stub2.obj", "msvcrt_data.obj", "msvcrt_atexit.obj" ]; if (!x64) { @@ -162,21 +179,14 @@ void buildMsvcrt(string outDir) } // merge into libs - const additionalMsvcrtObjs = objs.map!(a => `"` ~ outDir ~ a ~ `"`).join(" "); + const additionalMsvcrtObjs = objs.map!(a => quote(outDir ~ a)).join(" "); foreach (f; std.file.dirEntries(outDir[0 .. $-1], "*.lib", SpanMode.shallow)) { const lowerBase = toLower(baseName(f.name)); if (lowerBase.startsWith("msvcr") || lowerBase.startsWith("ucrtbase")) - runShell(lib ~ `"` ~ f.name ~ `" ` ~ additionalMsvcrtObjs); + runShell(`lib /MACHINE:` ~ (x64 ? "X64" : "X86") ~ ` "` ~ f.name ~ `" ` ~ additionalMsvcrtObjs); } - // create empty uuid.lib (expected by dmd, but UUIDs already in druntime) - std.file.write(outDir ~ "empty.c", ""); - runShell(cl ~ `"/Fo` ~ outDir ~ `uuid.obj" "` ~ outDir ~ `empty.c"`); - runShell(lib ~ `"/OUT:` ~ outDir ~ `uuid.lib" "` ~ outDir ~ `uuid.obj"`); - objs ~= "uuid.obj"; - std.file.remove(outDir ~ "empty.c"); - foreach (f; objs) std.file.remove(outDir ~ f); } @@ -196,15 +206,22 @@ void buildOldnames(string outDir) const src = buildPath(outDir, "oldnames.c"); std.file.write(src, oldnames_c); + c2lib(outDir, src); + std.file.remove(src); +} - const obj = setExtension(src, ".obj"); - runShell(`cl /c /Zl "/Fo` ~ obj ~ `" "` ~ src ~ `"`); - - const lib = setExtension(src, ".lib"); - runShell(`lib /MACHINE:` ~ (x64 ? "X64" : "X86") ~ ` "/OUT:` ~ lib ~ `" "` ~ obj ~ `"`); +void buildLegacyStdioDefinitions(string outDir) +{ + c2lib(outDir, "legacy_stdio_definitions.c"); +} +// create empty uuid.lib (expected by dmd, but UUIDs already in druntime) +void buildUuid(string outDir) +{ + const src = buildPath(outDir, "uuid.c"); + std.file.write(src, ""); + c2lib(outDir, src); std.file.remove(src); - std.file.remove(obj); } void main(string[] args) @@ -222,6 +239,8 @@ void main(string[] args) buildMsvcrt(outDir); buildOldnames(outDir); + buildLegacyStdioDefinitions(outDir); + buildUuid(outDir); //version (verbose) {} else foreach (f; std.file.dirEntries(outDir, "*.def", SpanMode.shallow)) diff --git a/windows/mingw/legacy_stdio_definitions.c b/windows/mingw/legacy_stdio_definitions.c new file mode 100644 index 00000000..5fdb517d --- /dev/null +++ b/windows/mingw/legacy_stdio_definitions.c @@ -0,0 +1,33 @@ +// VS 2015+ defines the printf/scanf function families inline. + +#include + +void __legacy_stdio_definitions() +{ + fprintf(NULL, NULL); + fscanf(NULL, NULL); + fwprintf(NULL, NULL); + fwscanf(NULL, NULL); + printf(NULL); + scanf(NULL); + snprintf(NULL, 0, NULL); + sprintf(NULL, NULL); + sscanf(NULL, NULL); + swprintf(NULL, 0, NULL); + swscanf(NULL, NULL); + vfprintf(NULL, NULL, NULL); + vfscanf(NULL, NULL, NULL); + vfwprintf(NULL, NULL, NULL); + vfwscanf(NULL, NULL, NULL); + vprintf(NULL, NULL); + vscanf(NULL, NULL); + vsnprintf(NULL, 0, NULL, NULL); + vsprintf(NULL, NULL, NULL); + vsscanf(NULL, NULL, NULL); + vswprintf(NULL, 0, NULL, NULL); + vswscanf(NULL, NULL, NULL); + vwprintf(NULL, NULL); + vwscanf(NULL, NULL); + wprintf(NULL); + wscanf(NULL); +} From 78bd057cb3e2d3dbc8f87368516614c37ec76881 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 25 Oct 2018 22:00:12 +0200 Subject: [PATCH 07/20] Refactor .def lines patching (prepare for .def.in patching) --- windows/mingw/buildsdk.d | 70 ++++++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 27 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index b566f257..fc8a84dc 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -41,6 +41,30 @@ void runShell(string cmd) } } +alias LineTransformer = string delegate(const string line); +string patchLines(string inFile, string outFile, LineTransformer lineTransformer) +{ + const lines = std.file.readText(inFile).splitLines; + + bool transformed = false; + const newLines = lines.map!((const string line) + { + const newLine = lineTransformer(line); + if (newLine !is line) + transformed = true; + return newLine; + }).array; + + if (!transformed) + return inFile; + + version (verbose) + writeln(`Patching file "` ~ inFile ~ `" to "` ~ outFile ~ `"`); + + std.file.write(outFile, newLines.join("\n")); + return outFile; +} + // Preprocesses a 'foo.def.in' file to 'foo.def'. void generateDef(string inFile, string outFile) { @@ -51,47 +75,39 @@ void generateDef(string inFile, string outFile) void sanitizeDef(string defFile) { - const lines = std.file.readText(defFile).splitLines; - - bool touched = false; - const newLines = lines.map!((const string line) + patchLines(defFile, defFile, (line) { - string l = line; - - if (l == "LIBRARY vcruntime140_app") - l = `LIBRARY "VCRUNTIME140.dll"`; + if (line == "LIBRARY vcruntime140_app") + return `LIBRARY "vcruntime140.dll"`; // The MinGW-w64 .def files specify weak external symbols as 'alias == realName'. - if (l.length > 1 && l[0] != ';') + if (line.length > 1 && line[0] != ';') { - const i = l.indexOf(" == "); + const i = line.indexOf(" == "); if (i > 0) { - const weakName = l[0 .. i]; - const realName = l[i+4 .. $]; - weakSymbols[weakName] = realName; - - l = ";" ~ l; + const weakName = line[0 .. i]; + const realName = line[i+4 .. $]; + + if (weakName.indexOf(' ') < 0 && realName.indexOf(' ') < 0) + { + weakSymbols[weakName] = realName; + return ";" ~ line; + } } } // Don't export function 'atexit'; we have our own in msvc_atexit.c. - if (l == "atexit" /* msvcr120 */ || l == "atexit DATA" /* < 120 */) - l = ""; + if (line == "atexit") + return ""; // Do export function '__chkstk' (ntdll.dll). // LLVM emits calls to it to detect stack overflows with '_alloca'. - if (l == ";__chkstk") - l = "__chkstk"; - - if (l !is line) - touched = true; - - return l; - }).array; + if (line == ";__chkstk") + return "__chkstk"; - if (touched) - std.file.write(defFile, newLines.join("\n")); + return line; + }); } void copyDefs(string inDir, string outDir) From 3473b0cfb06cf74adbc18ab3ce038aa3529417b4 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 23 Oct 2018 03:14:14 +0200 Subject: [PATCH 08/20] Fixup .def(.in) files to export functions replaced by the MinGW runtime --- windows/mingw/buildsdk.d | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index fc8a84dc..fe6e791e 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -68,9 +68,17 @@ string patchLines(string inFile, string outFile, LineTransformer lineTransformer // Preprocesses a 'foo.def.in' file to 'foo.def'. void generateDef(string inFile, string outFile) { - const includeDir = buildPath(dirName(dirName(inFile)), "def-include"); + const patchedInFile = outFile ~ ".in"; + const realInFile = patchLines(inFile, patchedInFile, (line) + { + // The MinGW-w64 .def.in files use 'F_X86_ANY(DATA)' to hide functions + // overridden by the MinGW runtime, primarily math functions. + return line.replace(" F_X86_ANY(DATA)", ""); + }); + + const includeDir = buildPath(inFile.dirName.dirName, "def-include"); const archDefine = x64 ? "DEF_X64" : "DEF_I386"; - runShell(`cl /EP /D` ~ archDefine ~ `=1 "/I` ~ includeDir ~ `" "` ~ inFile ~ `" > "` ~ outFile ~ `"`); + runShell(`cl /EP /D` ~ archDefine ~ `=1 "/I` ~ includeDir ~ `" "` ~ realInFile ~ `" > "` ~ outFile ~ `"`); } void sanitizeDef(string defFile) @@ -97,6 +105,15 @@ void sanitizeDef(string defFile) } } + // The MinGW runtime apparently replaces ceil(f)/floor(f) and hides the original functions via DATA. + if (line == "ceil DATA" || line == "ceilf DATA" || + line == "floor DATA" || line == "floorf DATA") + return line[0 .. $-5]; + + // MinGW apparently also replaces ucrtbase.dll's '_tzset'. + if (line == "_tzset DATA") + return "_tzset"; + // Don't export function 'atexit'; we have our own in msvc_atexit.c. if (line == "atexit") return ""; @@ -259,6 +276,6 @@ void main(string[] args) buildUuid(outDir); //version (verbose) {} else - foreach (f; std.file.dirEntries(outDir, "*.def", SpanMode.shallow)) + foreach (f; std.file.dirEntries(outDir, "*.def*", SpanMode.shallow)) std.file.remove(f.name); } From 00b00094706159b6c970b85643b1c2b2af5cdea5 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 26 Oct 2018 02:12:31 +0200 Subject: [PATCH 09/20] Compile extra MSVCRT objects separately for each DLL version --- windows/mingw/buildsdk.d | 60 +++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index fe6e791e..dc5a6482 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -16,7 +16,9 @@ import std.algorithm; import std.array; +import std.ascii : isDigit; import std.file; +import std.format : format; import std.path; import std.process; import std.stdio; @@ -196,32 +198,44 @@ void c2lib(string outDir, string cFile) void buildMsvcrt(string outDir) { - outDir ~= "/"; - - // compile some additional objects to be merged into the msvcr*.lib files - cl(outDir ~ "msvcrt_stub0.obj", "/D_APPTYPE=0 msvcrt_stub.c"); - cl(outDir ~ "msvcrt_stub1.obj", "/D_APPTYPE=1 msvcrt_stub.c"); - cl(outDir ~ "msvcrt_stub2.obj", "/D_APPTYPE=2 msvcrt_stub.c"); - cl(outDir ~ "msvcrt_data.obj", "msvcrt_data.c"); - cl(outDir ~ "msvcrt_atexit.obj", "msvcrt_atexit.c"); - auto objs = [ "msvcrt_stub0.obj", "msvcrt_stub1.obj", "msvcrt_stub2.obj", "msvcrt_data.obj", "msvcrt_atexit.obj" ]; - if (!x64) + const arch = x64 ? "X64" : "X86"; + foreach (lib; std.file.dirEntries(outDir, "*.lib", SpanMode.shallow)) { - runShell(`ml /c "/Fo` ~ outDir ~ `msvcrt_abs.obj" msvcrt_abs.asm`); - objs ~= "msvcrt_abs.obj"; - } + const lowerBase = toLower(baseName(lib.name)); + if (!(lowerBase.startsWith("msvcr") || lowerBase.startsWith("vcruntime"))) + continue; - // merge into libs - const additionalMsvcrtObjs = objs.map!(a => quote(outDir ~ a)).join(" "); - foreach (f; std.file.dirEntries(outDir[0 .. $-1], "*.lib", SpanMode.shallow)) - { - const lowerBase = toLower(baseName(f.name)); - if (lowerBase.startsWith("msvcr") || lowerBase.startsWith("ucrtbase")) - runShell(`lib /MACHINE:` ~ (x64 ? "X64" : "X86") ~ ` "` ~ f.name ~ `" ` ~ additionalMsvcrtObjs); - } + // parse version from filename (e.g., 140 for VC++ 2015) + const versionStart = lowerBase[0] == 'm' ? 5 : 9; + const versionLength = lowerBase[versionStart .. $].countUntil!(c => !isDigit(c)); + const msvcrtVersion = versionLength == 0 ? "0" : lowerBase[versionStart .. versionStart+versionLength]; + + string[] objs; + void addObj(string objFilename, string args) + { + const obj = buildPath(outDir, objFilename); + cl(obj, "/DMSVCRT_VERSION=" ~ msvcrtVersion ~ " " ~ args); + objs ~= obj; + } + + // compile some additional objects + foreach (i; 0 .. 3) + addObj(format!"msvcrt_stub%d.obj"(i), format!"/D_APPTYPE=%d msvcrt_stub.c"(i)); + addObj("msvcrt_data.obj", "msvcrt_data.c"); + addObj("msvcrt_atexit.obj", "msvcrt_atexit.c"); + if (!x64) + { + const obj = buildPath(outDir, "msvcrt_abs.obj"); + runShell(`ml /c "/Fo` ~ obj ~ `" msvcrt_abs.asm`); + objs ~= obj; + } + + // merge them into the library + runShell(`lib /MACHINE:` ~ arch ~ ` "` ~ lib.name ~ `" ` ~ objs.map!quote.join(" ")); - foreach (f; objs) - std.file.remove(outDir ~ f); + foreach (obj; objs) + std.file.remove(obj); + } } void buildOldnames(string outDir) From c3f360c5c99507bb606b5c589a9090c6e0c334bf Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Fri, 26 Oct 2018 01:17:01 +0200 Subject: [PATCH 10/20] Add UCRT support for MSVCRT C stub files Seems to be working fine for Win64 and LDC, based on a hello-world console app. --- windows/mingw/legacy_stdio_definitions.c | 4 ++ windows/mingw/msvcrt_data.c | 29 ++++++++++--- windows/mingw/msvcrt_stub.c | 52 ++++++++++++++++++------ 3 files changed, 68 insertions(+), 17 deletions(-) diff --git a/windows/mingw/legacy_stdio_definitions.c b/windows/mingw/legacy_stdio_definitions.c index 5fdb517d..5800c2a7 100644 --- a/windows/mingw/legacy_stdio_definitions.c +++ b/windows/mingw/legacy_stdio_definitions.c @@ -1,5 +1,9 @@ // VS 2015+ defines the printf/scanf function families inline. +#if _MSC_VER < 1900 +#error Requires Visual C++ 2015 or newer +#endif + #include void __legacy_stdio_definitions() diff --git a/windows/mingw/msvcrt_data.c b/windows/mingw/msvcrt_data.c index 5fe00535..73fdb3b2 100644 --- a/windows/mingw/msvcrt_data.c +++ b/windows/mingw/msvcrt_data.c @@ -5,8 +5,11 @@ ULONG _tls_index = 0; +#if MSVCRT_VERSION < 140 #pragma section(".tls$AAA") #pragma section(".tls$ZZZ") +#endif + #pragma section(".CRT$XLA", long, read) #pragma section(".CRT$XLZ", long, read) #pragma section(".CRT$XIA", long, read) @@ -21,10 +24,30 @@ ULONG _tls_index = 0; #pragma comment(linker, "/merge:.CRT=.rdata") +#if MSVCRT_VERSION >= 140 // UCRT + +#pragma data_seg(".tls") +#ifdef _M_X64 +_CRTALLOC(".tls") +#endif +char _tls_start = 0; + +#pragma data_seg(".tls$ZZZ") +#ifdef _M_X64 +_CRTALLOC(".tls$ZZZ") +#endif /* defined (_M_X64) */ +char _tls_end = 0; + +#pragma data_seg() + +#else // MSVCRT_VERSION < 140 + /* TLS raw template data start and end. */ _CRTALLOC(".tls$AAA") int _tls_start = 0; _CRTALLOC(".tls$ZZZ") int _tls_end = 0; +#endif + // TLS init/exit callbacks _CRTALLOC(".CRT$XLA") PIMAGE_TLS_CALLBACK __xl_a = 0; _CRTALLOC(".CRT$XLZ") PIMAGE_TLS_CALLBACK __xl_z = 0; @@ -54,8 +77,4 @@ _CRTALLOC(".CRT$XPZ") _PVFV __xp_z[] = { NULL }; _CRTALLOC(".CRT$XTA") _PVFV __xt_a[] = { NULL }; _CRTALLOC(".CRT$XTZ") _PVFV __xt_z[] = { NULL }; -char _fltused; - -int _argc = 0; -char **_argv = NULL; - +int _fltused = 0x9875; diff --git a/windows/mingw/msvcrt_stub.c b/windows/mingw/msvcrt_stub.c index 152c9a00..051ca202 100644 --- a/windows/mingw/msvcrt_stub.c +++ b/windows/mingw/msvcrt_stub.c @@ -1,7 +1,5 @@ #include -#define _CRTALLOC(x) __declspec(allocate(x)) - #define __UNKNOWN_APP 0 // abused for DLL #define __CONSOLE_APP 1 #define __GUI_APP 2 @@ -35,8 +33,12 @@ extern int __ref_oldnames; #pragma comment(lib, "kernel32.lib") #pragma comment(lib, "oldnames.lib") +#if MSVCRT_VERSION >= 140 +#pragma comment(lib, "ucrtbase.lib") +#endif #if _APPTYPE == __UNKNOWN_APP + BOOL WINAPI DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) { @@ -61,8 +63,24 @@ DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) #else // _APPTYPE != __UNKNOWN_APP -extern int _argc; -extern char **_argv; +extern int __argc; +extern char **__argv; + +#if MSVCRT_VERSION >= 140 // UCRT + +enum _crt_argv_mode +{ + _crt_argv_no_arguments, + _crt_argv_unexpanded_arguments, + _crt_argv_expanded_arguments, +}; + +extern int _initialize_narrow_environment(); +extern char **_get_initial_narrow_environment(); +extern int _configure_narrow_argv(int); +extern char *_get_narrow_winmain_command_line(); + +#else // MSVCRT_VERSION < 140 /* In MSVCRT.DLL, Microsoft's initialization hook is called __getmainargs(), * and it expects a further structure argument, (which we don't use, but pass @@ -71,6 +89,8 @@ extern char **_argv; typedef struct _startupinfo { int mode; } _startupinfo; extern void __getmainargs( int *argc, char ***argv, char ***penv, int glob, _startupinfo *info ); +#endif + /* The function mainCRTStartup() is the entry point for all * console/desktop programs. */ @@ -80,29 +100,39 @@ void mainCRTStartup(void) void WinMainCRTStartup(void) #endif { - int nRet, xRet; + int nRet; __set_app_type(_APPTYPE); __ref_oldnames = 0; // drag in alternate definitions +#if MSVCRT_VERSION >= 140 // UCRT + _configure_narrow_argv(_crt_argv_unexpanded_arguments); + _initialize_narrow_environment(); + char **envp = _get_initial_narrow_environment(); +#else /* The MSVCRT.DLL start-up hook requires this invocation * protocol... */ char **envp = NULL; _startupinfo start_info = { 0 }; - __getmainargs(&_argc, &_argv, &envp, 0, &start_info); + __getmainargs(&__argc, &__argv, &envp, 0, &start_info); +#endif - _initterm(__xi_a, __xi_z); + _initterm_e(__xi_a, __xi_z); _initterm(__xc_a, __xc_z); #if _APPTYPE == __CONSOLE_APP - nRet = main(_argc, _argv, envp); + nRet = main(__argc, __argv, envp); #else { STARTUPINFOA startupInfo; GetStartupInfoA(&startupInfo); int showWindowMode = startupInfo.dwFlags & STARTF_USESHOWWINDOW ? startupInfo.wShowWindow : SW_SHOWDEFAULT; - PCSTR lpszCommandLine = GetCommandLineA(); +#if MSVCRT_VERSION >= 140 // UCRT + LPSTR lpszCommandLine = _get_narrow_winmain_command_line(); +#else + LPSTR lpszCommandLine = GetCommandLineA(); +#endif nRet = WinMain((HINSTANCE)&__ImageBase, NULL, lpszCommandLine, showWindowMode); } #endif @@ -111,9 +141,7 @@ void WinMainCRTStartup(void) _initterm(__xp_a, __xp_z); _initterm(__xt_a, __xt_z); - if (nRet == 0) - nRet = xRet; - ExitProcess(nRet); } + #endif // _APPTYPE != __UNKNOWN_APP From 09713e7775139b44ee6e9d4cc1ad85caf4e04b43 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 27 Oct 2018 00:02:08 +0200 Subject: [PATCH 11/20] Remove LDC-specific __chkstk workaround That symbol is available in LLVM's builtins compiler-rt library, so no need to export it and link with ntdll.dll anymore. --- windows/mingw/buildsdk.d | 5 ----- 1 file changed, 5 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index dc5a6482..443182c2 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -120,11 +120,6 @@ void sanitizeDef(string defFile) if (line == "atexit") return ""; - // Do export function '__chkstk' (ntdll.dll). - // LLVM emits calls to it to detect stack overflows with '_alloca'. - if (line == ";__chkstk") - return "__chkstk"; - return line; }); } From dbd516276c355dcb46b74818927f33e6f1bc20ea Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sat, 27 Oct 2018 18:28:55 +0200 Subject: [PATCH 12/20] Restore stdcall-stripping for 32-bit import libs This has gotten messy, as some .defs feature stdcall-mangled functions as well as C++ ones, and some hide stdcall-mangled functions via `DATA` suffix, so that we have to handle global variables with `@` characters etc. I switched from C to D, as `pragma(mangle)` is a big help when dealing with arbitrary identifiers. --- windows/mingw/buildsdk.d | 148 +++++++++++++++++++++++++++++++++++---- 1 file changed, 135 insertions(+), 13 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 443182c2..8b87b2d8 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -10,7 +10,7 @@ // source files extracted from MinGW-w64: // https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v6.0.0.tar.bz2 // -// assumes VC tools cl, lib and ml installed and found through path +// assumes dmd & VC tools cl, lib, link and ml installed and found through path // and configured to the appropriate architecture // @@ -87,23 +87,23 @@ void sanitizeDef(string defFile) { patchLines(defFile, defFile, (line) { + if (line.length == 0 || line[0] == ';') + return line; + if (line == "LIBRARY vcruntime140_app") return `LIBRARY "vcruntime140.dll"`; // The MinGW-w64 .def files specify weak external symbols as 'alias == realName'. - if (line.length > 1 && line[0] != ';') + const i = line.indexOf("=="); + if (i > 0) { - const i = line.indexOf(" == "); - if (i > 0) + const weakName = strip(line[0 .. i]); + const realName = strip(line[i+2 .. $]); + + if (weakName.indexOf(' ') < 0 && realName.indexOf(' ') < 0) { - const weakName = line[0 .. i]; - const realName = line[i+4 .. $]; - - if (weakName.indexOf(' ') < 0 && realName.indexOf(' ') < 0) - { - weakSymbols[weakName] = realName; - return ";" ~ line; - } + weakSymbols[weakName] = realName; + return ";" ~ line; } } @@ -118,7 +118,11 @@ void sanitizeDef(string defFile) // Don't export function 'atexit'; we have our own in msvc_atexit.c. if (line == "atexit") - return ""; + return ";atexit"; + + // An apparent bug in lib32/shell32.def (there's 'ExtractIconW@12' too). + if (line == "ExtractIconW@") + return ";ExtractIconW@"; return line; }); @@ -156,6 +160,12 @@ void copyDefs(string inDir, string outDir) void def2implib(string defFile) { + if (!x64) + { + if (defWithStdcallMangling2implib(defFile)) + return; + } + const libFile = setExtension(defFile, ".lib"); const arch = x64 ? "X64" : "X86"; runShell(`lib /MACHINE:` ~ arch ~ ` "/DEF:` ~ defFile ~ `" "/OUT:` ~ libFile ~ `"`); @@ -182,6 +192,118 @@ string quote(string arg) return `"` ~ arg ~ `"`; } +/** + * x86: the WinAPI symbol names in the .def files are stdcall-mangled + * (trailing `@`). These mangled names are required in the import + * library, but the names of the DLL exports don't feature the stdcall + * suffix. + * `lib /DEF` doesn't support the required renaming functionality, so + * we have to go through compiling a D file with the symbols and + * building a DLL with renamed exports to get the appropriate import + * library. + */ +bool defWithStdcallMangling2implib(string defFile) +{ + import std.regex : ctRegex, matchFirst; + + string[] functions; + string[] fields; + bool hasRenamedStdcall = false; + + patchLines(defFile, defFile, (line) + { + if (line.length == 0 || line[0] == ';' || + line.startsWith("LIBRARY ") || line.startsWith("EXPORTS")) + return line; + + if (line.endsWith(" DATA")) + { + fields ~= line[0 .. $-5]; + return line; + } + + // include fastcall mangle (like stdcall, with additional leading '@') + enum re = ctRegex!r"^@?([a-zA-Z0-9_]+)(@[0-9]+)"; + if (const m = matchFirst(line, re)) + { + string lineSuffix = line[m[0].length .. $]; + if (lineSuffix.startsWith(m[2])) // e.g., 'JetAddColumnA@28@28' + { + /** + * Actually not to be renamed, symbol is exported in mangled form. + * Treat it like 'JetAddColumnA@28' though, because some libraries + * export the same function as both 'JetAddColumnA' and 'JetAddColumnA@28', + * and I don't know how to replicate that with our approach. + */ + lineSuffix = lineSuffix[m[2].length .. $]; + } + + assert(!lineSuffix.startsWith("=")); // renamings not supported + + hasRenamedStdcall = true; + functions ~= m[1]; + // keep the line suffix (e.g., ' @100' => ordinal 100) + return m[0] ~ "=" ~ m[1] ~ lineSuffix; + } + + const firstSpaceIndex = line.indexOf(' '); + const strippedLine = firstSpaceIndex < 0 ? line : line[0 .. firstSpaceIndex]; + const equalsIndex = strippedLine.indexOf('='); + const functionName = equalsIndex > 0 ? strippedLine[equalsIndex+1 .. $] : strippedLine; + functions ~= functionName; + return line; + }); + + if (!hasRenamedStdcall) + return false; + + string src = "module dummy;\n"; + alias Emitter = string delegate(); + void emitOnce(ref bool[string] emittedSymbols, string symbolName, Emitter emitter) + { + if (symbolName !in emittedSymbols) + { + src ~= emitter() ~ "\n"; + emittedSymbols[symbolName] = true; + } + } + + bool[string] emittedFunctions; + foreach (i, name; functions) + { + emitOnce(emittedFunctions, name, () + { + const linkage = name[0] == '?' ? "C++" : "C"; + return `pragma(mangle, "%s") extern(%s) void func%d() {}`.format(name, linkage, i); + }); + } + + bool[string] emittedFields; + foreach (i, name; fields) + { + emitOnce(emittedFields, name, () + { + const linkage = name[0] == '_' ? "C" : "C++"; + return `pragma(mangle, "%s") extern(%s) __gshared int field%d;`.format(name, linkage, i); + }); + } + + const dFile = setExtension(defFile, ".d"); + const objFile = setExtension(defFile, ".obj"); + const dllFile = setExtension(defFile, ".dll"); + + std.file.write(dFile, src); + runShell(`dmd -c -betterC -m32mscoff "-of=` ~ objFile ~ `" ` ~ quote(dFile)); + runShell("link /NOD /NOENTRY /DLL " ~ quote(objFile) ~ ` "/OUT:` ~ dllFile ~ `" "/DEF:` ~ defFile ~ `"`); + + std.file.remove(dFile); + std.file.remove(objFile); + std.file.remove(dllFile); + std.file.remove(setExtension(dllFile, ".exp")); + + return true; +} + void c2lib(string outDir, string cFile) { const obj = buildPath(outDir, baseName(cFile).setExtension(".obj")); From 34de11e8975cd75f6fab8f07ba0487f0c2b54876 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 28 Oct 2018 15:16:32 +0100 Subject: [PATCH 13/20] Assemble msvcrt_abs.asm with /safeseh option To prevent having to link with `/SAFESEH:NO`. --- windows/mingw/buildsdk.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 8b87b2d8..ba3c74bb 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -343,7 +343,7 @@ void buildMsvcrt(string outDir) if (!x64) { const obj = buildPath(outDir, "msvcrt_abs.obj"); - runShell(`ml /c "/Fo` ~ obj ~ `" msvcrt_abs.asm`); + runShell(`ml /c /safeseh "/Fo` ~ obj ~ `" msvcrt_abs.asm`); objs ~= obj; } From ab3a7c0184c7e526691d1c0760a4fb99f7cd7529 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Sun, 28 Oct 2018 16:57:27 +0100 Subject: [PATCH 14/20] msvcrt_data.c: Add special load-config struct Containing the information displayed by `dumpbin /loadconfig`. Seems to be required when generating a safe-EH compatible binary (32-bit only). --- windows/mingw/msvcrt_data.c | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/windows/mingw/msvcrt_data.c b/windows/mingw/msvcrt_data.c index 73fdb3b2..e9422bfa 100644 --- a/windows/mingw/msvcrt_data.c +++ b/windows/mingw/msvcrt_data.c @@ -78,3 +78,44 @@ _CRTALLOC(".CRT$XTA") _PVFV __xt_a[] = { NULL }; _CRTALLOC(".CRT$XTZ") _PVFV __xt_z[] = { NULL }; int _fltused = 0x9875; + +#ifdef _M_IX86 +// magic linker symbols available if the binary has a safe exception table +// (implicit if all object files are safe-EH compatible) +extern PVOID __safe_se_handler_table[]; +extern BYTE __safe_se_handler_count; +#endif + +const DECLSPEC_SELECTANY IMAGE_LOAD_CONFIG_DIRECTORY _load_config_used = +{ + sizeof(_load_config_used), + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, +#ifdef _M_IX86 + (SIZE_T) __safe_se_handler_table, + (SIZE_T) &__safe_se_handler_count, +#else + 0, + 0, +#endif + 0, + 0, + 0, + 0, + 0, +}; From bace73e0cfbf1dd2865ee71b411c2a40f4b9c6fc Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 1 Nov 2018 18:12:32 +0100 Subject: [PATCH 15/20] Generate special vfw32.lib --- windows/mingw/buildsdk.d | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index ba3c74bb..9d6798e0 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -1,5 +1,5 @@ // -// Convert MingGW-w64 definition files to COFF import librries +// Convert MingGW-w64 definition files to COFF import libraries // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -167,8 +167,7 @@ void def2implib(string defFile) } const libFile = setExtension(defFile, ".lib"); - const arch = x64 ? "X64" : "X86"; - runShell(`lib /MACHINE:` ~ arch ~ ` "/DEF:` ~ defFile ~ `" "/OUT:` ~ libFile ~ `"`); + runShell(`lib "/DEF:` ~ defFile ~ `" "/OUT:` ~ libFile ~ `"`); std.file.remove(setExtension(defFile, ".exp")); } @@ -309,13 +308,12 @@ void c2lib(string outDir, string cFile) const obj = buildPath(outDir, baseName(cFile).setExtension(".obj")); const lib = setExtension(obj, ".lib"); cl(obj, quote(cFile)); - runShell(`lib /MACHINE:` ~ (x64 ? "X64" : "X86") ~ ` "/OUT:` ~ lib ~ `" "` ~ obj ~ `"`); + runShell(`lib "/OUT:` ~ lib ~ `" ` ~ quote(obj)); std.file.remove(obj); } void buildMsvcrt(string outDir) { - const arch = x64 ? "X64" : "X86"; foreach (lib; std.file.dirEntries(outDir, "*.lib", SpanMode.shallow)) { const lowerBase = toLower(baseName(lib.name)); @@ -348,7 +346,7 @@ void buildMsvcrt(string outDir) } // merge them into the library - runShell(`lib /MACHINE:` ~ arch ~ ` "` ~ lib.name ~ `" ` ~ objs.map!quote.join(" ")); + runShell("lib " ~ quote(lib.name) ~ " " ~ objs.map!quote.join(" ")); foreach (obj; objs) std.file.remove(obj); @@ -388,6 +386,14 @@ void buildUuid(string outDir) std.file.remove(src); } +// vfw32.lib is a merge of 3 other libs +void buildVfw32(string outDir) +{ + auto srcLibs = [ "msvfw32", "avicap32", "avifil32" ].map!(name => buildPath(outDir, name ~ ".lib")); + const outLib = buildPath(outDir, "vfw32.lib"); + runShell(`lib "/OUT:` ~ outLib ~ `" ` ~ srcLibs.map!quote.join(" ")); +} + void main(string[] args) { x64 = (args.length > 1 && args[1] == "x64"); @@ -405,6 +411,7 @@ void main(string[] args) buildOldnames(outDir); buildLegacyStdioDefinitions(outDir); buildUuid(outDir); + buildVfw32(outDir); //version (verbose) {} else foreach (f; std.file.dirEntries(outDir, "*.def*", SpanMode.shallow)) From b8e8e73f19e7f6bef3af2d3ec785bed43703def5 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 1 Nov 2018 18:34:22 +0100 Subject: [PATCH 16/20] Rename msvcr.lib to msvcrt.lib as expected by DMD --- windows/mingw/buildsdk.d | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 9d6798e0..5a7fcf7e 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -323,7 +323,9 @@ void buildMsvcrt(string outDir) // parse version from filename (e.g., 140 for VC++ 2015) const versionStart = lowerBase[0] == 'm' ? 5 : 9; const versionLength = lowerBase[versionStart .. $].countUntil!(c => !isDigit(c)); - const msvcrtVersion = versionLength == 0 ? "0" : lowerBase[versionStart .. versionStart+versionLength]; + const msvcrtVersion = versionLength == 0 + ? "70" // msvcrt.lib + : lowerBase[versionStart .. versionStart+versionLength]; string[] objs; void addObj(string objFilename, string args) @@ -413,6 +415,18 @@ void main(string[] args) buildUuid(outDir); buildVfw32(outDir); + // rename msvcr.lib to msvcrt.lib as expected by DMD + foreach (lib; std.file.dirEntries(outDir, "msvcr*.lib", SpanMode.shallow)) + { + const base = baseName(lib.name); + if (!isDigit(base[5])) // msvcrt.lib + continue; + const newName = buildPath(outDir, "msvcrt" ~ base[5 .. $]); + version (verbose) + writefln("Renaming '%s' to '%s'", lib.name, newName); + std.file.rename(lib.name, newName); + } + //version (verbose) {} else foreach (f; std.file.dirEntries(outDir, "*.def*", SpanMode.shallow)) std.file.remove(f.name); From 5b6c311a2111e2582bdb8efcbe9ace69e5072836 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 1 Nov 2018 20:17:10 +0100 Subject: [PATCH 17/20] Un-hide more functions overridden by the MinGW runtime Specifically tailored for ucrtbase.def (LDC) and msvcr100.def (DMD). This list has been generated by side-by-side diffing the final patched .def file and the .def file auto-generated by MinGW-w64's gendef tool. --- windows/mingw/buildsdk.d | 54 +++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 5a7fcf7e..b30bbc4c 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -85,9 +85,47 @@ void generateDef(string inFile, string outFile) void sanitizeDef(string defFile) { + // The MinGW runtime overrides some functions and hides the original + // functions by appending a ' DATA' suffix in the .def files. + static __gshared const overriddenMinGWFunctions = + [ + // ucrtbase.def: + "_assert", "_cabs", "_fpreset", "_tzset", + "ceil", "ceilf", "coshf", "fabs", + "floor", "floorf", "modf", "modff", + "sinhf", "sqrt", "sqrtf", "wcsnlen", + // additional ones in msvcr100.def: + "__report_gsfailure", + "_byteswap_uint64", "_byteswap_ulong", "_byteswap_ushort", + "_difftime32", "_difftime64", + "_fseeki64", "_ftelli64", + "_get_errno", + "_rotl64", "_rotr64", + "_set_errno", + "_wassert", + "acosf", "asinf", "atan2", "atan2f", "atanf", + "btowc", + "cos", "cosf", "exp", "expf", "fmod", "fmodf", "ldexp", + "longjmp", + "llabs", "lldiv", + "log", "log10f", "logf", + "mbrlen", "mbrtowc", "mbsrtowcs", + "pow", "powf", + "sin", "sinf", + "strnlen", + "tanf", "tanhf", + "wcrtomb", "wcsrtombs", "wctob", + ]; + patchLines(defFile, defFile, (line) { - if (line.length == 0 || line[0] == ';') + if (line.length == 0) + return line; + + if (line == "; strnlen replaced by emu") + return "strnlen"; + + if (line[0] == ';') return line; if (line == "LIBRARY vcruntime140_app") @@ -107,14 +145,12 @@ void sanitizeDef(string defFile) } } - // The MinGW runtime apparently replaces ceil(f)/floor(f) and hides the original functions via DATA. - if (line == "ceil DATA" || line == "ceilf DATA" || - line == "floor DATA" || line == "floorf DATA") - return line[0 .. $-5]; - - // MinGW apparently also replaces ucrtbase.dll's '_tzset'. - if (line == "_tzset DATA") - return "_tzset"; + // Un-hide functions overridden by the MinGW runtime. + foreach (name; overriddenMinGWFunctions) + { + if (line.length == name.length + 5 && line.startsWith(name) && line.endsWith(" DATA")) + return name; + } // Don't export function 'atexit'; we have our own in msvc_atexit.c. if (line == "atexit") From 97ffed0a796131cff3007a84c5553fb2e45629c8 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Tue, 6 Nov 2018 23:25:07 +0100 Subject: [PATCH 18/20] Complete oldnames.lib The oldnames.list file has been generated by dumping the VS 2015 oldnames.lib symbols (`dumpbin /symbols`). These aliases are added to or replace aliases defined in the MinGW-w64 .def files (`alias == realName`). I checked the 32- and 64-bit libs; they are identical and only differ wrt. symbol mangling. --- windows/mingw/buildsdk.d | 39 +++++- windows/mingw/oldnames.list | 228 ++++++++++++++++++++++++++++++++++++ 2 files changed, 265 insertions(+), 2 deletions(-) create mode 100644 windows/mingw/oldnames.list diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index b30bbc4c..4238a657 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -393,12 +393,47 @@ void buildMsvcrt(string outDir) void buildOldnames(string outDir) { - const cPrefix = x64 ? "" : "_"; + static string prependUnderscore(string symbolName) + { + return symbolName.startsWith("__imp_") + ? symbolName[0 .. 6] ~ "_" ~ symbolName[6 .. $] // __imp_name => __imp__name + : "_" ~ symbolName; // name => _name + } + + const lines = std.file.readText("oldnames.list").splitLines; + foreach (line; lines) + { + if (line.length == 0) + continue; + + string weakName; + string realName; + + const equalsIndex = line.indexOf('='); + if (equalsIndex > 0) + { + weakName = line[0 .. equalsIndex]; + realName = line[equalsIndex+1 .. $]; + } + else // most real names just feature an additional leading underscore + { + weakName = line; + realName = prependUnderscore(weakName); + } + + weakSymbols[weakName] = realName; + } + + static string getMangledName(string symbolName) + { + return x64 ? symbolName : prependUnderscore(symbolName); + } + const oldnames_c = // access this __ref_oldnames symbol to drag in the generated linker directives (msvcrt_stub.c) "int __ref_oldnames;\n" ~ weakSymbols.byKeyValue.map!(pair => - `__pragma(comment(linker, "/alternatename:` ~ cPrefix ~ pair.key ~ `=` ~ cPrefix ~ pair.value ~ `"));` + `__pragma(comment(linker, "/alternatename:` ~ getMangledName(pair.key) ~ `=` ~ getMangledName(pair.value) ~ `"));` ).join("\n"); version (verbose) diff --git a/windows/mingw/oldnames.list b/windows/mingw/oldnames.list new file mode 100644 index 00000000..513f6547 --- /dev/null +++ b/windows/mingw/oldnames.list @@ -0,0 +1,228 @@ +__imp_utime=__imp__utime32 +utime=_utime32 +__imp_ftime=__imp__ftime32 +ftime=_ftime32 +__imp_stat=__imp__stat32 +stat=_stat32 +__imp_fstat=__imp__fstat32 +fstat=_fstat32 +__imp_fcloseall +fcloseall +__imp_control87 +control87 +__imp_sys_errlist +sys_errlist +__imp_filelength +filelength +__imp_strcmpi=__imp__stricmp +strcmpi=_stricmp +__imp_wcsicoll +__imp_wcsupr +__imp_wcslwr +__imp_wcsset +__imp_wcsrev +__imp_wcsnset +__imp_wcsnicmp +__imp_wcsicmp +__imp_wcsdup +__imp_dup +__imp_tzset +__imp_tzname +__imp_timezone +__imp_strupr +__imp_strset +__imp_strrev +__imp_strnset +__imp_strnicmp +__imp_strlwr +__imp_strdup +__imp_stricmp +__imp_tempnam +__imp_rmtmp +__imp_putw +__imp_getw +__imp_fputchar +__imp_flushall +__imp_fileno +__imp_fgetchar +__imp_fdopen +__imp_ultoa +__imp_swab +__imp_putenv +__imp_onexit +__imp_ltoa +__imp_itoa +__imp_yn +__imp_y1 +__imp_y0 +__imp_jn +__imp_j1 +__imp_j0 +__imp_cabs +__imp_HUGE +__imp_gcvt +__imp_fcvt +__imp_ecvt +__imp_lsearch +__imp_lfind +__imp_spawnvpe +__imp_spawnvp +__imp_spawnve +__imp_spawnv +__imp_spawnlpe +__imp_spawnlp +__imp_spawnle +__imp_spawnl +__imp_getpid +__imp_execvpe +__imp_execvp +__imp_execve +__imp_execv +__imp_execlpe +__imp_execlp +__imp_execle +__imp_execl +__imp_cwait +__imp_memicmp +__imp_memccpy +__imp_write +__imp_unlink +__imp_umask +__imp_tell +__imp_sys_nerr +__imp_sopen +__imp_setmode +__imp_read +__imp_open +__imp_mktemp +__imp_lseek +__imp_locking +__imp_isatty +__imp_eof +__imp_dup2 +__imp_creat +__imp_close +__imp_chsize +__imp_chmod +__imp_access +__imp_rmdir +__imp_mkdir +__imp_getcwd +__imp_chdir +__imp_ungetch +__imp_putch +__imp_kbhit +__imp_getche +__imp_fpreset +__imp_getch +__imp_environ +__imp_daylight +__imp_cscanf +__imp_cputs +__imp_cprintf +__imp_cgets +wcsicoll +wcsupr +wcslwr +wcsset +wcsrev +wcsnset +wcsnicmp +wcsicmp +wcsdup +dup +tzset +tzname +timezone +strupr +strset +strrev +strnset +strnicmp +strlwr +strdup +stricmp +tempnam +rmtmp +putw +getw +fputchar +flushall +fileno +fgetchar +fdopen +ultoa +swab +putenv +onexit +ltoa +itoa +yn +y1 +y0 +jn +j1 +j0 +cabs +HUGE +gcvt +fcvt +ecvt +lsearch +lfind +spawnvpe +spawnvp +spawnve +spawnv +spawnlpe +spawnlp +spawnle +spawnl +getpid +execvpe +execvp +execve +execv +execlpe +execlp +execle +execl +cwait +memicmp +memccpy +write +unlink +umask +tell +sys_nerr +sopen +setmode +read +open +mktemp +lseek +locking +isatty +eof +dup2 +creat +close +chsize +chmod +access +rmdir +mkdir +getcwd +chdir +ungetch +putch +kbhit +getche +fpreset +getch +environ +daylight +cscanf +cputs +cprintf +cgets From bf5be117054a8f6c206d22082c8aca7dbae8aea7 Mon Sep 17 00:00:00 2001 From: Martin Kinkelin Date: Thu, 8 Nov 2018 21:36:24 +0100 Subject: [PATCH 19/20] Change approach for weak symbols Ignore the aliases in the MinGW-w64 .def files altogether; they are not just incomplete, but sometimes also wrong (e.g., https://github.com/ldc-developers/ldc/issues/2903; there were more of these after I checked against msvcrt.lib). I decided to write a little tool to extract these aliases from the MS libs. The resulting output for VS 2015 oldnames.lib and msvcrt.lib is included (as well as the tool) as input files for the generated linker directives in oldnames.lib. --- windows/mingw/buildsdk.d | 54 ++---- windows/mingw/extractAliases.d | 53 ++++++ windows/mingw/msvcrt140.aliases32 | 277 ++++++++++++++++++++++++++++++ windows/mingw/msvcrt140.aliases64 | 275 +++++++++++++++++++++++++++++ windows/mingw/msvcrt_stub.c | 6 + windows/mingw/oldnames.aliases32 | 229 ++++++++++++++++++++++++ windows/mingw/oldnames.aliases64 | 229 ++++++++++++++++++++++++ windows/mingw/oldnames.list | 228 ------------------------ 8 files changed, 1088 insertions(+), 263 deletions(-) create mode 100644 windows/mingw/extractAliases.d create mode 100644 windows/mingw/msvcrt140.aliases32 create mode 100644 windows/mingw/msvcrt140.aliases64 create mode 100644 windows/mingw/oldnames.aliases32 create mode 100644 windows/mingw/oldnames.aliases64 delete mode 100644 windows/mingw/oldnames.list diff --git a/windows/mingw/buildsdk.d b/windows/mingw/buildsdk.d index 4238a657..dd6ff5f6 100644 --- a/windows/mingw/buildsdk.d +++ b/windows/mingw/buildsdk.d @@ -27,7 +27,6 @@ import std.string; version = verbose; bool x64; -string[string] weakSymbols; // weak name => real name void runShell(string cmd) @@ -132,6 +131,7 @@ void sanitizeDef(string defFile) return `LIBRARY "vcruntime140.dll"`; // The MinGW-w64 .def files specify weak external symbols as 'alias == realName'. + // Just ignore them; they are incomplete and sometimes wrong. const i = line.indexOf("=="); if (i > 0) { @@ -139,10 +139,7 @@ void sanitizeDef(string defFile) const realName = strip(line[i+2 .. $]); if (weakName.indexOf(' ') < 0 && realName.indexOf(' ') < 0) - { - weakSymbols[weakName] = realName; return ";" ~ line; - } } // Un-hide functions overridden by the MinGW runtime. @@ -393,47 +390,34 @@ void buildMsvcrt(string outDir) void buildOldnames(string outDir) { - static string prependUnderscore(string symbolName) - { - return symbolName.startsWith("__imp_") - ? symbolName[0 .. 6] ~ "_" ~ symbolName[6 .. $] // __imp_name => __imp__name - : "_" ~ symbolName; // name => _name - } + static struct WeakSymbol { string name; string targetName; } + WeakSymbol[] weakSymbols; - const lines = std.file.readText("oldnames.list").splitLines; - foreach (line; lines) + void processAliasesFile(string path) { - if (line.length == 0) - continue; + foreach (line; std.file.readText(path).splitLines) + { + if (line.length == 0 || line[0] == ';') + continue; - string weakName; - string realName; + const equalsIndex = line.indexOf('='); + const weakName = line[0 .. equalsIndex]; + const realName = line[equalsIndex+1 .. $]; - const equalsIndex = line.indexOf('='); - if (equalsIndex > 0) - { - weakName = line[0 .. equalsIndex]; - realName = line[equalsIndex+1 .. $]; - } - else // most real names just feature an additional leading underscore - { - weakName = line; - realName = prependUnderscore(weakName); + weakSymbols ~= WeakSymbol(weakName, realName); } - - weakSymbols[weakName] = realName; } - static string getMangledName(string symbolName) - { - return x64 ? symbolName : prependUnderscore(symbolName); - } + const suffix = x64 ? "64" : "32"; + processAliasesFile("oldnames.aliases" ~ suffix); + // include the weak symbols from msvcrt.lib too + processAliasesFile("msvcrt140.aliases" ~ suffix); const oldnames_c = - // access this __ref_oldnames symbol to drag in the generated linker directives (msvcrt_stub.c) + // access this __ref_oldnames symbol (in msvcrt_stub.c) to drag in the generated linker directives "int __ref_oldnames;\n" ~ - weakSymbols.byKeyValue.map!(pair => - `__pragma(comment(linker, "/alternatename:` ~ getMangledName(pair.key) ~ `=` ~ getMangledName(pair.value) ~ `"));` + weakSymbols.map!(sym => + `__pragma(comment(linker, "/alternatename:` ~ sym.name ~ `=` ~ sym.targetName ~ `"));` ).join("\n"); version (verbose) diff --git a/windows/mingw/extractAliases.d b/windows/mingw/extractAliases.d new file mode 100644 index 00000000..f98c1d5e --- /dev/null +++ b/windows/mingw/extractAliases.d @@ -0,0 +1,53 @@ +import std.file; +import std.process; +import std.stdio; +import std.string; + +string untilFirstSpace(string str) +{ + const spaceIndex = str.indexOf(' '); + return spaceIndex < 0 ? str : str[0 .. spaceIndex]; +} + +int main(string[] args) +{ + if (args.length != 2) + { + writefln("Usage: %s ", args[0]); + return 1; + } + + const command = `dumpbin /symbols "` ~ args[1] ~ `"`; + const result = executeShell(command); + if (result.status) + { + writefln("Error: '%s' failed with status %d", command, result.status); + return 1; + } + + writeln("; aliases extracted from ", args[1]); + + const lines = splitLines(result.output); + foreach (i; 1 .. lines.length-1) + { + const line = lines[i]; + const previousLine = lines[i-1]; + const nextLine = lines[i+1]; + + const weakExternalIndex = line.indexOf(" WeakExternal | "); + if (weakExternalIndex < 0) + continue; + if (nextLine.indexOf(" 2 Alias record") < 0) + continue; + const externalIndex = previousLine.indexOf(" External | "); + if (externalIndex < 0) + continue; + + const weakName = untilFirstSpace(line[weakExternalIndex+16 .. $]); + const realName = untilFirstSpace(previousLine[externalIndex+16 .. $]); + + writeln(weakName, "=", realName); + } + + return 0; +} diff --git a/windows/mingw/msvcrt140.aliases32 b/windows/mingw/msvcrt140.aliases32 new file mode 100644 index 00000000..21e57eec --- /dev/null +++ b/windows/mingw/msvcrt140.aliases32 @@ -0,0 +1,277 @@ +; aliases extracted from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\msvcrt.lib +___argc_dll=__imp____argc +___argv_dll=__imp____argv +__commode_dll=__imp___commode +__daylight_dll=__imp___daylight +__environ_dll=__imp___environ +__fmode_dll=__imp___fmode +__HUGE_dll=__imp___HUGE +__osver_dll=__imp___osver +__pctype_dll=__imp___pctype +__pwctype_dll=__imp___pwctype +__pgmptr_dll=__imp___pgmptr +__sys_nerr_dll=__imp___sys_nerr +__timezone_dll=__imp___timezone +__winver_dll=__imp___winver +__winmajor_dll=__imp___winmajor +__winminor_dll=__imp___winminor +__ctype=__imp___ctype +__tzname=__imp___tzname +___mb_cur_max_dll=__imp____mb_cur_max +__sys_errlist=__imp___sys_errlist +__mbscat=_strcat +__mbscpy=_strcpy +__strcmpi=__stricmp +__mbsdup=__strdup +_ctime=__ctime32 +_difftime=__difftime32 +__findfirst=__findfirst32 +__findfirsti64=__findfirst32i64 +__findnext=__findnext32 +__findnexti64=__findnext32i64 +__fstat=__fstat32 +__fstati64=__fstat32i64 +__ftime=__ftime32 +__futime=__futime32 +__getdcwd_nolock=__getdcwd +_gmtime=__gmtime32 +_localtime=__localtime32 +_mktime=__mktime32 +__mkgmtime=__mkgmtime32 +__stat=__stat32 +__stati64=__stat32i64 +_time=__time32 +__utime=__utime32 +__wctime=__wctime32 +__wfindfirst=__wfindfirst32 +__wfindfirsti64=__wfindfirst32i64 +__wfindnext=__wfindnext32 +__wfindnexti64=__wfindnext32i64 +__wgetdcwd_nolock=__wgetdcwd +__freea_s=__freea +___CxxFrameHandler2=___CxxFrameHandler3 +_setjmp=___intrinsic_setjmp +__setjmp=___intrinsic_setjmp +__setjmpex=___intrinsic_setjmpex +?_wopen@@YAHPBGHH@Z=?_wopen@@YAHPB_WHH@Z +?_wsopen@@YAHPBGHHH@Z=?_wsopen@@YAHPB_WHHH@Z +?vswprintf@@YAHPAGIPBGPAD@Z=?vswprintf@@YAHPA_WIPB_WPAD@Z +?_set_invalid_parameter_handler@@YAP6AXPBG00II@ZH@Z=?_set_invalid_parameter_handler@@YAP6AXPB_W00II@ZH@Z +?_set_invalid_parameter_handler@@YAP6MXPBG00II@ZP6MX000II@Z@Z=?_set_invalid_parameter_handler@@YAP6MXPB_W00II@ZP6MX000II@Z@Z +__wstat=__wstat32 +__wstati64=__wstat32i64 +__wutime=__wutime32 +_swprintf=__swprintf +_vswprintf=__vswprintf +_vsnprintf=__vsnprintf +_vsnprintf_s=__vsnprintf_s +__tcsclen=__mbslen +__tcsclen_l=__mbslen_l +__tcscnlen=__mbsnlen +__tcscnlen_l=__mbsnlen_l +__tclen=__mbclen +__tccpy=__mbccpy +__tccpy_s=__mbccpy_s +__tccpy_l=__mbccpy_l +__tccpy_s_l=__mbccpy_s_l +__tcsncat=__mbsnbcat +__tcsncat_s=__mbsnbcat_s +__tcsncat_l=__mbsnbcat_l +__tcsncat_s_l=(PREFIX)_mbsnbcat_s_l +__tcsncmp=__mbsnbcmp +__tcsncoll=__mbsnbcoll +__tcsncoll_l=__mbsnbcoll_l +__tcsncpy=__mbsnbcpy +__tcsncpy_s=__mbsnbcpy_s +__tcsncpy_l=__mbsnbcpy_l +__tcsncpy_s_l=__mbsnbcpy_s_l +__tcsnicmp=__mbsnbicmp +__tcsnicmp_l=__mbsnbicmp_l +__tcsnicoll=__mbsnbicoll +__tcsnicoll_l=__mbsnbicoll_l +__tcsnset=__mbsnbset +__tcsnset_s=__mbsnbset_s +__tcsnset_l=__mbsnbset_l +__tcsnset_s_l=__mbsnbset_s_l +__tcsnccat=__mbsncat +__tcsnccat_s=__mbsncat_s +__tcsnccat_l=__mbsncat_l +__tcsnccat_s_l=__mbsncat_s_l +__tcsnccmp=__mbsncmp +__tcsnccoll=__mbsncoll +__tcsnccoll_l=__mbsncoll_l +__tcsnccpy=__mbsncpy +__tcsnccpy_s=__mbsncpy_s +__tcsnccpy_l=__mbsncpy_l +__tcsnccpy_s_l=__mbsncpy_s_l +__tcsncicmp=__mbsnicmp +__tcsncicmp_l=__mbsnicmp_l +__tcsncicoll=__mbsnicoll +__tcsncicoll_l=__mbsnicoll_l +__tcsncset=__mbsnset +__tcsncset_s=__mbsnset_s +__tcsncset_l=__mbsnset_l +__tcsncset_s_l=__mbsnset_s_l +__tcslen=__mbslen +__tcschr=__mbschr +__tcscspn=__mbscspn +__tcspbrk=__mbspbrk +__tcsrchr=__mbsrchr +__tcsspn=__mbsspn +__tcsstr=__mbsstr +__tcstok=__mbstok +__tcstok_l=__mbstok_l +__tcstok_s=__mbstok_s +__tcstok_s_l=__mbstok_s_l +__tcsrev=__mbsrev +__tcsset=__mbsset +__tcsset_l=__mbsset_l +__tcsset_s=__mbsset_s +__tcsset_s_l=__mbsset_s_l +__tcsdec=__mbsdec +__tcsinc=__mbsinc +__tcsnbcnt=__mbsnbcnt +__tcsnccnt=__mbsnccnt +__tcsnextc=__mbsnextc +__tcsninc=__mbsninc +__tcsspnp=__mbsspnp +__tcslwr=__mbslwr +__tcslwr_l=__mbslwr_l +__tcslwr_s=__mbslwr_s +__tcslwr_s_l=__mbslwr_s_l +__tcsupr=__mbsupr +__tcsupr_l=__mbsupr_l +__tcsupr_s=__mbsupr_s +__tcsupr_s_l=__mbsupr_s_l +__tcscmp=__mbscmp +__tcsicmp=__mbsicmp +__tcsicmp_l=__mbsicmp_l +__tcscoll=__mbscoll +__tcscoll_l=__mbscoll_l +__tcsicoll=__mbsicoll +__tcsicoll_l=__mbsicoll_l +__imp___mbscat=__imp__strcat +__imp___mbscpy=__imp__strcpy +__imp___strcmpi=__imp___stricmp +__imp___mbsdup=__imp___strdup +__imp__ctime=__imp___ctime32 +__imp__difftime=__imp___difftime32 +__imp___findfirst=__imp___findfirst32 +__imp___findfirsti64=__imp___findfirst32i64 +__imp___findnext=__imp___findnext32 +__imp___findnexti64=__imp___findnext32i64 +__imp___fstat=__imp___fstat32 +__imp___fstati64=__imp___fstat32i64 +__imp___ftime=__imp___ftime32 +__imp___futime=__imp___futime32 +__imp__gmtime=__imp___gmtime32 +__imp__localtime=__imp___localtime32 +__imp__mktime=__imp___mktime32 +__imp___mkgmtime=__imp___mkgmtime32 +__imp___stat=__imp___stat32 +__imp___stati64=__imp___stat32i64 +__imp__time=__imp___time32 +__imp___utime=__imp___utime32 +__imp___wctime=__imp___wctime32 +__imp___wfindfirst=__imp___wfindfirst32 +__imp___wfindfirsti64=__imp___wfindfirst32i64 +__imp___wfindnext=__imp___wfindnext32 +__imp___wfindnexti64=__imp___wfindnext32i64 +__imp___freea_s=__imp___freea +__imp_?_wopen@@YAHPBGHH@Z=__imp_?_wopen@@YAHPB_WHH@Z +__imp_?_wsopen@@YAHPBGHHH@Z=__imp_?_wsopen@@YAHPB_WHHH@Z +__imp_?vswprintf@@YAHPAGIPBGPAD@Z=__imp_?vswprintf@@YAHPA_WIPB_WPAD@Z +__imp___wstat=__imp___wstat32 +__imp___wstati64=__imp___wstat32i64 +__imp___wutime=__imp___wutime32 +__imp__swprintf=__imp___swprintf +__imp__vswprintf=__imp___vswprintf +__imp__vsnprintf=__imp___vsnprintf +__imp__vsnprintf_s=__imp___vsnprintf_s +__imp_?_set_invalid_parameter_handler@@YAP6AXPBG00II@ZH@Z=__imp_?_set_invalid_parameter_handler@@YAP6AXPB_W00II@ZH@Z +__imp_?_set_invalid_parameter_handler@@YAP6MXPBG00II@ZP6MX000II@Z@Z=__imp_?_set_invalid_parameter_handler@@YAP6MXPB_W00II@ZP6MX000II@Z@Z +__imp___tcsclen=__imp___mbslen +__imp___tcsclen_l=__imp___mbslen_l +__imp___tcscnlen=__imp___mbsnlen +__imp___tcscnlen_l=__imp___mbsnlen_l +__imp___tclen=__imp___mbclen +__imp___tccpy=__imp___mbccpy +__imp___tccpy_s=__imp___mbccpy_s +__imp___tccpy_l=__imp___mbccpy_l +__imp___tccpy_s_l=__imp___mbccpy_s_l +__imp___tcsncat=__imp___mbsnbcat +__imp___tcsncat_s=__imp___mbsnbcat_s +__imp___tcsncat_l=__imp___mbsnbcat_l +__imp___tcsncat_s_l=(PREFIX)_mbsnbcat_s_l +__imp___tcsncmp=__imp___mbsnbcmp +__imp___tcsncoll=__imp___mbsnbcoll +__imp___tcsncoll_l=__imp___mbsnbcoll_l +__imp___tcsncpy=__imp___mbsnbcpy +__imp___tcsncpy_s=__imp___mbsnbcpy_s +__imp___tcsncpy_l=__imp___mbsnbcpy_l +__imp___tcsncpy_s_l=__imp___mbsnbcpy_s_l +__imp___tcsnicmp=__imp___mbsnbicmp +__imp___tcsnicmp_l=__imp___mbsnbicmp_l +__imp___tcsnicoll=__imp___mbsnbicoll +__imp___tcsnicoll_l=__imp___mbsnbicoll_l +__imp___tcsnset=__imp___mbsnbset +__imp___tcsnset_s=__imp___mbsnbset_s +__imp___tcsnset_l=__imp___mbsnbset_l +__imp___tcsnset_s_l=__imp___mbsnbset_s_l +__imp___tcsnccat=__imp___mbsncat +__imp___tcsnccat_s=__imp___mbsncat_s +__imp___tcsnccat_l=__imp___mbsncat_l +__imp___tcsnccat_s_l=__imp___mbsncat_s_l +__imp___tcsnccmp=__imp___mbsncmp +__imp___tcsnccoll=__imp___mbsncoll +__imp___tcsnccoll_l=__imp___mbsncoll_l +__imp___tcsnccpy=__imp___mbsncpy +__imp___tcsnccpy_s=__imp___mbsncpy_s +__imp___tcsnccpy_l=__imp___mbsncpy_l +__imp___tcsnccpy_s_l=__imp___mbsncpy_s_l +__imp___tcsncicmp=__imp___mbsnicmp +__imp___tcsncicmp_l=__imp___mbsnicmp_l +__imp___tcsncicoll=__imp___mbsnicoll +__imp___tcsncicoll_l=__imp___mbsnicoll_l +__imp___tcsncset=__imp___mbsnset +__imp___tcsncset_s=__imp___mbsnset_s +__imp___tcsncset_l=__imp___mbsnset_l +__imp___tcsncset_s_l=__imp___mbsnset_s_l +__imp___tcslen=__imp___mbslen +__imp___tcschr=__imp___mbschr +__imp___tcscspn=__imp___mbscspn +__imp___tcspbrk=__imp___mbspbrk +__imp___tcsrchr=__imp___mbsrchr +__imp___tcsspn=__imp___mbsspn +__imp___tcsstr=__imp___mbsstr +__imp___tcstok=__imp___mbstok +__imp___tcstok_l=__imp___mbstok_l +__imp___tcstok_s=__imp___mbstok_s +__imp___tcstok_s_l=__imp___mbstok_s_l +__imp___tcsrev=__imp___mbsrev +__imp___tcsset=__imp___mbsset +__imp___tcsset_l=__imp___mbsset_l +__imp___tcsset_s=__imp___mbsset_s +__imp___tcsset_s_l=__imp___mbsset_s_l +__imp___tcsdec=__imp___mbsdec +__imp___tcsinc=__imp___mbsinc +__imp___tcsnbcnt=__imp___mbsnbcnt +__imp___tcsnccnt=__imp___mbsnccnt +__imp___tcsnextc=__imp___mbsnextc +__imp___tcsninc=__imp___mbsninc +__imp___tcsspnp=__imp___mbsspnp +__imp___tcslwr=__imp___mbslwr +__imp___tcslwr_l=__imp___mbslwr_l +__imp___tcslwr_s=__imp___mbslwr_s +__imp___tcslwr_s_l=__imp___mbslwr_s_l +__imp___tcsupr=__imp___mbsupr +__imp___tcsupr_l=__imp___mbsupr_l +__imp___tcsupr_s=__imp___mbsupr_s +__imp___tcsupr_s_l=__imp___mbsupr_s_l +__imp___tcscmp=__imp___mbscmp +__imp___tcsicmp=__imp___mbsicmp +__imp___tcsicmp_l=__imp___mbsicmp_l +__imp___tcscoll=__imp___mbscoll +__imp___tcscoll_l=__imp___mbscoll_l +__imp___tcsicoll=__imp___mbsicoll +__imp___tcsicoll_l=__imp___mbsicoll_l diff --git a/windows/mingw/msvcrt140.aliases64 b/windows/mingw/msvcrt140.aliases64 new file mode 100644 index 00000000..00ee6049 --- /dev/null +++ b/windows/mingw/msvcrt140.aliases64 @@ -0,0 +1,275 @@ +; aliases extracted from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64\msvcrt.lib +__argc_dll=__imp___argc +__argv_dll=__imp___argv +_commode_dll=__imp__commode +_daylight_dll=__imp__daylight +_environ_dll=__imp__environ +_fmode_dll=__imp__fmode +_HUGE_dll=__imp__HUGE +_osver_dll=__imp__osver +_pctype_dll=__imp__pctype +_pwctype_dll=__imp__pwctype +_pgmptr_dll=__imp__pgmptr +_sys_nerr_dll=__imp__sys_nerr +_timezone_dll=__imp__timezone +_winver_dll=__imp__winver +_winmajor_dll=__imp__winmajor +_winminor_dll=__imp__winminor +_ctype=__imp__ctype +_tzname=__imp__tzname +__mb_cur_max_dll=__imp___mb_cur_max +_sys_errlist=__imp__sys_errlist +_mbscat=strcat +_mbscpy=strcpy +_strcmpi=_stricmp +_mbsdup=_strdup +ctime=_ctime32 +difftime=_difftime32 +_findfirst=_findfirst32 +_findfirsti64=_findfirst32i64 +_findnext=_findnext32 +_findnexti64=_findnext32i64 +_fstat=_fstat32 +_fstati64=_fstat32i64 +_ftime=_ftime32 +_futime=_futime32 +_getdcwd_nolock=_getdcwd +gmtime=_gmtime32 +localtime=_localtime32 +mktime=_mktime32 +_mkgmtime=_mkgmtime32 +_stat=_stat32 +_stati64=_stat32i64 +time=_time32 +_utime=_utime32 +_wctime=_wctime32 +_wfindfirst=_wfindfirst32 +_wfindfirsti64=_wfindfirst32i64 +_wfindnext=_wfindnext32 +_wfindnexti64=_wfindnext32i64 +_wgetdcwd_nolock=_wgetdcwd +_freea_s=_freea +__CxxFrameHandler2=__CxxFrameHandler3 +setjmp=__intrinsic_setjmp +_setjmp=__intrinsic_setjmp +_setjmpex=__intrinsic_setjmpex +?_wopen@@YAHPEBGHH@Z=?_wopen@@YAHPEB_WHH@Z +?_wsopen@@YAHPEBGHHH@Z=?_wsopen@@YAHPEB_WHHH@Z +?_set_invalid_parameter_handler@@YAP6AXPEBG00I_K@ZH@Z=?_set_invalid_parameter_handler@@YAP6AXPEB_W00I_K@ZH@Z +?_set_invalid_parameter_handler@@YAP6MXPEBG00I_K@ZP6MX000I1@Z@Z=?_set_invalid_parameter_handler@@YAP6MXPEB_W00I_K@ZP6MX000I1@Z@Z +_wstat=_wstat32 +_wstati64=_wstat32i64 +_wutime=_wutime32 +swprintf=_swprintf +vswprintf=_vswprintf +vsnprintf=_vsnprintf +vsnprintf_s=_vsnprintf_s +_tcsclen=_mbslen +_tcsclen_l=_mbslen_l +_tcscnlen=_mbsnlen +_tcscnlen_l=_mbsnlen_l +_tclen=_mbclen +_tccpy=_mbccpy +_tccpy_s=_mbccpy_s +_tccpy_l=_mbccpy_l +_tccpy_s_l=_mbccpy_s_l +_tcsncat=_mbsnbcat +_tcsncat_s=_mbsnbcat_s +_tcsncat_l=_mbsnbcat_l +_tcsncat_s_l=(PREFIX)_mbsnbcat_s_l +_tcsncmp=_mbsnbcmp +_tcsncoll=_mbsnbcoll +_tcsncoll_l=_mbsnbcoll_l +_tcsncpy=_mbsnbcpy +_tcsncpy_s=_mbsnbcpy_s +_tcsncpy_l=_mbsnbcpy_l +_tcsncpy_s_l=_mbsnbcpy_s_l +_tcsnicmp=_mbsnbicmp +_tcsnicmp_l=_mbsnbicmp_l +_tcsnicoll=_mbsnbicoll +_tcsnicoll_l=_mbsnbicoll_l +_tcsnset=_mbsnbset +_tcsnset_s=_mbsnbset_s +_tcsnset_l=_mbsnbset_l +_tcsnset_s_l=_mbsnbset_s_l +_tcsnccat=_mbsncat +_tcsnccat_s=_mbsncat_s +_tcsnccat_l=_mbsncat_l +_tcsnccat_s_l=_mbsncat_s_l +_tcsnccmp=_mbsncmp +_tcsnccoll=_mbsncoll +_tcsnccoll_l=_mbsncoll_l +_tcsnccpy=_mbsncpy +_tcsnccpy_s=_mbsncpy_s +_tcsnccpy_l=_mbsncpy_l +_tcsnccpy_s_l=_mbsncpy_s_l +_tcsncicmp=_mbsnicmp +_tcsncicmp_l=_mbsnicmp_l +_tcsncicoll=_mbsnicoll +_tcsncicoll_l=_mbsnicoll_l +_tcsncset=_mbsnset +_tcsncset_s=_mbsnset_s +_tcsncset_l=_mbsnset_l +_tcsncset_s_l=_mbsnset_s_l +_tcslen=_mbslen +_tcschr=_mbschr +_tcscspn=_mbscspn +_tcspbrk=_mbspbrk +_tcsrchr=_mbsrchr +_tcsspn=_mbsspn +_tcsstr=_mbsstr +_tcstok=_mbstok +_tcstok_l=_mbstok_l +_tcstok_s=_mbstok_s +_tcstok_s_l=_mbstok_s_l +_tcsrev=_mbsrev +_tcsset=_mbsset +_tcsset_l=_mbsset_l +_tcsset_s=_mbsset_s +_tcsset_s_l=_mbsset_s_l +_tcsdec=_mbsdec +_tcsinc=_mbsinc +_tcsnbcnt=_mbsnbcnt +_tcsnccnt=_mbsnccnt +_tcsnextc=_mbsnextc +_tcsninc=_mbsninc +_tcsspnp=_mbsspnp +_tcslwr=_mbslwr +_tcslwr_l=_mbslwr_l +_tcslwr_s=_mbslwr_s +_tcslwr_s_l=_mbslwr_s_l +_tcsupr=_mbsupr +_tcsupr_l=_mbsupr_l +_tcsupr_s=_mbsupr_s +_tcsupr_s_l=_mbsupr_s_l +_tcscmp=_mbscmp +_tcsicmp=_mbsicmp +_tcsicmp_l=_mbsicmp_l +_tcscoll=_mbscoll +_tcscoll_l=_mbscoll_l +_tcsicoll=_mbsicoll +_tcsicoll_l=_mbsicoll_l +__imp__mbscat=__imp_strcat +__imp__mbscpy=__imp_strcpy +__imp__strcmpi=__imp__stricmp +__imp__mbsdup=__imp__strdup +__imp_ctime=__imp__ctime32 +__imp_difftime=__imp__difftime32 +__imp__findfirst=__imp__findfirst32 +__imp__findfirsti64=__imp__findfirst32i64 +__imp__findnext=__imp__findnext32 +__imp__findnexti64=__imp__findnext32i64 +__imp__fstat=__imp__fstat32 +__imp__fstati64=__imp__fstat32i64 +__imp__ftime=__imp__ftime32 +__imp__futime=__imp__futime32 +__imp_gmtime=__imp__gmtime32 +__imp_localtime=__imp__localtime32 +__imp_mktime=__imp__mktime32 +__imp__mkgmtime=__imp__mkgmtime32 +__imp__stat=__imp__stat32 +__imp__stati64=__imp__stat32i64 +__imp_time=__imp__time32 +__imp__utime=__imp__utime32 +__imp__wctime=__imp__wctime32 +__imp__wfindfirst=__imp__wfindfirst32 +__imp__wfindfirsti64=__imp__wfindfirst32i64 +__imp__wfindnext=__imp__wfindnext32 +__imp__wfindnexti64=__imp__wfindnext32i64 +__imp__freea_s=__imp__freea +__imp_?_wopen@@YAHPEBGHH@Z=__imp_?_wopen@@YAHPEB_WHH@Z +__imp_?_wsopen@@YAHPEBGHHH@Z=__imp_?_wsopen@@YAHPEB_WHHH@Z +__imp__wstat=__imp__wstat32 +__imp__wstati64=__imp__wstat32i64 +__imp__wutime=__imp__wutime32 +__imp_swprintf=__imp__swprintf +__imp_vswprintf=__imp__vswprintf +__imp_vsnprintf=__imp__vsnprintf +__imp_vsnprintf_s=__imp__vsnprintf_s +__imp_?_set_invalid_parameter_handler@@YAP6AXPBG00II@ZH@Z=__imp_?_set_invalid_parameter_handler@@YAP6AXPB_W00II@ZH@Z +__imp_?_set_invalid_parameter_handler@@YAP6MXPBG00II@ZP6MX000II@Z@Z=__imp_?_set_invalid_parameter_handler@@YAP6MXPB_W00II@ZP6MX000II@Z@Z +__imp__tcsclen=__imp__mbslen +__imp__tcsclen_l=__imp__mbslen_l +__imp__tcscnlen=__imp__mbsnlen +__imp__tcscnlen_l=__imp__mbsnlen_l +__imp__tclen=__imp__mbclen +__imp__tccpy=__imp__mbccpy +__imp__tccpy_s=__imp__mbccpy_s +__imp__tccpy_l=__imp__mbccpy_l +__imp__tccpy_s_l=__imp__mbccpy_s_l +__imp__tcsncat=__imp__mbsnbcat +__imp__tcsncat_s=__imp__mbsnbcat_s +__imp__tcsncat_l=__imp__mbsnbcat_l +__imp__tcsncat_s_l=(PREFIX)_mbsnbcat_s_l +__imp__tcsncmp=__imp__mbsnbcmp +__imp__tcsncoll=__imp__mbsnbcoll +__imp__tcsncoll_l=__imp__mbsnbcoll_l +__imp__tcsncpy=__imp__mbsnbcpy +__imp__tcsncpy_s=__imp__mbsnbcpy_s +__imp__tcsncpy_l=__imp__mbsnbcpy_l +__imp__tcsncpy_s_l=__imp__mbsnbcpy_s_l +__imp__tcsnicmp=__imp__mbsnbicmp +__imp__tcsnicmp_l=__imp__mbsnbicmp_l +__imp__tcsnicoll=__imp__mbsnbicoll +__imp__tcsnicoll_l=__imp__mbsnbicoll_l +__imp__tcsnset=__imp__mbsnbset +__imp__tcsnset_s=__imp__mbsnbset_s +__imp__tcsnset_l=__imp__mbsnbset_l +__imp__tcsnset_s_l=__imp__mbsnbset_s_l +__imp__tcsnccat=__imp__mbsncat +__imp__tcsnccat_s=__imp__mbsncat_s +__imp__tcsnccat_l=__imp__mbsncat_l +__imp__tcsnccat_s_l=__imp__mbsncat_s_l +__imp__tcsnccmp=__imp__mbsncmp +__imp__tcsnccoll=__imp__mbsncoll +__imp__tcsnccoll_l=__imp__mbsncoll_l +__imp__tcsnccpy=__imp__mbsncpy +__imp__tcsnccpy_s=__imp__mbsncpy_s +__imp__tcsnccpy_l=__imp__mbsncpy_l +__imp__tcsnccpy_s_l=__imp__mbsncpy_s_l +__imp__tcsncicmp=__imp__mbsnicmp +__imp__tcsncicmp_l=__imp__mbsnicmp_l +__imp__tcsncicoll=__imp__mbsnicoll +__imp__tcsncicoll_l=__imp__mbsnicoll_l +__imp__tcsncset=__imp__mbsnset +__imp__tcsncset_s=__imp__mbsnset_s +__imp__tcsncset_l=__imp__mbsnset_l +__imp__tcsncset_s_l=__imp__mbsnset_s_l +__imp__tcslen=__imp__mbslen +__imp__tcschr=__imp__mbschr +__imp__tcscspn=__imp__mbscspn +__imp__tcspbrk=__imp__mbspbrk +__imp__tcsrchr=__imp__mbsrchr +__imp__tcsspn=__imp__mbsspn +__imp__tcsstr=__imp__mbsstr +__imp__tcstok=__imp__mbstok +__imp__tcstok_l=__imp__mbstok_l +__imp__tcstok_s=__imp__mbstok_s +__imp__tcstok_s_l=__imp__mbstok_s_l +__imp__tcsrev=__imp__mbsrev +__imp__tcsset=__imp__mbsset +__imp__tcsset_l=__imp__mbsset_l +__imp__tcsset_s=__imp__mbsset_s +__imp__tcsset_s_l=__imp__mbsset_s_l +__imp__tcsdec=__imp__mbsdec +__imp__tcsinc=__imp__mbsinc +__imp__tcsnbcnt=__imp__mbsnbcnt +__imp__tcsnccnt=__imp__mbsnccnt +__imp__tcsnextc=__imp__mbsnextc +__imp__tcsninc=__imp__mbsninc +__imp__tcsspnp=__imp__mbsspnp +__imp__tcslwr=__imp__mbslwr +__imp__tcslwr_l=__imp__mbslwr_l +__imp__tcslwr_s=__imp__mbslwr_s +__imp__tcslwr_s_l=__imp__mbslwr_s_l +__imp__tcsupr=__imp__mbsupr +__imp__tcsupr_l=__imp__mbsupr_l +__imp__tcsupr_s=__imp__mbsupr_s +__imp__tcsupr_s_l=__imp__mbsupr_s_l +__imp__tcscmp=__imp__mbscmp +__imp__tcsicmp=__imp__mbsicmp +__imp__tcsicmp_l=__imp__mbsicmp_l +__imp__tcscoll=__imp__mbscoll +__imp__tcscoll_l=__imp__mbscoll_l +__imp__tcsicoll=__imp__mbsicoll +__imp__tcsicoll_l=__imp__mbsicoll_l diff --git a/windows/mingw/msvcrt_stub.c b/windows/mingw/msvcrt_stub.c index 051ca202..a3fd1d16 100644 --- a/windows/mingw/msvcrt_stub.c +++ b/windows/mingw/msvcrt_stub.c @@ -68,6 +68,12 @@ extern char **__argv; #if MSVCRT_VERSION >= 140 // UCRT +#ifdef _M_X64 +__pragma(comment(linker, "/alternatename:__set_app_type=_set_app_type")); +#else +__pragma(comment(linker, "/alternatename:___set_app_type=__set_app_type")); +#endif + enum _crt_argv_mode { _crt_argv_no_arguments, diff --git a/windows/mingw/oldnames.aliases32 b/windows/mingw/oldnames.aliases32 new file mode 100644 index 00000000..15ceb2a6 --- /dev/null +++ b/windows/mingw/oldnames.aliases32 @@ -0,0 +1,229 @@ +; aliases extracted from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\oldnames.lib +__imp__utime=__imp___utime32 +_utime=__utime32 +__imp__ftime=__imp___ftime32 +_ftime=__ftime32 +__imp__stat=__imp___stat32 +_stat=__stat32 +__imp__fstat=__imp___fstat32 +_fstat=__fstat32 +__imp__fcloseall=__imp___fcloseall +_fcloseall=__fcloseall +__imp__control87=__imp___control87 +_control87=__control87 +__imp__sys_errlist=__imp___sys_errlist +_sys_errlist=__sys_errlist +__imp__filelength=__imp___filelength +_filelength=__filelength +__imp__strcmpi=__imp___stricmp +_strcmpi=__stricmp +__imp__wcsicoll=__imp___wcsicoll +__imp__wcsupr=__imp___wcsupr +__imp__wcslwr=__imp___wcslwr +__imp__wcsset=__imp___wcsset +__imp__wcsrev=__imp___wcsrev +__imp__wcsnset=__imp___wcsnset +__imp__wcsnicmp=__imp___wcsnicmp +__imp__wcsicmp=__imp___wcsicmp +__imp__wcsdup=__imp___wcsdup +__imp__dup=__imp___dup +__imp__tzset=__imp___tzset +__imp__tzname=__imp___tzname +__imp__timezone=__imp___timezone +__imp__strupr=__imp___strupr +__imp__strset=__imp___strset +__imp__strrev=__imp___strrev +__imp__strnset=__imp___strnset +__imp__strnicmp=__imp___strnicmp +__imp__strlwr=__imp___strlwr +__imp__strdup=__imp___strdup +__imp__stricmp=__imp___stricmp +__imp__tempnam=__imp___tempnam +__imp__rmtmp=__imp___rmtmp +__imp__putw=__imp___putw +__imp__getw=__imp___getw +__imp__fputchar=__imp___fputchar +__imp__flushall=__imp___flushall +__imp__fileno=__imp___fileno +__imp__fgetchar=__imp___fgetchar +__imp__fdopen=__imp___fdopen +__imp__ultoa=__imp___ultoa +__imp__swab=__imp___swab +__imp__putenv=__imp___putenv +__imp__onexit=__imp___onexit +__imp__ltoa=__imp___ltoa +__imp__itoa=__imp___itoa +__imp__yn=__imp___yn +__imp__y1=__imp___y1 +__imp__y0=__imp___y0 +__imp__jn=__imp___jn +__imp__j1=__imp___j1 +__imp__j0=__imp___j0 +__imp__cabs=__imp___cabs +__imp__HUGE=__imp___HUGE +__imp__gcvt=__imp___gcvt +__imp__fcvt=__imp___fcvt +__imp__ecvt=__imp___ecvt +__imp__lsearch=__imp___lsearch +__imp__lfind=__imp___lfind +__imp__spawnvpe=__imp___spawnvpe +__imp__spawnvp=__imp___spawnvp +__imp__spawnve=__imp___spawnve +__imp__spawnv=__imp___spawnv +__imp__spawnlpe=__imp___spawnlpe +__imp__spawnlp=__imp___spawnlp +__imp__spawnle=__imp___spawnle +__imp__spawnl=__imp___spawnl +__imp__getpid=__imp___getpid +__imp__execvpe=__imp___execvpe +__imp__execvp=__imp___execvp +__imp__execve=__imp___execve +__imp__execv=__imp___execv +__imp__execlpe=__imp___execlpe +__imp__execlp=__imp___execlp +__imp__execle=__imp___execle +__imp__execl=__imp___execl +__imp__cwait=__imp___cwait +__imp__memicmp=__imp___memicmp +__imp__memccpy=__imp___memccpy +__imp__write=__imp___write +__imp__unlink=__imp___unlink +__imp__umask=__imp___umask +__imp__tell=__imp___tell +__imp__sys_nerr=__imp___sys_nerr +__imp__sopen=__imp___sopen +__imp__setmode=__imp___setmode +__imp__read=__imp___read +__imp__open=__imp___open +__imp__mktemp=__imp___mktemp +__imp__lseek=__imp___lseek +__imp__locking=__imp___locking +__imp__isatty=__imp___isatty +__imp__eof=__imp___eof +__imp__dup2=__imp___dup2 +__imp__creat=__imp___creat +__imp__close=__imp___close +__imp__chsize=__imp___chsize +__imp__chmod=__imp___chmod +__imp__access=__imp___access +__imp__rmdir=__imp___rmdir +__imp__mkdir=__imp___mkdir +__imp__getcwd=__imp___getcwd +__imp__chdir=__imp___chdir +__imp__ungetch=__imp___ungetch +__imp__putch=__imp___putch +__imp__kbhit=__imp___kbhit +__imp__getche=__imp___getche +__imp__fpreset=__imp___fpreset +__imp__getch=__imp___getch +__imp__environ=__imp___environ +__imp__daylight=__imp___daylight +__imp__cscanf=__imp___cscanf +__imp__cputs=__imp___cputs +__imp__cprintf=__imp___cprintf +__imp__cgets=__imp___cgets +_wcsicoll=__wcsicoll +_wcsupr=__wcsupr +_wcslwr=__wcslwr +_wcsset=__wcsset +_wcsrev=__wcsrev +_wcsnset=__wcsnset +_wcsnicmp=__wcsnicmp +_wcsicmp=__wcsicmp +_wcsdup=__wcsdup +_dup=__dup +_tzset=__tzset +_tzname=__tzname +_timezone=__timezone +_strupr=__strupr +_strset=__strset +_strrev=__strrev +_strnset=__strnset +_strnicmp=__strnicmp +_strlwr=__strlwr +_strdup=__strdup +_stricmp=__stricmp +_tempnam=__tempnam +_rmtmp=__rmtmp +_putw=__putw +_getw=__getw +_fputchar=__fputchar +_flushall=__flushall +_fileno=__fileno +_fgetchar=__fgetchar +_fdopen=__fdopen +_ultoa=__ultoa +_swab=__swab +_putenv=__putenv +_onexit=__onexit +_ltoa=__ltoa +_itoa=__itoa +_yn=__yn +_y1=__y1 +_y0=__y0 +_jn=__jn +_j1=__j1 +_j0=__j0 +_cabs=__cabs +_HUGE=__HUGE +_gcvt=__gcvt +_fcvt=__fcvt +_ecvt=__ecvt +_lsearch=__lsearch +_lfind=__lfind +_spawnvpe=__spawnvpe +_spawnvp=__spawnvp +_spawnve=__spawnve +_spawnv=__spawnv +_spawnlpe=__spawnlpe +_spawnlp=__spawnlp +_spawnle=__spawnle +_spawnl=__spawnl +_getpid=__getpid +_execvpe=__execvpe +_execvp=__execvp +_execve=__execve +_execv=__execv +_execlpe=__execlpe +_execlp=__execlp +_execle=__execle +_execl=__execl +_cwait=__cwait +_memicmp=__memicmp +_memccpy=__memccpy +_write=__write +_unlink=__unlink +_umask=__umask +_tell=__tell +_sys_nerr=__sys_nerr +_sopen=__sopen +_setmode=__setmode +_read=__read +_open=__open +_mktemp=__mktemp +_lseek=__lseek +_locking=__locking +_isatty=__isatty +_eof=__eof +_dup2=__dup2 +_creat=__creat +_close=__close +_chsize=__chsize +_chmod=__chmod +_access=__access +_rmdir=__rmdir +_mkdir=__mkdir +_getcwd=__getcwd +_chdir=__chdir +_ungetch=__ungetch +_putch=__putch +_kbhit=__kbhit +_getche=__getche +_fpreset=__fpreset +_getch=__getch +_environ=__environ +_daylight=__daylight +_cscanf=__cscanf +_cputs=__cputs +_cprintf=__cprintf +_cgets=__cgets diff --git a/windows/mingw/oldnames.aliases64 b/windows/mingw/oldnames.aliases64 new file mode 100644 index 00000000..68fcf66a --- /dev/null +++ b/windows/mingw/oldnames.aliases64 @@ -0,0 +1,229 @@ +; aliases extracted from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib\amd64\oldnames.lib +__imp_utime=__imp__utime32 +utime=_utime32 +__imp_ftime=__imp__ftime32 +ftime=_ftime32 +__imp_stat=__imp__stat32 +stat=_stat32 +__imp_fstat=__imp__fstat32 +fstat=_fstat32 +__imp_fcloseall=__imp__fcloseall +fcloseall=_fcloseall +__imp_control87=__imp__control87 +control87=_control87 +__imp_sys_errlist=__imp__sys_errlist +sys_errlist=_sys_errlist +__imp_filelength=__imp__filelength +filelength=_filelength +__imp_strcmpi=__imp__stricmp +strcmpi=_stricmp +__imp_wcsicoll=__imp__wcsicoll +__imp_wcsupr=__imp__wcsupr +__imp_wcslwr=__imp__wcslwr +__imp_wcsset=__imp__wcsset +__imp_wcsrev=__imp__wcsrev +__imp_wcsnset=__imp__wcsnset +__imp_wcsnicmp=__imp__wcsnicmp +__imp_wcsicmp=__imp__wcsicmp +__imp_wcsdup=__imp__wcsdup +__imp_dup=__imp__dup +__imp_tzset=__imp__tzset +__imp_tzname=__imp__tzname +__imp_timezone=__imp__timezone +__imp_strupr=__imp__strupr +__imp_strset=__imp__strset +__imp_strrev=__imp__strrev +__imp_strnset=__imp__strnset +__imp_strnicmp=__imp__strnicmp +__imp_strlwr=__imp__strlwr +__imp_strdup=__imp__strdup +__imp_stricmp=__imp__stricmp +__imp_tempnam=__imp__tempnam +__imp_rmtmp=__imp__rmtmp +__imp_putw=__imp__putw +__imp_getw=__imp__getw +__imp_fputchar=__imp__fputchar +__imp_flushall=__imp__flushall +__imp_fileno=__imp__fileno +__imp_fgetchar=__imp__fgetchar +__imp_fdopen=__imp__fdopen +__imp_ultoa=__imp__ultoa +__imp_swab=__imp__swab +__imp_putenv=__imp__putenv +__imp_onexit=__imp__onexit +__imp_ltoa=__imp__ltoa +__imp_itoa=__imp__itoa +__imp_yn=__imp__yn +__imp_y1=__imp__y1 +__imp_y0=__imp__y0 +__imp_jn=__imp__jn +__imp_j1=__imp__j1 +__imp_j0=__imp__j0 +__imp_cabs=__imp__cabs +__imp_HUGE=__imp__HUGE +__imp_gcvt=__imp__gcvt +__imp_fcvt=__imp__fcvt +__imp_ecvt=__imp__ecvt +__imp_lsearch=__imp__lsearch +__imp_lfind=__imp__lfind +__imp_spawnvpe=__imp__spawnvpe +__imp_spawnvp=__imp__spawnvp +__imp_spawnve=__imp__spawnve +__imp_spawnv=__imp__spawnv +__imp_spawnlpe=__imp__spawnlpe +__imp_spawnlp=__imp__spawnlp +__imp_spawnle=__imp__spawnle +__imp_spawnl=__imp__spawnl +__imp_getpid=__imp__getpid +__imp_execvpe=__imp__execvpe +__imp_execvp=__imp__execvp +__imp_execve=__imp__execve +__imp_execv=__imp__execv +__imp_execlpe=__imp__execlpe +__imp_execlp=__imp__execlp +__imp_execle=__imp__execle +__imp_execl=__imp__execl +__imp_cwait=__imp__cwait +__imp_memicmp=__imp__memicmp +__imp_memccpy=__imp__memccpy +__imp_write=__imp__write +__imp_unlink=__imp__unlink +__imp_umask=__imp__umask +__imp_tell=__imp__tell +__imp_sys_nerr=__imp__sys_nerr +__imp_sopen=__imp__sopen +__imp_setmode=__imp__setmode +__imp_read=__imp__read +__imp_open=__imp__open +__imp_mktemp=__imp__mktemp +__imp_lseek=__imp__lseek +__imp_locking=__imp__locking +__imp_isatty=__imp__isatty +__imp_eof=__imp__eof +__imp_dup2=__imp__dup2 +__imp_creat=__imp__creat +__imp_close=__imp__close +__imp_chsize=__imp__chsize +__imp_chmod=__imp__chmod +__imp_access=__imp__access +__imp_rmdir=__imp__rmdir +__imp_mkdir=__imp__mkdir +__imp_getcwd=__imp__getcwd +__imp_chdir=__imp__chdir +__imp_ungetch=__imp__ungetch +__imp_putch=__imp__putch +__imp_kbhit=__imp__kbhit +__imp_getche=__imp__getche +__imp_fpreset=__imp__fpreset +__imp_getch=__imp__getch +__imp_environ=__imp__environ +__imp_daylight=__imp__daylight +__imp_cscanf=__imp__cscanf +__imp_cputs=__imp__cputs +__imp_cprintf=__imp__cprintf +__imp_cgets=__imp__cgets +wcsicoll=_wcsicoll +wcsupr=_wcsupr +wcslwr=_wcslwr +wcsset=_wcsset +wcsrev=_wcsrev +wcsnset=_wcsnset +wcsnicmp=_wcsnicmp +wcsicmp=_wcsicmp +wcsdup=_wcsdup +dup=_dup +tzset=_tzset +tzname=_tzname +timezone=_timezone +strupr=_strupr +strset=_strset +strrev=_strrev +strnset=_strnset +strnicmp=_strnicmp +strlwr=_strlwr +strdup=_strdup +stricmp=_stricmp +tempnam=_tempnam +rmtmp=_rmtmp +putw=_putw +getw=_getw +fputchar=_fputchar +flushall=_flushall +fileno=_fileno +fgetchar=_fgetchar +fdopen=_fdopen +ultoa=_ultoa +swab=_swab +putenv=_putenv +onexit=_onexit +ltoa=_ltoa +itoa=_itoa +yn=_yn +y1=_y1 +y0=_y0 +jn=_jn +j1=_j1 +j0=_j0 +cabs=_cabs +HUGE=_HUGE +gcvt=_gcvt +fcvt=_fcvt +ecvt=_ecvt +lsearch=_lsearch +lfind=_lfind +spawnvpe=_spawnvpe +spawnvp=_spawnvp +spawnve=_spawnve +spawnv=_spawnv +spawnlpe=_spawnlpe +spawnlp=_spawnlp +spawnle=_spawnle +spawnl=_spawnl +getpid=_getpid +execvpe=_execvpe +execvp=_execvp +execve=_execve +execv=_execv +execlpe=_execlpe +execlp=_execlp +execle=_execle +execl=_execl +cwait=_cwait +memicmp=_memicmp +memccpy=_memccpy +write=_write +unlink=_unlink +umask=_umask +tell=_tell +sys_nerr=_sys_nerr +sopen=_sopen +setmode=_setmode +read=_read +open=_open +mktemp=_mktemp +lseek=_lseek +locking=_locking +isatty=_isatty +eof=_eof +dup2=_dup2 +creat=_creat +close=_close +chsize=_chsize +chmod=_chmod +access=_access +rmdir=_rmdir +mkdir=_mkdir +getcwd=_getcwd +chdir=_chdir +ungetch=_ungetch +putch=_putch +kbhit=_kbhit +getche=_getche +fpreset=_fpreset +getch=_getch +environ=_environ +daylight=_daylight +cscanf=_cscanf +cputs=_cputs +cprintf=_cprintf +cgets=_cgets diff --git a/windows/mingw/oldnames.list b/windows/mingw/oldnames.list deleted file mode 100644 index 513f6547..00000000 --- a/windows/mingw/oldnames.list +++ /dev/null @@ -1,228 +0,0 @@ -__imp_utime=__imp__utime32 -utime=_utime32 -__imp_ftime=__imp__ftime32 -ftime=_ftime32 -__imp_stat=__imp__stat32 -stat=_stat32 -__imp_fstat=__imp__fstat32 -fstat=_fstat32 -__imp_fcloseall -fcloseall -__imp_control87 -control87 -__imp_sys_errlist -sys_errlist -__imp_filelength -filelength -__imp_strcmpi=__imp__stricmp -strcmpi=_stricmp -__imp_wcsicoll -__imp_wcsupr -__imp_wcslwr -__imp_wcsset -__imp_wcsrev -__imp_wcsnset -__imp_wcsnicmp -__imp_wcsicmp -__imp_wcsdup -__imp_dup -__imp_tzset -__imp_tzname -__imp_timezone -__imp_strupr -__imp_strset -__imp_strrev -__imp_strnset -__imp_strnicmp -__imp_strlwr -__imp_strdup -__imp_stricmp -__imp_tempnam -__imp_rmtmp -__imp_putw -__imp_getw -__imp_fputchar -__imp_flushall -__imp_fileno -__imp_fgetchar -__imp_fdopen -__imp_ultoa -__imp_swab -__imp_putenv -__imp_onexit -__imp_ltoa -__imp_itoa -__imp_yn -__imp_y1 -__imp_y0 -__imp_jn -__imp_j1 -__imp_j0 -__imp_cabs -__imp_HUGE -__imp_gcvt -__imp_fcvt -__imp_ecvt -__imp_lsearch -__imp_lfind -__imp_spawnvpe -__imp_spawnvp -__imp_spawnve -__imp_spawnv -__imp_spawnlpe -__imp_spawnlp -__imp_spawnle -__imp_spawnl -__imp_getpid -__imp_execvpe -__imp_execvp -__imp_execve -__imp_execv -__imp_execlpe -__imp_execlp -__imp_execle -__imp_execl -__imp_cwait -__imp_memicmp -__imp_memccpy -__imp_write -__imp_unlink -__imp_umask -__imp_tell -__imp_sys_nerr -__imp_sopen -__imp_setmode -__imp_read -__imp_open -__imp_mktemp -__imp_lseek -__imp_locking -__imp_isatty -__imp_eof -__imp_dup2 -__imp_creat -__imp_close -__imp_chsize -__imp_chmod -__imp_access -__imp_rmdir -__imp_mkdir -__imp_getcwd -__imp_chdir -__imp_ungetch -__imp_putch -__imp_kbhit -__imp_getche -__imp_fpreset -__imp_getch -__imp_environ -__imp_daylight -__imp_cscanf -__imp_cputs -__imp_cprintf -__imp_cgets -wcsicoll -wcsupr -wcslwr -wcsset -wcsrev -wcsnset -wcsnicmp -wcsicmp -wcsdup -dup -tzset -tzname -timezone -strupr -strset -strrev -strnset -strnicmp -strlwr -strdup -stricmp -tempnam -rmtmp -putw -getw -fputchar -flushall -fileno -fgetchar -fdopen -ultoa -swab -putenv -onexit -ltoa -itoa -yn -y1 -y0 -jn -j1 -j0 -cabs -HUGE -gcvt -fcvt -ecvt -lsearch -lfind -spawnvpe -spawnvp -spawnve -spawnv -spawnlpe -spawnlp -spawnle -spawnl -getpid -execvpe -execvp -execve -execv -execlpe -execlp -execle -execl -cwait -memicmp -memccpy -write -unlink -umask -tell -sys_nerr -sopen -setmode -read -open -mktemp -lseek -locking -isatty -eof -dup2 -creat -close -chsize -chmod -access -rmdir -mkdir -getcwd -chdir -ungetch -putch -kbhit -getche -fpreset -getch -environ -daylight -cscanf -cputs -cprintf -cgets From a8ff537465eb34220f4ebf5bd1be0e254fd7344f Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Sun, 14 Apr 2019 09:51:46 +0200 Subject: [PATCH 20/20] Rename -FileName -> -OutFile --- windows/build_mingw.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/build_mingw.bat b/windows/build_mingw.bat index 2ac2e7fb..9cffd914 100644 --- a/windows/build_mingw.bat +++ b/windows/build_mingw.bat @@ -11,7 +11,7 @@ set PATH=%ROOT%\dmd2\windows\bin;%PATH% set MINGW_URL=https://netix.dl.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v%MINGW_VER%.tar.bz2 set USER_AGENT=[Microsoft.PowerShell.Commands.PSUserAgent]::FireFox -powershell -Command "Invoke-WebRequest %MINGW_URL% -FileName mingw-w64.tar.bz2 -UserAgent %User_Agent%" || exit /B 1 +powershell -Command "Invoke-WebRequest %MINGW_URL% -OutFile mingw-w64.tar.bz2 -UserAgent %User_Agent%" || exit /B 1 :: e.g. from git installation dos2unix "%ROOT%\windows\build_mingw.sha256sums"