Fix compiling with TDM-GCC-64 and -O3

By default, TDM-GCC-64 was using -march=x86-64, which for whatever reason caused issues when compiling with -O3.  This makes scons force it to use -march=pentiumpro, the same as TDM-GCC-32.  This also changes the release build to use -O3 instead of -O2, which matches the release build default used by cmake and code::blocks.

Added -march=pentiumpro on Windows for -O3 build

m5
This commit is contained in:
Pentarctagon 2016-11-11 22:20:04 -06:00 committed by pentarctagon
parent e55e4a6d60
commit 8ea76ce432
2 changed files with 25 additions and 4 deletions

View file

@ -508,6 +508,23 @@ list(REMOVE_ITEM CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG")
string(REPLACE ";" " " CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}" CACHE STRING "removed NDEBUG flag" FORCE)
# add pentiumpro arch for windows builds with -O3, otherwise resulting executable may not work
if(WIN32)
separate_arguments(CMAKE_CXX_FLAGS_RELEASE)
list(APPEND CMAKE_CXX_FLAGS_RELEASE "-march=pentiumpro")
list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS_RELEASE)
string(REPLACE ";" " " CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "added -march=pentiumpro" FORCE)
MESSAGE("added -march=pentiumpro to Release build")
separate_arguments(CMAKE_C_FLAGS_RELEASE)
list(APPEND CMAKE_C_FLAGS_RELEASE "-march=pentiumpro")
list(REMOVE_DUPLICATES CMAKE_C_FLAGS_RELEASE)
string(REPLACE ";" " " CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}" CACHE STRING "added -march=pentiumpro" FORCE)
MESSAGE("added -march=pentiumpro to Release build")
endif(WIN32)
# replace the default Debug flag of -g with -O0 -DDEBUG -ggdb3
# this matches the flags of scons' debug build
MESSAGE("Replacing flags used for Debug build")

View file

@ -505,10 +505,14 @@ for env in [test_env, client_env, env]:
env.AppendUnique(CXXFLAGS = Split("-Wold-style-cast"))
if env['sanitize']:
env.AppendUnique(CCFLAGS = ["-fsanitize=" + env["sanitize"]], LINKFLAGS = ["-fsanitize=" + env["sanitize"]])
env["OPT_FLAGS"] = "-O2"
env["OPT_FLAGS"] = "-O3"
env["DEBUG_FLAGS"] = Split("-O0 -DDEBUG -ggdb3")
# because apparently telling the compiler, linker, AND windres to be 32-bit just isn't enough
if env["PLATFORM"] == 'win32':
env["OPT_FLAGS"] = "$OPT_FLAGS -march=pentiumpro"
if env["enable_lto"] == "yes":
env["HIGH_OPT_COMP_FLAGS"] = "-O3 -march=native -flto"
env["HIGH_OPT_LINK_FLAGS"] = "$HIGH_OPT_COMP_FLAGS -fuse-ld=gold"
@ -558,10 +562,10 @@ SConscript(dirs = Split("po doc packaging/windows packaging/systemd"))
binaries = Split("wesnoth wesnothd cutter exploder campaignd test")
builds = {
"base" : dict(CCFLAGS = "$OPT_FLAGS"), # Don't build in subdirectory
"base" : dict(CCFLAGS = Split("$OPT_FLAGS")), # Don't build in subdirectory
"debug" : dict(CCFLAGS = Split("$DEBUG_FLAGS")),
"glibcxx_debug" : dict(CPPDEFINES = Split("_GLIBCXX_DEBUG _GLIBCXX_DEBUG_PEDANTIC")),
"release" : dict(CCFLAGS = "$OPT_FLAGS"),
"release" : dict(CCFLAGS = Split("$OPT_FLAGS")),
"profile" : dict(CCFLAGS = "-pg", LINKFLAGS = "-pg"),
"optimize" : dict(CCFLAGS = Split("$HIGH_OPT_COMP_FLAGS"), LINKFLAGS=Split("$HIGH_OPT_LINK_FLAGS"))
}