[英]Speed up extremely slow MinGW-w64 compilation/linking?
How can I speed up MinGW-w64's extremely slow C++ compilation/linking?我怎样才能加快的MinGW-W64 ++真实编译/链接非常慢C 2
Compiling a trivial "Hello World" program:编译一个简单的“Hello World”程序:
#include <iostream>
int main()
{
std::cout << "hello world" << std::endl;
}
...takes 3 minutes (!) on this otherwise-unloaded Windows 10 box ( i7-6700 , 32GB of RAM, decent SATA SSD): ...在这个卸载的 Windows 10 机器( i7-6700、32GB内存、不错的 SATA SSD)上需要3 分钟(!):
> ptime.exe g++ main.cpp
ptime 1.0 for Win32, Freeware - http://www.pc-tools.net/
Copyright(C) 2002, Jem Berkes <jberkes@pc-tools.net>
=== g++ main.cpp ===
Execution time: 180.488 s
Process Explorer shows the g++
process tree bottoming out in ld.exe
which doesn't use any appreciable CPU or I/O for the duration. Process Explorer显示了在ld.exe
中触底的g++
进程树,它在此期间不使用任何明显的 CPU 或 I/O。
Running the g++
process tree through API Monitor shows there are three unusually long syscalls in ld.exe
: two NtCreateFile()
s and a NtOpenFile()
, each operating on a.exe
and taking 60 seconds apiece.通过API Monitor运行g++
进程树显示ld.exe
有三个异常长的系统调用:两个NtCreateFile()
和一个NtOpenFile()
,每个都在a.exe
运行,每个耗时 60 秒。
The slowness only happens when using the default a.exe
output;缓慢仅在使用默认a.exe
输出时发生; g++ -o foo.exe main.cpp
takes 2 seconds, tops. g++ -o foo.exe main.cpp
需要 2 秒, g++ -o foo.exe main.cpp
。
"Well don't use a.exe
as an output name then!" “那么不要使用a.exe
作为输出名称!” isn't really a solution since this behavior causes CMake to take ages doing compiler feature detection.并不是真正的解决方案,因为这种行为会导致 CMake 花费很长时间进行编译器功能检测。
GCC toolchain versions: GCC 工具链版本:
>g++ --version
g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
>ld --version
GNU ld (GNU Binutils) 2.30
Given that I couldn't repro the problem in a clean Windows 10 VM and the dependence on the output filename led me down the path of anti-virus/anti-malware interference.鉴于我无法在干净的 Windows 10 VM 中重现该问题,并且对输出文件名的依赖使我走上了防病毒/反恶意软件干扰的道路。
fltmc instances
listed several possible filesystem filter drivers; fltmc instances
列出了几种可能的文件系统过滤器驱动程序; guess-n-check narrowed it down to two of Carbon Black 's: carbonblackk
& ParityDriver
. guess-n-check 将其范围缩小到两个Carbon Black : carbonblackk
和ParityDriver
。
Using Regedit to disable them via setting Start
to 0x4
("Disabled", 0x2
== Automatic, 0x3
== Manual) in these two registry keys followed by a reboot fixed the slowness:使用 Regedit 通过在这两个注册表项中将Start
设置为0x4
("Disabled", 0x2
== Automatic, 0x3
== Manual) 来禁用它们,然后重新启动修复了缓慢:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.