Using GCC’s link-time optimization with static linked libraries

Here is an MCVE CMake project that reproduces the problem: $ ls -R hellow hellow: CMakeLists.txt hello.c libhello.c $ cat hellow/CMakeLists.txt cmake_minimum_required (VERSION 2.6) project (hellow) SET(CMAKE_C_FLAGS “${CMAKE_C_FLAGS} -flto”) SET(CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} -flto”) #SET(CMAKE_AR “gcc-ar”) #SET(CMAKE_C_ARCHIVE_CREATE “<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>”) #SET(CMAKE_C_ARCHIVE_FINISH true) add_library(hello STATIC libhello.c) add_executable(hellow hello.c) target_link_libraries(hellow hello) add_dependencies(hellow hello) $ cat hellow/hello.c extern … Read more

How do I enable link time optimization (LTO) with CMake?

Good news! CMake v3.9 finally supports LTO. Example Here’s an example code to show how it works: cmake_minimum_required(VERSION 3.9.4) include(CheckIPOSupported) check_ipo_supported(RESULT supported OUTPUT error) add_executable(example Example.cpp) if( supported ) message(STATUS “IPO / LTO enabled”) set_property(TARGET example PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) else() message(STATUS “IPO / LTO not supported: <${error}>”) endif() For GCC this adds -flto -fno-fat-lto-objects to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)