ソースを参照

Windows: Use `/bigobj` only for debug builds, breaks GCC LTO

Building `target=release` and `target=release_debug` builds with MinGW-GCC
errors when linking with LTO.

Since it's only needed for `target=debug` builds anyway (bigger objects), which
we don't build with LTO, this works around the issue.
Rémi Verschelde 3 年 前
コミット
64d7df1e5f
1 ファイル変更6 行追加2 行削除
  1. 6 2
      platform/windows/detect.py

+ 6 - 2
platform/windows/detect.py

@@ -206,6 +206,8 @@ def configure_msvc(env, manual_msvc_config):
 
 
     elif env["target"] == "debug":
     elif env["target"] == "debug":
         env.AppendUnique(CCFLAGS=["/Zi", "/FS", "/Od", "/EHsc"])
         env.AppendUnique(CCFLAGS=["/Zi", "/FS", "/Od", "/EHsc"])
+        # Allow big objects. Only needed for debug, see MinGW branch for rationale.
+        env.AppendUnique(CCFLAGS=["/bigobj"])
         env.Append(LINKFLAGS=["/DEBUG"])
         env.Append(LINKFLAGS=["/DEBUG"])
 
 
     if env["debug_symbols"]:
     if env["debug_symbols"]:
@@ -227,7 +229,6 @@ def configure_msvc(env, manual_msvc_config):
 
 
     env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"])
     env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"])
     env.AppendUnique(CCFLAGS=["/utf-8"])  # Force to use Unicode encoding.
     env.AppendUnique(CCFLAGS=["/utf-8"])  # Force to use Unicode encoding.
-    env.AppendUnique(CCFLAGS=["/bigobj"])  # Allow big objects, no drawbacks.
     env.AppendUnique(CXXFLAGS=["/TP"])  # assume all sources are C++
     env.AppendUnique(CXXFLAGS=["/TP"])  # assume all sources are C++
 
 
     if manual_msvc_config:  # should be automatic if SCons found it
     if manual_msvc_config:  # should be automatic if SCons found it
@@ -359,6 +360,10 @@ def configure_mingw(env):
 
 
     elif env["target"] == "debug":
     elif env["target"] == "debug":
         env.Append(CCFLAGS=["-g3"])
         env.Append(CCFLAGS=["-g3"])
+        # Allow big objects. It's supposed not to have drawbacks but seems to break
+        # GCC LTO, so enabling for debug builds only (which are not built with LTO
+        # and are the only ones with too big objects).
+        env.Append(CCFLAGS=["-Wa,-mbig-obj"])
 
 
     if env["windows_subsystem"] == "gui":
     if env["windows_subsystem"] == "gui":
         env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
         env.Append(LINKFLAGS=["-Wl,--subsystem,windows"])
@@ -422,7 +427,6 @@ def configure_mingw(env):
     ## Compile flags
     ## Compile flags
 
 
     env.Append(CCFLAGS=["-mwindows"])
     env.Append(CCFLAGS=["-mwindows"])
-    env.Append(CCFLAGS=["-Wa,-mbig-obj"])  # Allow big objects, no drawbacks.
 
 
     env.Append(CPPDEFINES=["WINDOWS_ENABLED", "WASAPI_ENABLED", "WINMIDI_ENABLED"])
     env.Append(CPPDEFINES=["WINDOWS_ENABLED", "WASAPI_ENABLED", "WINMIDI_ENABLED"])
     env.Append(CPPDEFINES=[("WINVER", env["target_win_version"]), ("_WIN32_WINNT", env["target_win_version"])])
     env.Append(CPPDEFINES=[("WINVER", env["target_win_version"]), ("_WIN32_WINNT", env["target_win_version"])])