aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-03-08 12:53:25 +0100
committerdec05eba <dec05eba@protonmail.com>2023-03-08 12:53:25 +0100
commit0697f410b05085cdaf767d5b6fd3fea056ec5bd3 (patch)
tree09c5a5c920b191edb0ceffe30ae0cc99de91b11d /backend/ninja
parentcc0eb4651e4b204fb7926ddd84bb830f432aabd3 (diff)
Add support for mold, add optimization flags for linking step
Diffstat (limited to 'backend/ninja')
-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 6c69d13..c66907c 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -810,7 +810,9 @@ namespace backend
// TODO: Allow configuring default linking flags. Maybe have `package.useThreads = false` to disable this flag
string allLinkerFlags;
- if(!config.linker.empty())
+ if(config.linker == "mold")
+ allLinkerFlags += " -B/usr/lib/mold/";
+ else if(!config.linker.empty())
allLinkerFlags += " -fuse-ld=" + config.linker;
if(isSamePlatformFamily(config.platform, PLATFORM_POSIX))
@@ -1011,6 +1013,10 @@ namespace backend
vector<ninja::NinjaArg> optimizationFlags = getCompilerOptimizationFlags(config);
compileCCommand.insert(compileCCommand.end(), optimizationFlags.begin(), optimizationFlags.end());
+ for(auto &optFlag : optimizationFlags) {
+ allLinkerFlags += " " + optFlag.arg;
+ }
+
ninja::NinjaArg sanitizerFlag = getCompilerSanitizerFlag(config);
if(sanitizerFlag.type != ninja::NinjaArg::Type::NONE)
compileCCommand.push_back(std::move(sanitizerFlag));
@@ -1065,6 +1071,10 @@ namespace backend
vector<ninja::NinjaArg> optimizationFlags = getCompilerOptimizationFlags(config);
compileCCommand.insert(compileCCommand.end(), optimizationFlags.begin(), optimizationFlags.end());
+ for(auto &optFlag : optimizationFlags) {
+ allLinkerFlags += " " + optFlag.arg;
+ }
+
ninja::NinjaArg sanitizerFlag = getCompilerSanitizerFlag(config);
if(sanitizerFlag.type != ninja::NinjaArg::Type::NONE)
compileCCommand.push_back(std::move(sanitizerFlag));