Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable LTO #1627

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Enable LTO for compiling Spicy/HILTI sources.
bbannier committed Dec 22, 2023
commit 57813d895c76311650535a84be346f41b5dd1ff5
15 changes: 8 additions & 7 deletions hilti/toolchain/src/config.cc.in
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ void Configuration::init(bool use_build_directory) {
prefix("${HILTI_CONFIG_RUNTIME_CXX_INCLUDE_DIRS}", "-I", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_CXX_FLAGS_DEBUG}", "", installation_tag)});

runtime_cxx_flags_release = flatten({"-fPIC", "-std=c++17", "-g", "-O3", "-DNDEBUG", "-fvisibility=hidden",
runtime_cxx_flags_release = flatten({"-fPIC", "-std=c++17", "-g", "-O3", "-DNDEBUG", "-fvisibility=hidden", "-flto",
prefix("${HILTI_CONFIG_RUNTIME_CXX_INCLUDE_DIRS}", "-I", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_CXX_FLAGS_RELEASE}", "", installation_tag)});

@@ -162,12 +162,13 @@ void Configuration::init(bool use_build_directory) {
prefix("${HILTI_CONFIG_RUNTIME_LD_FLAGS_DEBUG}", "", installation_tag),
prefix(CMAKE_THREAD_LIBS_INIT, "-l", installation_tag), prefix(CMAKE_DL_LIBS, "-l", installation_tag)});

runtime_ld_flags_release = flatten(
{prefix("${HILTI_CONFIG_RUNTIME_CXX_LIBRARY_DIRS}", "-L", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_CXX_LIBRARY_DIRS}", "-Wl,-rpath,", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_LIBRARIES_RELEASE}", "-l", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_LD_FLAGS_RELEASE}", "", installation_tag),
prefix(CMAKE_THREAD_LIBS_INIT, "-l", installation_tag), prefix(CMAKE_DL_LIBS, "-l", installation_tag)});
runtime_ld_flags_release =
flatten({prefix("${HILTI_CONFIG_RUNTIME_CXX_LIBRARY_DIRS}", "-L", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_CXX_LIBRARY_DIRS}", "-Wl,-rpath,", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_LIBRARIES_RELEASE}", "-l", installation_tag),
prefix("${HILTI_CONFIG_RUNTIME_LD_FLAGS_RELEASE}", "", installation_tag),
prefix(CMAKE_THREAD_LIBS_INIT, "-l", installation_tag), prefix(CMAKE_DL_LIBS, "-l", installation_tag),
"-flto"});

hlto_cxx_flags_debug = runtime_cxx_flags_debug;
hlto_cxx_flags_release = runtime_cxx_flags_release;
5 changes: 2 additions & 3 deletions scripts/precompile-headers.sh
Original file line number Diff line number Diff line change
@@ -64,11 +64,10 @@ cp "${LIBHILTI}" "${CACHE}/precompiled_libhilti_debug.h"
$("${HILTI_CONFIG}" --cxx --cxxflags --debug) -x c++-header "${LIBHILTI}" -o "${CACHE}/precompiled_libhilti_debug.h.gch"

cp "${LIBHILTI}" "${CACHE}/precompiled_libhilti.h"

$("${HILTI_CONFIG}" --cxx --cxxflags) -x c++-header "${LIBHILTI}" -o "${CACHE}/precompiled_libhilti.h.gch"
$("${HILTI_CONFIG}" --cxx --cxxflags | sed 's/-flto//g') -x c++-header "${LIBHILTI}" -o "${CACHE}/precompiled_libhilti.h.gch"

cp "${LIBSPICY}" "${CACHE}/precompiled_libspicy_debug.h"
$("${SPICY_CONFIG}" --cxx --cxxflags --debug) -x c++-header "${LIBSPICY}" -o "${CACHE}/precompiled_libspicy_debug.h.gch"

cp "${LIBSPICY}" "${CACHE}/precompiled_libspicy.h"
$("${SPICY_CONFIG}" --cxx --cxxflags) -x c++-header "${LIBSPICY}" -o "${CACHE}/precompiled_libspicy.h.gch"
$("${SPICY_CONFIG}" --cxx --cxxflags | sed 's/-flto//g') -x c++-header "${LIBSPICY}" -o "${CACHE}/precompiled_libspicy.h.gch"