Browse Source

Default to external assembler in cross-endian configuration.

  Add note about reason of switching to external assembler.

(cherry picked from commit 31c8e78581f442ef537693da2db81bacd4a30fee)
Pierre Muller 1 year ago
parent
commit
3e197cb8d7
2 changed files with 30 additions and 4 deletions
  1. 16 4
      compiler/options.pas
  2. 14 0
      compiler/systems.pas

+ 16 - 4
compiler/options.pas

@@ -4052,6 +4052,13 @@ begin
   { maybe override assembler }
   if (option.paratargetasm<>as_none) then
     begin
+      if (option.paratargetasm=as_default) then
+        begin
+          if (target_info.endian<>source_info.endian) then
+            option.paratargetasm:=target_info.assemextern
+          else
+            option.paratargetasm:=target_info.assem;
+        end;
       if not set_target_asm(option.paratargetasm) then
         begin
           if assigned(asminfos[option.paratargetasm]) then
@@ -4076,7 +4083,6 @@ begin
         begin
           option.paratargetdbg:=dbg_dwarf2;
         end;
-
     end;
   {TOptionheck a second time as we might have changed assembler just above }
   option.checkoptionscompatibility;
@@ -4087,10 +4093,16 @@ begin
       Message(option_w_unsupported_debug_format);
 
   { switch assembler if it's binary and we got -a on the cmdline }
-  if (cs_asm_leave in init_settings.globalswitches) and
-     (af_outputbinary in target_asm.flags) then
+  if (af_outputbinary in target_asm.flags) and
+     ((cs_asm_leave in init_settings.globalswitches) or
+      { if -s is passed, we shouldn't call the internal assembler }
+      (cs_asm_extern in init_settings.globalswitches)) or
+      ((option.paratargetasm=as_none) and (target_info.endian<>source_info.endian)) then
    begin
-     Message(option_switch_bin_to_src_assembler);
+     if ((option.paratargetasm=as_none) and (target_info.endian<>source_info.endian)) then
+       Message(option_switch_bin_to_src_assembler_cross_endian)
+     else
+       Message(option_switch_bin_to_src_assembler);
 {$ifdef llvm}
      set_target_asm(as_clang_llvm);
 {$else}

+ 14 - 0
compiler/systems.pas

@@ -411,6 +411,20 @@ interface
                              + [system_i386_beos,system_i386_haiku]
                              + [system_powerpc_morphos];
 
+       systems_support_uf2 = [system_arm_embedded,system_avr_embedded,system_mipsel_embedded,system_xtensa_embedded];
+
+       { all internal COFF writers }
+       asms_int_coff = [as_arm_pecoffwince,as_x86_64_pecoff,as_i386_pecoffwince,
+                        as_i386_pecoffwdosx,as_i386_pecoff,as_i386_coff];
+
+       { all internal ELF writers }
+       asms_int_elf = [as_arm_elf32,as_x86_64_elf64,as_m68k_elf32,
+                       as_sparc_elf32,as_i386_elf32];
+
+       { all internal writers }
+       asms_internals = asms_int_coff + asms_int_elf
+                        + [as_i8086_omf, as_z80_rel, as_wasm32_wasm, as_i386_macho];
+
        cpu2str : array[TSystemCpu] of string[10] =
             ('','i386','m68k','alpha','powerpc','sparc','vm','ia64','x86_64',
              'mips','arm', 'powerpc64', 'avr', 'mipsel','jvm', 'i8086',