diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e564f15..84b8a012 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,7 +70,12 @@ elseif (UNIX) find_package(Curses REQUIRED) # linker flags - set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s") + if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO" OR ${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic") + else () + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-z,norelro,-O3,--sort-common,--as-needed,--relax,-z,combreloc,-z,global,--no-omagic,-x,-s") + endif () + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") # don't put anything too crazy in debug...and any common flags go into CMAKE_CXX_FLAGS @@ -90,13 +95,15 @@ elseif (UNIX) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb") - # RELWITHDEBINFO is used for building profiled builds + # RELWITHDEBINFO is used for building bins that produce profdata files set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-instr-generate") # MINSIZEREL is used for profiled, flto builds + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_RELEASE} -flto -fwhole-program-vtables") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # O3 and Ofast include one or more flags that cause java to crash when using gcc6 - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math -fno-unroll-loops -fno-tree-loop-optimize") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -fno-signed-zeros -freciprocal-math + -fno-unroll-loops -fno-tree-loop-optimize") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") @@ -114,12 +121,17 @@ elseif (UNIX) # release and debug are internal use only if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR ${CMAKE_BUILD_TYPE} STREQUAL "Release") add_definitions(-DSTELLA_INTERNAL) - endif() + endif () # this is so some profile specific stuff is turned on in the code if (${CMAKE_BUILD_TYPE} STREQUAL "RELWITHDEBINFO") add_definitions(-DENABLE_PROFILING) - endif() + endif () + + # this is so some profile specific stuff is turned on in the code + if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + add_definitions(-DENABLE_PROFILING) + endif () endif () add_subdirectory(external) diff --git a/engine/server/application/CommoditiesServer/src/CMakeLists.txt b/engine/server/application/CommoditiesServer/src/CMakeLists.txt index 8ba55ff9..321f60c0 100644 --- a/engine/server/application/CommoditiesServer/src/CMakeLists.txt +++ b/engine/server/application/CommoditiesServer/src/CMakeLists.txt @@ -1,4 +1,8 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/CommoditiesServer.profdata) +endif() + set(SHARED_SOURCES shared/AuctionBid.cpp shared/AuctionBid.h diff --git a/engine/server/application/ConnectionServer/src/CMakeLists.txt b/engine/server/application/ConnectionServer/src/CMakeLists.txt index 6737fd50..67a46a8a 100644 --- a/engine/server/application/ConnectionServer/src/CMakeLists.txt +++ b/engine/server/application/ConnectionServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/ConnectionServer.profdata) +endif() set(SHARED_SOURCES shared/CentralConnection.cpp diff --git a/engine/server/application/LoginServer/src/CMakeLists.txt b/engine/server/application/LoginServer/src/CMakeLists.txt index 147c47df..03f39400 100644 --- a/engine/server/application/LoginServer/src/CMakeLists.txt +++ b/engine/server/application/LoginServer/src/CMakeLists.txt @@ -1,3 +1,7 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/LoginServer.profdata) +endif() + set(SHARED_SOURCES shared/CentralServerConnection.cpp shared/CentralServerConnection.h diff --git a/engine/server/application/PlanetServer/src/CMakeLists.txt b/engine/server/application/PlanetServer/src/CMakeLists.txt index e0eefd7a..615d618e 100644 --- a/engine/server/application/PlanetServer/src/CMakeLists.txt +++ b/engine/server/application/PlanetServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/PlanetServer.profdata) +endif() set(SHARED_SOURCES shared/CentralServerConnection.cpp diff --git a/game/server/application/SwgDatabaseServer/src/CMakeLists.txt b/game/server/application/SwgDatabaseServer/src/CMakeLists.txt index 776d387f..af451078 100644 --- a/game/server/application/SwgDatabaseServer/src/CMakeLists.txt +++ b/game/server/application/SwgDatabaseServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/SwgDatabaseServer.profdata) +endif() set(SHARED_SOURCES shared/buffers/AuctionLocationsBuffer.cpp diff --git a/game/server/application/SwgGameServer/src/CMakeLists.txt b/game/server/application/SwgGameServer/src/CMakeLists.txt index 8b7318ef..77d3885d 100644 --- a/game/server/application/SwgGameServer/src/CMakeLists.txt +++ b/game/server/application/SwgGameServer/src/CMakeLists.txt @@ -1,3 +1,6 @@ +if (${CMAKE_BUILD_TYPE} STREQUAL "MINSIZEREL") + add_compile_options(-fprofile-instr-use=${PROJECT_SOURCE_DIR}/src/linux/SwgGameServer.profdata) +endif() set(SHARED_SOURCES shared/combat/combat.def