./fixes/gcc220/vcs_diff_compiler.patch 2025-07-31-21:05
> uname -a OpenBSD cfarm220.cfarm.net 7.7 GENERIC.MP#625 amd64
diff --git a/compiler/globtype.pas b/compiler/globtype.pas index cd8440aa4f..a32ae2a51e 100644 --- a/compiler/globtype.pas +++ b/compiler/globtype.pas @@ -224,7 +224,9 @@ tcompextendedrec=record cs_link_map,cs_link_pthread,cs_link_no_default_lib_order, cs_link_native, cs_link_pre_binutils_2_19, - cs_link_vlink + cs_link_vlink, + { Use ld.lld linker } + cs_link_lld ); tglobalswitches = set of tglobalswitch; diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas index c2b849e983..08456273c4 100644 --- a/compiler/llvm/agllvm.pas +++ b/compiler/llvm/agllvm.pas @@ -1697,7 +1697,6 @@ tdoubleval = record supported_targets : [system_x86_64_linux,system_x86_64_darwin]; flags : [af_smartlink_sections,af_llvm]; labelprefix : 'L'; - labelmaxlen : -1; comment : '; '; dollarsign: '$'; ); diff --git a/compiler/options.pas b/compiler/options.pas index 79900f42df..e85f19f173 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -2713,7 +2713,7 @@ procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean); 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 @@ -2728,7 +2728,17 @@ procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean); 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 661e503f84..8d08755be9 100644 --- a/compiler/systems/t_bsd.pas +++ b/compiler/systems/t_bsd.pas @@ -126,7 +126,11 @@ procedure TLinkerBSD.SetDefaultInfo; var LdProgram: string='ld'; begin - if target_info.system in (systems_openbsd+systems_freebsd+[system_x86_64_dragonfly]) then + { Force ld.lld usage for x86_64 openbsd system, + because GNU linker generates wrong executable's on x86_64 OpenBSD 7.5 } + if (cs_link_lld in current_settings.globalswitches) or (target_info.system = system_x86_64_openbsd) 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 3418e628e0..1724525947 100644 --- a/compiler/utils/ppuutils/ppudump.pp +++ b/compiler/utils/ppuutils/ppudump.pp @@ -2187,7 +2187,8 @@ (* tsettings = record 'Link no default lib order', {cs_link_no_default_lib_order} 'Link using native linker', {cs_link_native} 'Link for GNU linker version <=2.19', {cs_link_pre_binutils_2_19} - 'Link using vlink' {cs_link_vlink} + 'Link using vlink', {cs_link_vlink} + 'Link using ld.lld GNU compatible LLVM linker' {cs_link_lld} ); localswitchname : array[tlocalswitch] of string[50] = { Switches which can be changed locally } diff --git a/compiler/x86/agx86att.pas b/compiler/x86/agx86att.pas index 54817eec4d..e0ae86124f 100644 --- a/compiler/x86/agx86att.pas +++ b/compiler/x86/agx86att.pas @@ -458,6 +458,19 @@ Tx86InstrWriter=class(TCPUInstrWriter) dollarsign: '$'; ); + as_x86_64_clang_gas_info : tasminfo = + ( + id : as_clang_gas; + idtxt : 'AS-CLANG'; + asmbin : 'clang'; + asmcmd : '-x assembler -c -target $TRIPLET -o $OBJ $EXTRAOPT -x assembler $ASM'; + supported_targets : [system_x86_64_linux, system_x86_64_freebsd, system_x86_64_netbsd, system_x86_64_openbsd]; + flags : [af_needar,af_smartlink_sections,af_supports_dwarf,af_llvm]; + labelprefix : '.L'; + comment : '// '; + dollarsign: '$'; + ); + {$else x86_64} as_i386_as_info : tasminfo = ( @@ -532,6 +545,19 @@ Tx86InstrWriter=class(TCPUInstrWriter) dollarsign: '$'; ); + as_i386_clang_gas_info : tasminfo = + ( + id : as_clang_gas; + idtxt : 'AS-CLANG'; + asmbin : 'clang'; + asmcmd : '-x assembler -c -target $TRIPLET -o $OBJ $EXTRAOPT -x assembler $ASM'; + supported_targets : [system_i386_linux, system_i386_freebsd, system_i386_netbsd, system_i386_openbsd]; + flags : [af_needar,af_smartlink_sections,af_supports_dwarf,af_llvm]; + labelprefix : '.L'; + comment : '// '; + dollarsign: '$'; + ); + as_i386_gas_info : tasminfo = ( id : as_ggas; @@ -571,6 +597,7 @@ initialization RegisterAssembler(as_x86_64_gas_info,Tx86ATTAssembler); RegisterAssembler(as_x86_64_gas_darwin_info,Tx86AppleGNUAssembler); RegisterAssembler(as_x86_64_clang_darwin_info,Tx86AppleGNUAssembler); + RegisterAssembler(as_x86_64_clang_gas_info,Tx86ATTAssembler); RegisterAssembler(as_x86_64_solaris_info,Tx86ATTAssembler); {$else x86_64} RegisterAssembler(as_i386_as_info,Tx86ATTAssembler); @@ -578,6 +605,7 @@ initialization RegisterAssembler(as_i386_yasm_info,Tx86ATTAssembler); RegisterAssembler(as_i386_gas_darwin_info,Tx86AppleGNUAssembler); RegisterAssembler(as_i386_clang_darwin_info,Tx86AppleGNUAssembler); + RegisterAssembler(as_i386_clang_gas_info,Tx86ATTAssembler); RegisterAssembler(as_i386_as_aout_info,Tx86AoutGNUAssembler); RegisterAssembler(as_i386_solaris_info,Tx86ATTAssembler); {$endif x86_64}