From 54b38adb83eb63cf77e92de1918cb3ea099f971a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 19 May 2022 21:29:10 +0200 Subject: Disable automatic use of lld when using link-time optimization --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3c2ad46..de09301 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -666,7 +666,11 @@ static int buildProject(int argc, const _tinydir_char_t **argv, bool run) // 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()) + // Static object files compiled with gcc are not compatible with lld (llvm linker) + // and we dont know which compiler was used to compile to code so we disable automatic + // use of lld by default. The user can still force lld with --linker=lld, if they are + // sure that they used clang to compile the code. + if(!use_lto && is_lld_linker_installed()) linker = "lld"; else if(is_gold_linker_installed()) linker = "gold"; -- cgit v1.2.3