Selaa lähdekoodia

Introduce -XLL option for link using ld.lld linker

Pierre Muller 2 vuotta sitten
vanhempi
commit
79d1fcd40d

+ 3 - 1
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;
 

+ 13 - 2
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}

+ 3 - 1
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));

+ 2 - 1
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 }