Ticket #1755: lto.patch

File lto.patch, 1.8 KB (added by fabio, 11 years ago)
  • premake4.lua

    When: 2012-12-10
    What: optional gcc LTO support with --enable-lto option
    Who: Fabio Pedretti <fabio.ped@libero.it>
    
    old new newoption { trigger = "icc", description  
    77newoption { trigger = "outpath", description = "Location for generated project files" }
    88newoption { trigger = "without-audio", description = "Disable use of OpenAL/Ogg/Vorbis APIs" }
    99newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed. Has no effect on Windows builds" }
     10newoption { trigger = "enable-lto", description = "Enable experimental GCC LTO (Link Time Optimization)" }
    1011newoption { trigger = "without-nvtt", description = "Disable use of NVTT" }
    1112newoption { trigger = "without-tests", description = "Disable generation of test projects" }
    1213newoption { trigger = "without-pch", description = "Disable generation and usage of precompiled headers" }
    else  
    9596        minor = 0+minor
    9697        has_broken_pch = (major < 4 or (major == 4 and minor < 2))
    9798        if has_broken_pch then
    98             print("WARNING: Detected GCC <4.2 -- disabling PCH for Atlas (will increase build times)")
     99            print("WARNING: Detected GCC < 4.2 -- disabling PCH for Atlas (will increase build times)")
     100        end
     101        if _OPTIONS["enable-lto"] then
     102            has_broken_lto = (major < 4 or (major == 4 and minor < 7))
     103            if has_broken_lto then
     104                print("WARNING: Detected GCC < 4.7 -- disabling GCC LTO")
     105            end
    99106        end
    100107    end
    101108end
    function project_set_build_flags()  
    235242                    }
    236243                end
    237244
     245                if _OPTIONS["enable-lto"] and not has_broken_lto then
     246                    buildoptions { "-flto" }
     247                    linkoptions { "-flto" }
     248                end
     249
    238250                if arch == "x86" or arch == "amd64" then
    239251                    buildoptions {
    240252                        -- enable SSE intrinsics