+ added support for using Clang as an assembler, and make it the default

for all non-ppc(32/64) Darwin platforms
   o pass the macosx-version-min/iphoneos-version-min to clang as an assembler,
     so that it properly sets this information starting with Xcode 7 (solves
     errors when targeting the iOS simulator, and warnings about object files
     being compiled for a different OS X version when targeting (Mac) OS X)
   o the old assembler is still selectable via -Aas-darwin (required with
     Xcode 3.1.x and older)
   o since the first Xcode version that shipped with Clang is Xcode 3.2, which
     is available for Mac OS X 10.6, most users should not encounter any issues
     with the new default (in fact, it fixes some tests for x86 because Clang
     supports some instructions that "as" doesn't). Clang does not support
     Stabs however, so -gs does require the use of -Aas-darwin

git-svn-id: trunk@31830 -
This commit is contained in:
Jonas Maebe 2015-09-25 18:31:54 +00:00
parent 624376b403
commit 7c594b0288
7 changed files with 75 additions and 34 deletions

View File

@ -45,7 +45,6 @@ unit agcpugas;
TAArch64AppleAssembler=class(TAppleGNUassembler) TAArch64AppleAssembler=class(TAppleGNUassembler)
constructor create(info: pasminfo; smart: boolean); override; constructor create(info: pasminfo; smart: boolean); override;
function MakeCmdLine: TCmdStr; override;
end; end;
@ -91,18 +90,6 @@ unit agcpugas;
InstrWriter := TAArch64InstrWriter.create(self); InstrWriter := TAArch64InstrWriter.create(self);
end; end;
function TAArch64AppleAssembler.MakeCmdLine: TCmdStr;
begin
{ 'as' calls through to clang for aarch64, and that one only supports
reading from standard input in case "-" is specified as input file
(in which case you also have to specify the language via -x) }
result:=inherited;
{$ifdef hasunix}
if DoPipe then
result:=result+' -x assembler -'
{$endif}
end;
{****************************************************************************} {****************************************************************************}
{ Helper routines for Instruction Writer } { Helper routines for Instruction Writer }
@ -295,14 +282,14 @@ unit agcpugas;
dollarsign: '$'; dollarsign: '$';
); );
as_aarch64_gas_darwin_info : tasminfo = as_aarch64_clang_darwin_info : tasminfo =
( (
id : as_darwin; id : as_clang;
idtxt : 'AS-DARWIN'; idtxt : 'CLANG';
asmbin : 'as'; asmbin : 'clang';
asmcmd : '-o $OBJ $EXTRAOPT $ASM -arch arm64'; asmcmd : '-c -o $OBJ $EXTRAOPT -arch arm64 $DARWINVERSION -x assembler $ASM';
supported_targets : [system_aarch64_darwin]; supported_targets : [system_aarch64_darwin];
flags : [af_needar,af_smartlink_sections,af_supports_dwarf,af_stabs_use_function_absolute_addresses]; flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
labelprefix : 'L'; labelprefix : 'L';
comment : '# '; comment : '# ';
dollarsign: '$'; dollarsign: '$';
@ -311,5 +298,5 @@ unit agcpugas;
begin begin
RegisterAssembler(as_aarch64_gas_info,TAArch64Assembler); RegisterAssembler(as_aarch64_gas_info,TAArch64Assembler);
RegisterAssembler(as_aarch64_gas_darwin_info,TAArch64AppleAssembler); RegisterAssembler(as_aarch64_clang_darwin_info,TAArch64AppleAssembler);
end. end.

View File

@ -425,7 +425,22 @@ unit agarmgas;
); );
as_arm_clang_darwin_info : tasminfo =
(
id : as_clang;
idtxt : 'CLANG';
asmbin : 'clang';
asmcmd : '-c -o $OBJ $EXTRAOPT -arch $ARCH $DARWINVERSION -x assembler $ASM';
supported_targets : [system_arm_darwin];
flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
labelprefix : 'L';
comment : '# ';
dollarsign: '$';
);
begin begin
RegisterAssembler(as_arm_gas_info,TARMGNUAssembler); RegisterAssembler(as_arm_gas_info,TARMGNUAssembler);
RegisterAssembler(as_arm_gas_darwin_info,TArmAppleGNUAssembler); RegisterAssembler(as_arm_gas_darwin_info,TArmAppleGNUAssembler);
RegisterAssembler(as_arm_clang_darwin_info,TArmAppleGNUAssembler);
end. end.

