From 79d1fcd40d6ee362a0340751051edade7b124027 Mon Sep 17 00:00:00 2001 From: Pierre Muller Date: Wed, 5 Jul 2023 17:27:03 +0200 Subject: [PATCH] Introduce -XLL option for link using ld.lld linker --- compiler/globtype.pas | 4 +++- compiler/options.pas | 15 +++++++++++++-- compiler/systems/t_bsd.pas | 4 +++- compiler/utils/ppuutils/ppudump.pp | 3 ++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/compiler/globtype.pas b/compiler/globtype.pas index f471a952ec..c17050126f 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -239,7 +239,9 @@ interface this not supported on all OSes } cs_large, { if applicable, the compiler generates an executable in uf2 format } - cs_generate_uf2 + cs_generate_uf2, + { Use ld.lld linker } + cs_link_lld ); tglobalswitches = set of tglobalswitch; diff --git a/compiler/options.pas b/compiler/options.pas index c7b133697c..fd1365d08e 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -4261,7 +4261,7 @@ begin end; 'L' : begin // -XLO is link order -XLA is link alias. -XLD avoids load defaults. // these are not aggregable. - if (j=length(more)) or not (more[j+1] in ['O','A','D']) then + if (j=length(more)) or not (more[j+1] in ['O','A','D','L']) then IllegalPara(opt) else begin @@ -4276,7 +4276,18 @@ begin if not LinkLibraryOrder.AddWeight(s) Then IllegalPara(opt); end; - 'D' : include(init_settings.globalswitches,cs_link_no_default_lib_order) + 'D' : include(init_settings.globalswitches,cs_link_no_default_lib_order); + 'L' : + begin + if UnsetBool(More, j, opt, false) then + exclude(init_settings.globalswitches,cs_link_lld) + else + begin + include(init_settings.globalswitches,cs_link_lld); + include(init_settings.globalswitches,cs_link_extern); + end; + LinkerSetExplicitly:=true; + end else IllegalPara(opt); end; {case} diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas index 18eefbd29a..eaac6498f8 100644 --- a/compiler/systems/t_bsd.pas +++ b/compiler/systems/t_bsd.pas @@ -127,7 +127,9 @@ procedure TLinkerBSD.SetDefaultInfo; var LdProgram: string='ld'; begin - if target_info.system in (systems_openbsd+systems_freebsd+[system_x86_64_dragonfly]) then + if cs_link_lld in current_settings.globalswitches then + LdProgram:='ld.lld' + else if target_info.system in (systems_openbsd+systems_freebsd+[system_x86_64_dragonfly]) then LdProgram:='ld.bfd'; LibrarySuffix:=' '; LdSupportsNoResponseFile := (target_info.system in ([system_m68k_netbsd]+systems_darwin)); diff --git a/compiler/utils/ppuutils/ppudump.pp b/compiler/utils/ppuutils/ppudump.pp index 0b3cc303af..4e9e3b12cf 100644 --- a/compiler/utils/ppuutils/ppudump.pp +++ b/compiler/utils/ppuutils/ppudump.pp @@ -2342,7 +2342,8 @@ const 'Link-Time Optimization disabled for system unit', {cs_lto_nosystem} 'Assemble on target OS', {cs_asemble_on_target} 'Use a memory model to support >2GB static data on 64 Bit target', {cs_large} - 'Generate UF2 binary' {cs_generate_uf2} + 'Generate UF2 binary', {cs_generate_uf2} + 'Link using ld.lld GNU compatible LLVM linker' {cs_link_lld} ); localswitchname : array[tlocalswitch] of string[50] = { Switches which can be changed locally }