aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-05-19 21:29:10 +0200
committerdec05eba <dec05eba@protonmail.com>2022-05-19 21:29:10 +0200
commit54b38adb83eb63cf77e92de1918cb3ea099f971a (patch)
tree6b12f5ffffd15dc89163c456b513edfb2c9b0962
parentfa06d5a76b02018980ccc12fcd52ea96bd894c81 (diff)
Disable automatic use of lld when using link-time optimization
-rw-r--r--src/main.cpp6
1 files changed, 5 insertions, 1 deletions
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";