From 0697f410b05085cdaf767d5b6fd3fea056ec5bd3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 8 Mar 2023 12:53:25 +0100 Subject: Add support for mold, add optimization flags for linking step --- 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 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 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 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)); -- cgit v1.2.3