StephanTLavavej / mingw-distro

MinGW distro build scripts.
494 stars 55 forks source link

Investigate LTO issues #34

Closed StephanTLavavej closed 7 years ago

StephanTLavavej commented 7 years ago

LTO is reportedly unusable without copying files around. See this reddit thread. I should investigate whether this is true, and whether this is the right solution.

octoploid commented 7 years ago

Yes, this is the right solution. Alternatively, you can also use the gcc wrappers gcc-ar, etc.

StephanTLavavej commented 7 years ago

I tried this:

diff --git a/mingw-w64+gcc.sh b/mingw-w64+gcc.sh
index 8f87af0..c2e2059 100644
--- a/mingw-w64+gcc.sh
+++ b/mingw-w64+gcc.sh
@@ -80,4 +80,8 @@ rm -rf bin/c++.exe bin/x86_64-w64-mingw32-* share
 rm -rf mingw x86_64-w64-mingw32/lib64
 find -name "*.exe" -type f -print -exec strip -s {} ";"

+# Enable LTO.
+mkdir lib/bfd-plugins
+cp libexec/gcc/x86_64-w64-mingw32/7.1.0/liblto_plugin-0.dll lib/bfd-plugins
+
 7z -mx0 a ../mingw-w64+gcc.7z *

But Hello World crashes with -O3 -flto.