aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-04-25 21:49:53 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:58 +0200
commit75b961eb9572606e3cea2e5f649d47b5dd2207af (patch)
tree64892b260754acb796bc54776b38463eb538f41c
parent4c2659aacc9819e29772e2ad2cc03b9fb0815df2 (diff)
Add link-time optimization (flto) for gcc-like compilers
-rw-r--r--backend/ninja/Ninja.cpp12
1 files changed, 11 insertions, 1 deletions
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(), {