View File

@ -898,6 +898,13 @@ Implementation
function TExternalAssembler.MakeCmdLine: TCmdStr; function TExternalAssembler.MakeCmdLine: TCmdStr;
begin begin
result:=asminfo^.asmcmd; result:=asminfo^.asmcmd;
{ for Xcode 7.x and later }
if MacOSXVersionMin<>'' then
Replace(result,'$DARWINVERSION','-mmacosx-version-min='+MacOSXVersionMin)
else if iPhoneOSVersionMin<>'' then
Replace(result,'$DARWINVERSION','-miphoneos-version-min='+iPhoneOSVersionMin)
else
Replace(result,'$DARWINVERSION','');
{$ifdef arm} {$ifdef arm}
if (target_info.system=system_arm_darwin) then if (target_info.system=system_arm_darwin) then
Replace(result,'$ARCH',lower(cputypestr[current_settings.cputype])); Replace(result,'$ARCH',lower(cputypestr[current_settings.cputype]));
@ -911,7 +918,10 @@ Implementation
begin begin
{$ifdef hasunix} {$ifdef hasunix}
if DoPipe then if DoPipe then
Replace(result,'$ASM','') if asminfo^.id<>as_clang then
Replace(result,'$ASM','')
else
Replace(result,'$ASM','-')
else else
{$endif} {$endif}
Replace(result,'$ASM',maybequoted(AsmFileName)); Replace(result,'$ASM',maybequoted(AsmFileName));

View File

