From 75b961eb9572606e3cea2e5f649d47b5dd2207af Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 25 Apr 2020 21:49:53 +0200 Subject: Add link-time optimization (flto) for gcc-like compilers --- backend/ninja/Ninja.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 99b276e..68b3d05 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -434,7 +434,7 @@ namespace backend case OPT_LEV_RELEASE: { return { - ninja::NinjaArg::createRaw("-O3 -g0 -DNDEBUG") + ninja::NinjaArg::createRaw("-O3 -g0 -DNDEBUG -flto") }; } } @@ -1378,6 +1378,11 @@ namespace backend buildExeArgs.push_back(ninja::NinjaArg::createRaw("-s")); } + if(config.getOptimizationLevel() == OPT_LEV_RELEASE) + { + buildExeArgs.push_back(ninja::NinjaArg::createRaw("-flto")); + } + // TODO: Add flag to disable -ldl and -lm (dlopen, dlclose, floor, max, ...) #if OS_TYPE == OS_TYPE_OPENBSD || OS_TYPE == OS_TYPE_HAIKU buildExeArgs.insert(buildExeArgs.end(), { @@ -1602,6 +1607,11 @@ namespace backend buildDynamicArgs.push_back(ninja::NinjaArg::createRaw("-lasan -lubsan -llsan")); } + if(config.getOptimizationLevel() == OPT_LEV_RELEASE) + { + buildDynamicArgs.push_back(ninja::NinjaArg::createRaw("-flto")); + } + // TODO: Add flag to disable -ldl and -lm (dlopen, dlclose, floor, max, ...) #if OS_TYPE == OS_TYPE_OPENBSD || OS_TYPE == OS_TYPE_HAIKU buildDynamicArgs.insert(buildDynamicArgs.end(), { -- cgit v1.2.3