Allow current toolchain for mingw to work and allow GCC 5.2 to also work if gcc-ar is current enough. Add a little more info about lto (nw)

This commit is contained in:
Cowering 2015-10-05 10:28:46 -05:00
parent 254c14b3f3
commit 7c302af80f
2 changed files with 86 additions and 72 deletions

View File

@ -44,7 +44,7 @@ function findfunction(x)
end
function layoutbuildtask(_folder, _name)
return { MAME_DIR .. "src/".._folder.."/".. _name ..".lay" , GEN_DIR .. _folder .. "/".._name..".lh",
return { MAME_DIR .. "src/".._folder.."/".. _name ..".lay" , GEN_DIR .. _folder .. "/".._name..".lh",
{ MAME_DIR .. "src/build/file2str.py" }, {"@echo Converting src/".._folder.."/".._name..".lay...", PYTHON .. " $(1) $(<) $(@) layout_".._name }};
end
@ -428,7 +428,7 @@ else
solution (_OPTIONS["subtarget"])
else
solution (_OPTIONS["target"] .. _OPTIONS["subtarget"])
end
end
end
configurations {
@ -466,7 +466,7 @@ configuration { "Debug", "vs*" }
flags {
"Symbols",
}
configuration { "Release", "vs*" }
flags {
"Optimize",
@ -516,7 +516,7 @@ msgarchiving ("Archiving $(notdir $@)...")
messageskip { "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage" }
if (_OPTIONS["DRIVERS"] == nil) then
if (_OPTIONS["DRIVERS"] == nil) then
if (not os.isfile(path.join("target", _OPTIONS["target"],_OPTIONS["subtarget"] .. ".lua"))) then
error("File definition for TARGET=" .. _OPTIONS["target"] .. " SUBTARGET=" .. _OPTIONS["subtarget"] .. " does not exist")
end
@ -579,7 +579,7 @@ if _OPTIONS["FASTDEBUG"]=="1" then
}
end
configuration { }
configuration { }
if _OPTIONS["PROFILER"]=="1" then
defines{
@ -723,15 +723,15 @@ if (_OPTIONS["targetos"]=="solaris") then
else
buildoptions_c {
-- "-std=gnu99",
"-std=gnu89",
"-std=gnu89",
-- "-Wpedantic",
-- "-pedantic",
-- "-Wno-variadic-macros",
-- "-Wno-long-long",
}
end
end
if _OPTIONS["CPP11"]=="1" then
buildoptions_cpp {
"-x c++",
@ -850,27 +850,32 @@ if _OPTIONS["OPTIMIZE"] then
end
if _OPTIONS["LTO"]=="1" then
buildoptions {
"-flto=2",
-- these next flags allow MAME to compile in linux GCC 5.2. odr warnings should be fixed as LTO randomly crashes otherwise
"-fno-fat-lto-objects", "-Wodr",
"-flto-compression-level=9", -- lto didn't work with anything less on linux with < 12G RAM
-- windows native mingw GCC 5.2 fails with -flto=x with x > 1. bug unfixed as of this date
"-flto=1",
"-fuse-linker-plugin",
-- these next flags allow MAME to compile in GCC 5.2. odr warnings should be fixed as LTO randomly crashes otherwise
-- some GCC 4.9.x on Windows do not have -Wodr and -flto-odr-type-merging enabled. adjust accordingly...
-- -ffat-lto-objects lets you link non-lto version without rebuilding all .o/.a
"-ffat-lto-objects",
"-flto-odr-type-merging",
"-flto-report", -- if you get an error in lto after [WPA] stage, but before [LTRANS] stage, you need more memory!
"-fmem-report-wpa","-fmem-report","-fpre-ipa-mem-report","-fpost-ipa-mem-report","-flto-report-wpa","-fmem-report","-fuse-linker-plugin",
"-Wodr",
"-flto-compression-level=9", -- lto didn't work with anything <9 on linux with < 12G RAM
-- "-flto-report", -- if you get an error in lto after [WPA] stage, but before [LTRANS] stage, you need more memory!
-- "-fmem-report-wpa","-fmem-report","-fpre-ipa-mem-report","-fpost-ipa-mem-report","-flto-report-wpa","-fmem-report",
}
-- same flags are needed by linker
linkoptions {
"-flto=2",
-- these next flags allow MAME to compile in linux GCC 5.2. odr warnings should be fixed as LTO randomly crashes otherwise
"-fno-fat-lto-objects", "-Wodr",
"-flto-compression-level=9", -- lto didn't work with anything less on linux with < 12G RAM
"-Wl,-no-keep-memory",
"-flto=1",
"-fuse-linker-plugin",
"-ffat-lto-objects",
"-flto-odr-type-merging",
"-flto-report", -- if you get an error in lto after [WPA] stage printout, but before any [LTRANS] section printout, you need more memory!
"-fmem-report-wpa","-fmem-report","-fpre-ipa-mem-report","-fpost-ipa-mem-report","-flto-report-wpa","-fmem-report","-fuse-linker-plugin",
"-Wodr",
"-flto-compression-level=9", -- lto didn't work with anything < 9 on linux with < 12G RAM
-- "-flto-report", -- if you get an error in lto after [WPA] stage, but before [LTRANS] stage, you need more memory!
-- "-fmem-report-wpa","-fmem-report","-fpre-ipa-mem-report","-fpost-ipa-mem-report","-flto-report-wpa","-fmem-report",
}
end
end
@ -906,7 +911,7 @@ if _OPTIONS["OPENMP"]=="1" then
defines {
"USE_OPENMP=1",
}
else
buildoptions {
"-Wno-unknown-pragmas",
@ -948,7 +953,7 @@ end
"-Wpointer-arith",
"-Wstrict-prototypes",
}
if _OPTIONS["targetos"]~="freebsd" then
buildoptions_c {
"-Wbad-function-cast",
@ -1000,11 +1005,11 @@ end
"-Wno-extern-c-compat",
}
end
if (version >= 70000) then
buildoptions {
"-Wno-tautological-undefined-compare",
}
end
if (version >= 70000) then
buildoptions {
"-Wno-tautological-undefined-compare",
}
end
else
if (version == 40201) then
buildoptions {
@ -1041,13 +1046,12 @@ end
-- next two should work, but compiler complains about end conditions that are int when loop variable is unsigned. maybe these can be fixed
-- "-funsafe-loop-optimizations",
-- "-Wunsafe-loop-optimizations",
-- this six flag combo lets MAME compile with LTO=1 on linux with no errors (whew!--Cowering) someone should probably pretty this up as you can't really debug with them enabled
"-fdevirtualize-at-ltrans","-fgcse-sm","-fgcse-las",
"-fipa-pta","-fipa-icf","-fvariable-expansion-in-unroller",
-- this six flag combo lets MAME compile with LTO=1 on linux with no errors and ~2% speed boost, but compile time is much longer
-- "-fdevirtualize-at-ltrans","-fgcse-sm","-fgcse-las",
-- "-fipa-pta","-fipa-icf","-fvariable-expansion-in-unroller",
}
end
end
end
--ifeq ($(findstring arm,$(UNAME)),arm)
@ -1158,7 +1162,7 @@ configuration { "vs*" }
buildoptions {
"/wd4025", -- warning C4025: 'number' : based pointer passed to function with variable arguments: parameter number
"/wd4003", -- warning C4003: not enough actual parameters for macro 'xxx'
"/wd4018", -- warning C4018: 'x' : signed/unsigned mismatch
"/wd4018", -- warning C4018: 'x' : signed/unsigned mismatch
"/wd4061", -- warning C4061: enumerator 'xxx' in switch of enum 'xxx' is not explicitly handled by a case label
"/wd4100", -- warning C4100: 'xxx' : unreferenced formal parameter
"/wd4127", -- warning C4127: conditional expression is constant
@ -1202,7 +1206,7 @@ configuration { "vs*" }
"/wd4365", -- warning C4365: 'action' : conversion from 'type_1' to 'type_2', signed/unsigned mismatch
"/wd4389", -- warning C4389: 'operator' : signed/unsigned mismatch
"/wd4245", -- warning C4245: 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
"/wd4388", -- warning C4388:
"/wd4388", -- warning C4388:
"/wd4267", -- warning C4267: 'var' : conversion from 'size_t' to 'type', possible loss of data
"/wd4005", -- warning C4005: The macro identifier is defined twice. The compiler uses the second macro definition
"/wd4350", -- warning C4350: behavior change: 'member1' called instead of 'member2'
@ -1211,10 +1215,10 @@ configuration { "vs*" }
"/wd4060", -- warning C4060: switch statement contains no 'case' or 'default' labels
"/wd4065", -- warning C4065: switch statement contains 'default' but no 'case' labels
"/wd4640", -- warning C4640: 'instance' : construction of local static object is not thread-safe
"/wd4290", -- warning C4290:
"/wd4290", -- warning C4290:
"/wd4355", -- warning C4355: 'this' : used in base member initializer list
"/wd4800", -- warning C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning)
"/wd4371", -- warning C4371:
"/wd4371", -- warning C4371:
"/wd4548", -- warning C4548: expression before comma has no effect; expected expression with side-effect
}
if _OPTIONS["vs"]=="intel-15" then

View File

@ -172,7 +172,7 @@ function toolchain(_buildDir, _subDir)
if _OPTIONS["distro"]=="ubuntu-intrepid" then
premake.gcc.cc = "@gcc -V 4.2"
premake.gcc.cxx = "@g++-4.2"
end
end
premake.gcc.ar = "ar"
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-linux")
end
@ -192,24 +192,34 @@ function toolchain(_buildDir, _subDir)
if "mingw32-gcc" == _OPTIONS["gcc"] then
if not os.getenv("MINGW32") or not os.getenv("MINGW32") then
print("Set MINGW32 envrionment variable.")
end
end
premake.gcc.cc = "$(MINGW32)/bin/i686-w64-mingw32-gcc"
premake.gcc.cxx = "$(MINGW32)/bin/i686-w64-mingw32-g++"
premake.gcc.ar = "$(MINGW32)/bin/ar"
-- lto docs say to use gcc-ar so that plugin is completely setup, but this doesn't work in windows with the current build tools' copy of gcc-ar.exe
-- premake.gcc.ar = "$(MINGW32)/bin/gcc-ar"
-- work around GCC 4.9.2 not having proper linker for LTO=1 usage
local version_4_ar = str_to_version(_OPTIONS["gcc_version"])
if (version_4_ar < 50000) then
premake.gcc.ar = "$(MINGW32)/bin/i686-w64-mingw32-ar"
end
if (version_4_ar >= 50000) then
premake.gcc.ar = "$(MINGW32)/bin/i686-w64-mingw32-gcc-ar"
end
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-mingw32-gcc")
end
if "mingw64-gcc" == _OPTIONS["gcc"] then
if not os.getenv("MINGW64") or not os.getenv("MINGW64") then
print("Set MINGW64 envrionment variable.")
end
end
premake.gcc.cc = "$(MINGW64)/bin/x86_64-w64-mingw32-gcc"
premake.gcc.cxx = "$(MINGW64)/bin/x86_64-w64-mingw32-g++"
premake.gcc.ar = "$(MINGW64)/bin/ar"
-- lto docs say to use gcc-ar so that plugin is completely setup, but this doesn't work in windows with the current build tools' copy of gcc-ar.exe
-- premake.gcc.ar = "$(MINGW64)/bin/gcc-ar"
-- work around GCC 4.9.2 not having proper linker for LTO=1 usage
local version_4_ar = str_to_version(_OPTIONS["gcc_version"])
if (version_4_ar < 50000) then
premake.gcc.ar = "$(MINGW64)/bin/x86_64-w64-mingw32-ar"
end
if (version_4_ar >= 50000) then
premake.gcc.ar = "$(MINGW64)/bin/x86_64-w64-mingw32-gcc-ar"
end
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-mingw64-gcc")
end
@ -339,14 +349,14 @@ function toolchain(_buildDir, _subDir)
platforms { "ARM" }
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-winstore81")
end
if "winstore82" == _OPTIONS["vs"] then
premake.vstudio.toolset = "v140"
premake.vstudio.storeapp = "8.2"
platforms { "ARM" }
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-winstore82")
end
if "intel-14" == _OPTIONS["vs"] then
premake.vstudio.toolset = "Intel C++ Compiler XE 14.0"
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-intel")
@ -361,11 +371,11 @@ function toolchain(_buildDir, _subDir)
premake.vstudio.toolset = ("v110_xp")
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-xp")
end
if ("vs2013-xp") == _OPTIONS["vs"] then
premake.vstudio.toolset = ("v120_xp")
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-xp")
end
end
elseif _ACTION == "xcode4" then
if "osx" == _OPTIONS["xcode"] then
@ -383,11 +393,11 @@ function toolchain(_buildDir, _subDir)
end
if (_OPTIONS["CXX"] ~= nil) then
premake.gcc.cxx = _OPTIONS["CXX"]
end
end
if (_OPTIONS["LD"] ~= nil) then
premake.gcc.ld = _OPTIONS["LD"]
end
end
configuration {} -- reset configuration
@ -437,12 +447,12 @@ function toolchain(_buildDir, _subDir)
configuration { "x64", "vs*-clang", "Debug" }
targetdir (_buildDir .. _ACTION .. "-clang/bin/x64/Debug")
configuration { "vs*-clang" }
buildoptions {
"-Qunused-arguments",
}
}
configuration { "winphone8* or winstore8*" }
removeflags {
"StaticRuntime",
@ -466,7 +476,7 @@ function toolchain(_buildDir, _subDir)
configuration { "x64", "mingw64-gcc" }
objdir (_buildDir .. "mingw-gcc" .. "/obj")
buildoptions { "-m64" }
configuration { "x64", "mingw64-gcc", "Release" }
targetdir (_buildDir .. "mingw-gcc" .. "/bin/x64/Release")
@ -494,7 +504,7 @@ function toolchain(_buildDir, _subDir)
configuration { "x32", "mingw-clang", "Debug" }
targetdir (_buildDir .. "win32_mingw-clang/bin/x32/Debug")
configuration { "x64", "mingw-clang" }
objdir (_buildDir .. "mingw-clang/obj")
buildoptions { "-m64" }
@ -502,14 +512,14 @@ function toolchain(_buildDir, _subDir)
"-isystem$(MINGW64)/x86_64-w64-mingw32/include/c++",
"-isystem$(MINGW64)/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32",
"-isystem$(MINGW64)/x86_64-w64-mingw32/include",
}
}
configuration { "x64", "mingw-clang", "Release" }
targetdir (_buildDir .. "mingw-clang/bin/x64/Release")
configuration { "x64", "mingw-clang", "Debug" }
targetdir (_buildDir .. "mingw-clang/bin/x64/Debug")
configuration { "linux-gcc", "x32" }
objdir (_buildDir .. "linux_gcc" .. "/obj")
buildoptions {
@ -530,7 +540,7 @@ function toolchain(_buildDir, _subDir)
configuration { "linux-gcc", "x64", "Release" }
targetdir (_buildDir .. "linux_gcc" .. "/bin/x64/Release")
configuration { "linux-gcc", "x64", "Debug" }
targetdir (_buildDir .. "linux_gcc" .. "/bin/x64/Debug")
@ -557,7 +567,7 @@ function toolchain(_buildDir, _subDir)
configuration { "linux-clang", "x64", "Debug" }
targetdir (_buildDir .. "linux_clang" .. "/bin/x64/Debug")
configuration { "solaris", "x32" }
objdir (_buildDir .. "solaris" .. "/obj")
buildoptions {
@ -566,7 +576,7 @@ function toolchain(_buildDir, _subDir)
configuration { "solaris", "x32", "Release" }
targetdir (_buildDir .. "solaris" .. "/bin/x32/Release")
configuration { "solaris", "x32", "Debug" }
targetdir (_buildDir .. "solaris" .. "/bin/x32/Debug")
@ -578,7 +588,7 @@ function toolchain(_buildDir, _subDir)
configuration { "solaris", "x64", "Release" }
targetdir (_buildDir .. "solaris" .. "/bin/x64/Release")
configuration { "solaris", "x64", "Debug" }
targetdir (_buildDir .. "solaris" .. "/bin/x64/Debug")
@ -590,7 +600,7 @@ function toolchain(_buildDir, _subDir)
configuration { "freebsd", "x32", "Release" }
targetdir (_buildDir .. "freebsd" .. "/bin/x32/Release")
configuration { "freebsd", "x32", "Debug" }
targetdir (_buildDir .. "freebsd" .. "/bin/x32/Debug")
@ -601,7 +611,7 @@ function toolchain(_buildDir, _subDir)
}
configuration { "freebsd", "x64", "Release" }
targetdir (_buildDir .. "freebsd" .. "/bin/x64/Release")
configuration { "freebsd", "x64", "Debug" }
targetdir (_buildDir .. "freebsd" .. "/bin/x64/Debug")
@ -765,7 +775,7 @@ function toolchain(_buildDir, _subDir)
"-fdiagnostics-show-option",
"-fdata-sections",
"-ffunction-sections",
"-Wunused-value",
"-Wunused-value",
}
configuration { "nacl or nacl-arm" }
includedirs {
@ -773,10 +783,10 @@ function toolchain(_buildDir, _subDir)
"$(NACL_SDK_ROOT)/include/newlib",
}
configuration { "pnacl" }
configuration { "pnacl" }
buildoptions {
"-Wno-tautological-undefined-compare",
"-Wno-cast-align",
"-Wno-cast-align",
}
includedirs {
"$(NACL_SDK_ROOT)/include",
@ -833,7 +843,7 @@ function toolchain(_buildDir, _subDir)
configuration { "osx*", "x32", "Debug" }
targetdir (_buildDir .. "osx_clang" .. "/bin/x32/Debug")
configuration { "osx*", "x64" }
objdir (_buildDir .. "osx_clang" .. "/obj")
buildoptions {
@ -845,7 +855,7 @@ function toolchain(_buildDir, _subDir)
configuration { "osx*", "x64", "Debug" }
targetdir (_buildDir .. "osx_clang" .. "/bin/x64/Debug")
configuration { "ios-arm" }
targetdir (_buildDir .. "ios-arm" .. "/bin")
objdir (_buildDir .. "ios-arm" .. "/obj")