Add -flto as link flag, also fix missing <string> include in main.cpp causing a build failure with gcc10

This commit is contained in:
Nadia Holmquist Pedersen 2020-05-10 23:09:17 +02:00
parent d3f14b7a8b
commit 5c5d280dd5
3 changed files with 3 additions and 1 deletions

View File

@ -22,6 +22,7 @@ endif()
if(ENABLE_LTO) if(ENABLE_LTO)
add_compile_options(-O3 -flto) add_compile_options(-O3 -flto)
add_link_options(-flto)
set(CMAKE_AR "gcc-ar") set(CMAKE_AR "gcc-ar")
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>") set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH true) set(CMAKE_C_ARCHIVE_FINISH true)

View File

@ -65,7 +65,7 @@ macro(_handle_static)
OUTPUT ${_oname} OUTPUT ${_oname}
DEPENDS ${_LIBUINAME} DEPENDS ${_LIBUINAME}
COMMAND COMMAND
ld -r --whole-archive ${_aname} -o ${_oname} ${CMAKE_LINKER} -r --whole-archive ${_aname} -o ${_oname}
COMMAND COMMAND
objcopy --localize-hidden ${_oname} objcopy --localize-hidden ${_oname}
COMMENT "Removing hidden symbols") COMMENT "Removing hidden symbols")

View File

@ -20,6 +20,7 @@
#include <time.h> #include <time.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <string>
#ifndef __WIN32__ #ifndef __WIN32__
#include <glib.h> #include <glib.h>