Minor architecture/optimization improvements.

Use the X86_64 variable instead of AMD64 for this architecture in cmake.

For our upstream binary builds, use -march=core2 -mtune=rocketlake for
X86_64 on macOS, -march=core2 -mtune=znver3 for X86_64 on non-macOS (not
currently used) and -march=pentium-mmx -mtune=core2 for the future
Windows XP 32 bit MinGW build.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2021-10-31 18:23:34 -07:00
parent b6837cea05
commit b3cc663344
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
2 changed files with 30 additions and 18 deletions

View File

@ -343,8 +343,8 @@ if(APPLE)
endif()
# We do not support amd64 asm yet
if(AMD64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX))
message(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on AMD64 yet.")
if(X86_64 AND (ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS OR ENABLE_MMX))
message(FATAL_ERROR "The options ASM_CORE, ASM_SCALERS and MMX are not supported on X86_64 yet.")
endif()
if(ENABLE_ASM_CORE OR ENABLE_ASM_SCALERS)
@ -516,6 +516,8 @@ ProcessorCount(num_cpus)
# Compiler stuff
option(UPSTREAM_RELEASE "do some optimizations and release automation tasks" OFF)
if(CMAKE_C_COMPILER_ID STREQUAL Clang AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
include(LLVMToolchain)
endif()
@ -551,7 +553,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
unset(MY_C_OPT_FLAGS)
if(X86_32 OR AMD64)
if(X86_32 OR X86_64)
set(MY_C_OPT_FLAGS -mfpmath=sse -msse2)
endif()
@ -563,9 +565,24 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -O2)
endif()
# only use -mtune=generic on PC architectures
if(X86_32 OR AMD64)
set(MY_C_OPT_FLAGS ${MY_C_OPT_FLAGS} -mtune=generic)
# Common flags.
set(MY_C_FLAGS -pipe -Wformat -Wformat-security -feliminate-unused-debug-types)
# Enable some optimizations for our upstream binary builds.
if(UPSTREAM_RELEASE)
# Optimize for Core2 and tune for Rocketlake on macOS and Zen3 for the rest
# on X86_64.
if(X86_64)
set(MY_C_FLAGS ${MY_C_FLAGS} -march=core2)
if(APPLE)
set(MY_C_FLAGS ${MY_C_FLAGS} -mtune=rocketlake)
else()
set(MY_C_FLAGS ${MY_C_FLAGS} -mtune=znver3)
endif()
# Optimize for pentium-mmx and tune for Core2 on X86_32.
elseif(X86_32)
set(MY_C_FLAGS ${MY_C_FLAGS} -march=pentium-mmx -mtune=core2)
endif()
endif()
# common debug flags
@ -596,9 +613,6 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
endif()
endif()
# common flags
set(MY_C_FLAGS -pipe -Wformat -Wformat-security -feliminate-unused-debug-types)
if(ENABLE_SSP AND CMAKE_BUILD_TYPE STREQUAL Debug)
if(WIN32)
set(SSP_STATIC ON)
@ -780,8 +794,8 @@ elseif("${CMAKE_SYSTEM}" MATCHES "Linux")
add_definitions(-DELF)
endif()
if(AMD64)
add_definitions(-D__AMD64__)
if(X86_64)
add_definitions(-D__AMD64__ -D__X86_64__)
endif()
add_subdirectory (fex)

View File

@ -91,7 +91,7 @@ endif()
# on VS with vcpkg we can't use FindwxWidgets, we have to set everything up
# manually because the package is broken
if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR X86_64))
# set up wxwidgets stuff
set(libtype u)
unset(arch_suffix)
@ -373,7 +373,7 @@ int main(int argc, char** argv)
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -fpermissive -w "-I${CMAKE_SOURCE_DIR}/dependencies/minhook/include")
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -Wl,--subsystem,console)
if(AMD64)
if(X86_64)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook_64.a")
else() # assume 32 bit windows
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "${CMAKE_SOURCE_DIR}/dependencies/minhook/libMinHook.a")
@ -783,7 +783,7 @@ list(APPEND ALL_SRC_WX autoupdater/wxmsw/winsparkle-wrapper.cpp)
list(APPEND ALL_HDR_WX autoupdater/wxmsw/winsparkle-wrapper.h)
list(APPEND ALL_HDR_WX autoupdater/wxmsw/winsparkle-rc.h)
if(WIN32 AND (AMD64 OR X86_32) AND ENABLE_ONLINEUPDATES)
if(WIN32 AND (X86_64 OR X86_32) AND ENABLE_ONLINEUPDATES)
list(APPEND SRC_WX autoupdater/wxmsw/autoupdater.cpp)
list(APPEND HDR_WX autoupdater/autoupdater.h)
list(APPEND SRC_WX autoupdater/wxmsw/winsparkle-wrapper.cpp)
@ -876,7 +876,7 @@ add_executable(
${CM_STUFF}
)
if(WIN32 AND (AMD64 OR X86_32) AND ENABLE_ONLINEUPDATES)
if(WIN32 AND (X86_64 OR X86_32) AND ENABLE_ONLINEUPDATES)
if(NOT DEFINED WINSPARKLE_BIN_RELEASE_DIR)
set(WINSPARKLE_BIN_RELEASE_DIR ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0)
endif()
@ -886,7 +886,7 @@ if(WIN32 AND (AMD64 OR X86_32) AND ENABLE_ONLINEUPDATES)
PRIVATE ${WINSPARKLE_BIN_RELEASE_DIR}/include
)
if(AMD64)
if(X86_64)
set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/x64/Release/WinSparkle.dll)
else()
set(WINSPARKLE_DLL ${CMAKE_SOURCE_DIR}/dependencies/WinSparkle-0.6.0/Release/WinSparkle.dll)
@ -1060,8 +1060,6 @@ if(ENABLE_NLS)
)
endif()
option(UPSTREAM_RELEASE "do some release automation tasks" OFF)
find_program(GPG_PROGRAM gpg)
if(GPG_PROGRAM)