浏览代码

* merged the fixes_3_0-relevant parts of r31808, r31830, r31879: add support
for clang as an assembler on Darwin and use it by default for i386 and x86_64
(ARM will be in fixes_3_0_ios)

git-svn-id: branches/fixes_3_0@31907 -

Jonas Maebe 9 年之前
父节点
当前提交
decff7ad16

+ 16 - 1
compiler/arm/agarmgas.pas

@@ -368,7 +368,7 @@ unit agarmgas;
        as_arm_gas_darwin_info : tasminfo =
           (
             id     : as_darwin;
-            idtxt  : 'AS-Darwin';
+            idtxt  : 'AS-DARWIN';
             asmbin : 'as';
             asmcmd : '-o $OBJ $EXTRAOPT $ASM -arch $ARCH';
             supported_targets : [system_arm_darwin];
@@ -379,7 +379,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
   RegisterAssembler(as_arm_gas_info,TARMGNUAssembler);
   RegisterAssembler(as_arm_gas_darwin_info,TArmAppleGNUAssembler);
+  RegisterAssembler(as_arm_clang_darwin_info,TArmAppleGNUAssembler);
 end.

+ 12 - 2
compiler/assemble.pas

@@ -275,7 +275,7 @@ Implementation
       begin
         DoPipe:=(cs_asm_pipe in current_settings.globalswitches) and
                 (([cs_asm_extern,cs_asm_leave,cs_link_on_target] * current_settings.globalswitches) = []) and
-                ((target_asm.id in [as_gas,as_ggas,as_darwin,as_powerpc_xcoff]));
+                ((target_asm.id in [as_gas,as_ggas,as_darwin,as_powerpc_xcoff,as_clang]));
       end;
 
 
@@ -582,6 +582,13 @@ Implementation
     function TExternalAssembler.MakeCmdLine: TCmdStr;
       begin
         result:=target_asm.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}
         if (target_info.system=system_arm_darwin) then
           Replace(result,'$ARCH',lower(cputypestr[current_settings.cputype]));
@@ -595,7 +602,10 @@ Implementation
          begin
 {$ifdef hasunix}
           if DoPipe then
-            Replace(result,'$ASM','')
+            if target_asm.id<>as_clang then
+              Replace(result,'$ASM','')
+            else
+              Replace(result,'$ASM','-')
           else
 {$endif}
              Replace(result,'$ASM',maybequoted(AsmFileName));

+ 1 - 1
compiler/ppcgen/agppcgas.pas

@@ -556,7 +556,7 @@ unit agppcgas;
        (
          id     : as_darwin;
 
-         idtxt  : 'AS-Darwin';
+         idtxt  : 'AS-DARWIN';
          asmbin : 'as';
          asmcmd : '-o $OBJ $EXTRAOPT $ASM -arch $ARCH';
          supported_targets : [system_powerpc_darwin,system_powerpc64_darwin];

+ 1 - 0
compiler/systems.inc

@@ -211,6 +211,7 @@
              ,as_i8086_nasm
              ,as_i8086_nasmobj
              ,as_gas_powerpc_xcoff
+             ,as_clang
        );
 
        tlink = (ld_none,

+ 1 - 1
compiler/systems.pas

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

+ 6 - 6
compiler/systems/i_bsd.pas

@@ -729,8 +729,8 @@ unit i_bsd;
             Cprefix      : '_';
             newline      : #10;
             dirsep       : '/';
-            assem        : as_darwin;
-            assemextern  : as_darwin;
+            assem        : as_clang;
+            assemextern  : as_clang;
             link         : ld_none;
             linkextern   : ld_bsd;
             ar           : ar_gnu_ar;
@@ -793,8 +793,8 @@ unit i_bsd;
             Cprefix      : '_';
             newline      : #10;
             dirsep       : '/';
-            assem        : as_darwin;
-            assemextern  : as_darwin;
+            assem        : as_clang;
+            assemextern  : as_clang;
             link         : ld_none;
             linkextern   : ld_bsd;
             ar           : ar_gnu_ar;
@@ -921,8 +921,8 @@ unit i_bsd;
             Cprefix      : '_';
             newline      : #10;
             dirsep       : '/';
-            assem        : as_darwin;
-            assemextern  : as_darwin;
+            assem        : as_clang;
+            assemextern  : as_clang;
             link         : ld_none;
             linkextern   : ld_bsd;
             ar           : ar_gnu_ar;

+ 30 - 2
compiler/x86/agx86att.pas

@@ -508,7 +508,7 @@ interface
        as_x86_64_gas_darwin_info : tasminfo =
           (
             id     : as_darwin;
-            idtxt  : 'AS-Darwin';
+            idtxt  : 'AS-DARWIN';
             asmbin : 'as';
             asmcmd : '-o $OBJ $EXTRAOPT $ASM -arch x86_64';
             supported_targets : [system_x86_64_darwin];
@@ -518,6 +518,19 @@ interface
             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];
+            flags : [af_needar,af_smartlink_sections,af_supports_dwarf];
+            labelprefix : 'L';
+            comment : '# ';
+            dollarsign: '$';
+          );
+
 {$else x86_64}
        as_i386_as_info : tasminfo =
           (
@@ -569,7 +582,7 @@ interface
        as_i386_gas_darwin_info : tasminfo =
           (
             id     : as_darwin;
-            idtxt  : 'AS-Darwin';
+            idtxt  : 'AS-DARWIN';
             asmbin : 'as';
             asmcmd : '-o $OBJ $EXTRAOPT $ASM -arch i386';
             supported_targets : [system_i386_darwin,system_i386_iphonesim];
@@ -579,6 +592,19 @@ interface
             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 =
           (
             id     : as_ggas;
@@ -602,11 +628,13 @@ initialization
   RegisterAssembler(as_x86_64_yasm_info,Tx86ATTAssembler);
   RegisterAssembler(as_x86_64_gas_info,Tx86ATTAssembler);
   RegisterAssembler(as_x86_64_gas_darwin_info,Tx86AppleGNUAssembler);
+  RegisterAssembler(as_x86_64_clang_darwin_info,Tx86AppleGNUAssembler);
 {$else x86_64}
   RegisterAssembler(as_i386_as_info,Tx86ATTAssembler);
   RegisterAssembler(as_i386_gas_info,Tx86ATTAssembler);
   RegisterAssembler(as_i386_yasm_info,Tx86ATTAssembler);
   RegisterAssembler(as_i386_gas_darwin_info,Tx86AppleGNUAssembler);
+  RegisterAssembler(as_i386_clang_darwin_info,Tx86AppleGNUAssembler);
   RegisterAssembler(as_i386_as_aout_info,Tx86AoutGNUAssembler);
 {$endif x86_64}
 end.