Ehem, ARM

Kai Nacke kai at redstar.de
Fri Nov 15 04:18:19 PST 2013


On Friday, 15 November 2013 at 11:18:06 UTC, Joakim wrote:
> On Friday, 15 November 2013 at 09:45:42 UTC, Paulo Pinto wrote:
>> As far as I know dmd does not support cross compiling.
> I started skimming the dmd source to see how it handled porting 
> to new platforms and I found the following:
>
>  * Linux Version
>  * -------------
>  * There are two main issues: hosting the compiler on linux,
>  * and generating (targetting) linux executables.
>  * The "linux" and "__GNUC__" macros control hosting issues
>  * for operating system and compiler dependencies, respectively.
>  * To target linux executables, use ELFOBJ for things specific 
> to the
>  * ELF object file format, and TARGET_LINUX for things specific 
> to
>  * the linux memory model.
>  * If this is all done right, one could generate a linux object 
> file
>  * even when compiling on win32, and vice versa.
>  * The compiler source code currently uses these macros very 
> inconsistently
>  * with these goals, and should be fixed.
> https://github.com/D-Programming-Language/dmd/blob/master/src/backend/cdef.h#L71
>
> So it appears that the dmd backend has some support for 
> cross-compiling, although likely incomplete.

Hi Joakim!

Yes, there is a some support, but not too much. The existence of 
the TARGET_* macros means that you can't have one compiler with 2 
or more platform targets.
But there should be no real problem to create a dmd executable on 
Linux/ARM producing object files for Windows/x86. (Well - no 
problem except for the real data type. :-) ) But who needs that 
kind of cross-compiling?

To be useful for producing ARM binaries, you need an ARM backend. 
This is already available for LDC and GDC. IMHO it is easier to 
pick one of those compilers and think about and create a 
cross-compiling environment instead of starting by zero. (For 
LDC, this is issue #490: 
https://github.com/ldc-developers/ldc/issues/490)

Regards,
Kai


More information about the Digitalmars-d mailing list