From fa06d5a76b02018980ccc12fcd52ea96bd894c81 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 9 May 2022 13:19:47 +0200 Subject: Use lld or gold if installed --- src/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 2592135..3c2ad46 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -138,7 +138,7 @@ static void usageBuild(bool run) printf(" --platform The platform to build for - Optional (default: the running platform)\n"); printf(" --lto Use link-time optimization. May increase compile times - Optional (default: not used)\n"); printf(" --debug-symbols Include debug symbols in release mode - Optional (default: not used)\n"); - printf(" --linker=linker The linker to use. \"gold\" is the default linker when using gcc\n"); + printf(" --linker=linker The linker to use. \"lld\" or \"gold\" is the default linker when using gcc\n"); if(run) { printf(" --args A list of arguments to run the program with\n"); } else { @@ -182,7 +182,7 @@ static void usageTest() printf(" --sanitize=option Add runtime address/undefined behavior sanitization. Program can be up to 3 times slower and use 10 times as much RAM. Ignored if compiler doesn't support sanitization - Optional (default: address)\n"); printf(" --file Specify file to test, path to test file should be defined after this. Can be defined multiple times to test multiple files - Optional (default: not used), Only applicable for Zig\n"); printf(" --all-files Test all files - Optional (default: not used), Only applicable for Zig\n"); - printf(" --linker=linker The linker to use. \"gold\" is the default linker when using gcc\n"); + printf(" --linker=linker The linker to use. \"lld\" or \"gold\" is the default linker when using gcc\n"); printf(" --skip-compile Skip compilation. This can be used to generate a compile_commands.json file without compiling. Note that the compile_commands.json can miss files that are generated when this option is used. This option also skips running the tests\n"); printf(" --args A list of arguments to run the program with\n"); printf("Examples:\n"); @@ -664,6 +664,14 @@ static int buildProject(int argc, const _tinydir_char_t **argv, bool run) Compiler compiler = Compiler::MSVC; #endif + // TODO: Make mold the default linker if it's installed and the installed gcc version supports it with -fuse-ld= option + if(linker.empty()) { + if(is_lld_linker_installed()) + linker = "lld"; + else if(is_gold_linker_installed()) + linker = "gold"; + } + SibsConfig sibsConfig(compiler, projectPath, optimizationLevel, false); sibsConfig.showWarnings = true; sibsConfig.platform = platform; -- cgit v1.2.3