@ -220,6 +220,7 @@
,as_arm_elf32 ,as_arm_elf32
,as_i8086_omf ,as_i8086_omf
,as_llvm ,as_llvm
,as_clang
); );
tlink = (ld_none, tlink = (ld_none,

View File

@ -70,7 +70,7 @@ interface
id : tasm; id : tasm;
idtxt : string[12]; idtxt : string[12];
asmbin : string[8]; asmbin : string[8];
asmcmd : string[50]; asmcmd : string[70];
supported_targets : set of tsystem; supported_targets : set of tsystem;
flags : set of tasmflags; flags : set of tasmflags;
labelprefix : string[3]; labelprefix : string[3];

View File

@ -741,8 +741,8 @@ unit i_bsd;
Cprefix : '_'; Cprefix : '_';
newline : #10; newline : #10;
dirsep : '/'; dirsep : '/';
assem : as_darwin; assem : as_clang;
assemextern : as_darwin; assemextern : as_clang;
link : ld_none; link : ld_none;
linkextern : ld_bsd; linkextern : ld_bsd;
ar : ar_gnu_ar; ar : ar_gnu_ar;
@ -806,8 +806,8 @@ unit i_bsd;
Cprefix : '_'; Cprefix : '_';
newline : #10; newline : #10;
dirsep : '/'; dirsep : '/';
assem : as_darwin; assem : as_clang;
assemextern : as_darwin; assemextern : as_clang;
link : ld_none; link : ld_none;
linkextern : ld_bsd; linkextern : ld_bsd;
ar : ar_gnu_ar; ar : ar_gnu_ar;
@ -936,8 +936,8 @@ unit i_bsd;
Cprefix : '_'; Cprefix : '_';
newline : #10; newline : #10;
dirsep : '/'; dirsep : '/';
assem : as_darwin; assem : as_clang;
assemextern : as_darwin; assemextern : as_clang;
link : ld_none; link : ld_none;
linkextern : ld_bsd; linkextern : ld_bsd;
ar : ar_gnu_ar; ar : ar_gnu_ar;
@ -1000,8 +1000,8 @@ unit i_bsd;
Cprefix : '_'; Cprefix : '_';
newline : #10; newline : #10;
dirsep : '/'; dirsep : '/';
assem : as_darwin; assem : as_clang;
assemextern : as_darwin; assemextern : as_clang;
link : ld_none; link : ld_none;
linkextern : ld_bsd; linkextern : ld_bsd;
ar : ar_gnu_ar; ar : ar_gnu_ar;
@ -1064,8 +1064,8 @@ unit i_bsd;
Cprefix : '_'; Cprefix : '_';
newline : #10; newline : #10;
dirsep : '/'; dirsep : '/';
assem : as_darwin; assem : as_clang;
assemextern : as_darwin; assemextern : as_clang;
link : ld_none; link : ld_none;
linkextern : ld_bsd; linkextern : ld_bsd;
ar : ar_gnu_ar; ar : ar_gnu_ar;
@ -1129,8 +1129,8 @@ unit i_bsd;
Cprefix : '_'; Cprefix : '_';
newline : #10; newline : #10;
dirsep : '/'; dirsep : '/';
assem : as_darwin; assem : as_clang;
assemextern : as_darwin; assemextern : as_clang;
link : ld_none; link : ld_none;
linkextern : ld_bsd; linkextern : ld_bsd;
ar : ar_gnu_ar; ar : ar_gnu_ar;

View File

@ -484,6 +484,19 @@ interface
dollarsign: '$'; dollarsign: '$';
); );
as_x86_64_clang_darwin_info : tasminfo =
(
id : as_clang;
idtxt : 'CLANG';
asmbin : 'clang';
asmcmd : '-c -o $OBJ $EXTRAOPT -arch x86_64 $DARWINVERSION -x assembler $ASM';
supported_targets : [system_x86_64_darwin,system_x86_64_iphonesim];
flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
labelprefix : 'L';
comment : '# ';
dollarsign: '$';
);
{$else x86_64} {$else x86_64}
as_i386_as_info : tasminfo = as_i386_as_info : tasminfo =
( (
@ -545,6 +558,19 @@ interface
dollarsign: '$'; dollarsign: '$';
); );
as_i386_clang_darwin_info : tasminfo =
(
id : as_clang;
idtxt : 'CLANG';
asmbin : 'clang';
asmcmd : '-c -o $OBJ $EXTRAOPT -arch i386 $DARWINVERSION -x assembler $ASM';
supported_targets : [system_i386_darwin,system_i386_iphonesim];
flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
labelprefix : 'L';
comment : '# ';
dollarsign: '$';
);
as_i386_gas_info : tasminfo = as_i386_gas_info : tasminfo =
( (
id : as_ggas; id : as_ggas;
@ -568,11 +594,13 @@ initialization
RegisterAssembler(as_x86_64_yasm_info,Tx86ATTAssembler); RegisterAssembler(as_x86_64_yasm_info,Tx86ATTAssembler);
RegisterAssembler(as_x86_64_gas_info,Tx86ATTAssembler); RegisterAssembler(as_x86_64_gas_info,Tx86ATTAssembler);
RegisterAssembler(as_x86_64_gas_darwin_info,Tx86AppleGNUAssembler); RegisterAssembler(as_x86_64_gas_darwin_info,Tx86AppleGNUAssembler);
RegisterAssembler(as_x86_64_clang_darwin_info,Tx86AppleGNUAssembler);
{$else x86_64} {$else x86_64}
RegisterAssembler(as_i386_as_info,Tx86ATTAssembler); RegisterAssembler(as_i386_as_info,Tx86ATTAssembler);
RegisterAssembler(as_i386_gas_info,Tx86ATTAssembler); RegisterAssembler(as_i386_gas_info,Tx86ATTAssembler);
RegisterAssembler(as_i386_yasm_info,Tx86ATTAssembler); RegisterAssembler(as_i386_yasm_info,Tx86ATTAssembler);
RegisterAssembler(as_i386_gas_darwin_info,Tx86AppleGNUAssembler); RegisterAssembler(as_i386_gas_darwin_info,Tx86AppleGNUAssembler);
RegisterAssembler(as_i386_clang_darwin_info,Tx86AppleGNUAssembler);
RegisterAssembler(as_i386_as_aout_info,Tx86AoutGNUAssembler); RegisterAssembler(as_i386_as_aout_info,Tx86AoutGNUAssembler);
{$endif x86_64} {$endif x86_64}
end. end.