Jelajahi Sumber

SCons: make use_lto a global option and opt-in for iphone

Supersedes #12553, see discussion in #12552.
Rémi Verschelde 7 tahun lalu
induk
melakukan
cefdb34f6c
4 mengubah file dengan 7 tambahan dan 4 penghapusan
  1. 1 0
      SConstruct
  2. 6 2
      platform/iphone/detect.py
  3. 0 1
      platform/windows/detect.py
  4. 0 1
      platform/x11/detect.py

+ 1 - 0
SConstruct

@@ -143,6 +143,7 @@ opts.Add('p', "Platform (alias for 'platform')", '')
 opts.Add('platform', "Target platform (%s)" % ('|'.join(platform_list), ), '')
 opts.Add(EnumVariable('target', "Compilation target", 'debug', ('debug', 'release_debug', 'release')))
 opts.Add(BoolVariable('tools', "Build the tools a.k.a. the Godot editor", True))
+opts.Add(BoolVariable('use_lto', 'Use linking time optimization', False))
 
 # Components
 opts.Add(BoolVariable('deprecated', "Enable deprecated features", True))

+ 6 - 2
platform/iphone/detect.py

@@ -47,8 +47,8 @@ def configure(env):
 
     if (env["target"].startswith("release")):
         env.Append(CPPFLAGS=['-DNDEBUG', '-DNS_BLOCK_ASSERTIONS=1'])
-        env.Append(CPPFLAGS=['-O2', '-flto', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations'])
-        env.Append(LINKFLAGS=['-O2', '-flto'])
+        env.Append(CPPFLAGS=['-O2', '-ftree-vectorize', '-fomit-frame-pointer', '-ffast-math', '-funsafe-math-optimizations'])
+        env.Append(LINKFLAGS=['-O2'])
 
         if env["target"] == "release_debug":
             env.Append(CPPFLAGS=['-DDEBUG_ENABLED'])
@@ -56,6 +56,10 @@ def configure(env):
     elif (env["target"] == "debug"):
         env.Append(CPPFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED', '-DDEBUG_MEMORY_ENABLED'])
 
+    if (env["use_lto"]):
+        env.Append(CPPFLAGS=['-flto'])
+        env.Append(LINKFLAGS=['-flto'])
+
     ## Architecture
 
     if env["ios_sim"] or env["arch"] == "x86":  # i386, simulator

+ 0 - 1
platform/windows/detect.py

@@ -64,7 +64,6 @@ def get_opts():
     return [
         ('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32),
         ('mingw_prefix_64', 'MinGW prefix (Win64)', mingw64),
-        BoolVariable('use_lto', 'Use link time optimization (when using MingW)', False),
         EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')),
     ]
 

+ 0 - 1
platform/x11/detect.py

@@ -52,7 +52,6 @@ def get_opts():
         BoolVariable('use_static_cpp', 'Link stdc++ statically', False),
         BoolVariable('use_sanitizer', 'Use LLVM compiler address sanitizer', False),
         BoolVariable('use_leak_sanitizer', 'Use LLVM compiler memory leaks sanitizer (implies use_sanitizer)', False),
-        BoolVariable('use_lto', 'Use link time optimization', False),
         BoolVariable('pulseaudio', 'Detect & use pulseaudio', True),
         BoolVariable('udev', 'Use udev for gamepad connection callbacks', False),
         EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')),