On Friday, 23 June 2017 at 19:56:17 UTC, Joakim wrote:
On Friday, 23 June 2017 at 19:03:01 UTC, FoxyBrown wrote:
[...]

The ldc wiki page has a rudimentary version of what you're looking for, listing all platforms worked on and some idea of how well they're supported:

https://wiki.dlang.org/LDC


Thanks, it's a start.

Dmd will likely never target the vast majority of the platforms you list, so it will depend on the gdc and ldc teams doing it.

I'm not too worried about dmd, I am mainly interested in simply a way. D is a nice language, so being able to use it, regardless of which compiler, is the goal.

Also, I'm looking at submitting a pull with my last ldc CMake patch to cross-compile the stdlib for Android/ARM and generalizing it for other platforms too:

https://gist.github.com/joakim-noah/d74af3cf1355492557a9c56ef1bf2636

Once that's in, building a cross-compiled stdlib for several platforms should be as simple as setting some flags with the location of a C cross-compiler and any C/linker flags you need, then running the same cmake/make combo that you use to build a native stdlib today.

No modifications are needed to ldc itself for well-supported platforms, as ldc is always a cross-compiler by default. For example, kinke used the new llvm linker, lld, to cross-compile Windows/x64 binaries from linux/x64 by using the stock ldc compiler. The instructions for how he did it are linked from the changelog for the latest ldc 1.3 beta2:

https://github.com/ldc-developers/ldc/pull/2142#issuecomment-304472412

Finally, the latest ldc 1.3 betas for the first time include the llvm code-generation target backends for various other CPUs, like ARM or PowerPC, whereas before ldc only bothered to compile in the x86/x64 backends, as those were the only stdlibs it distributed:

[joakim@localhost ~]$ ./ldc2-1.3.0-beta2-linux-x86_64/bin/ldc2 --version
LDC - the LLVM D compiler (1.3.0-beta2):
  based on DMD v2.073.2 and LLVM 4.0.0
  built with LDC - the LLVM D compiler (1.3.0-beta2)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: broadwell
           http://dlang.org - http://wiki.dlang.org/LDC

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_be - AArch64 (big endian)
    arm        - ARM
    arm64      - ARM64 (little endian)
    armeb      - ARM (big endian)
    ppc32      - PowerPC 32
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64

Not very useful right now unless you're doing bare-metal programming on those newly added architectures, because the cross-compiled stdlibs are not included and there's no easy way to generate them, but we could also put out separate tarfiles with the cross-compiled stdlibs (separated only to save space in the compiler download for those who don't want them), just as kinke used the ldc stdlib compiled for Windows/x64 on linux/x64 when cross-compiling.

Just last night, I was thinking about some easy way to let ldc users cross-compile the stdlib themselves from the regular ldc download, and I thought of doing it with dub, the D package manager, since we now distribute dub alongside ldc. However, I don't know how feasible this is with dub, needs to be looked into.

Nice to know it's being worked on. I am not really familiar with llvm but it seems like it can be quite useful. I'm I correct that basically llvm is an intermediate representation(sorta like C#/VBS/F#/etc's IR)?

This means that one simply needs a front end that converts the source code to llvm's IR and then a back end that converts the IR to targets binary?


For example, a quick search for llvm and 8051 gives this:

https://github.com/AndreaCorallo/llvm-i8051

Since, I assume(since there is no documentation describing what it does) is a backend compiler for llvm's IR to 8051, we can go from LDC to LLVM to 8051? In theory, of course.

This is all bare metal, of course.

Is GCC effectively the same(although the IR is skipped?)?


Thanks.



Reply via email to