Thread overview
Cross-compile with LDC
Feb 08, 2017
Oleg B
Feb 08, 2017
kinke
Feb 08, 2017
Oleg B
Feb 08, 2017
kinke
Feb 09, 2017
Joakim
February 08, 2017
Hello all! I want to build ldc cross compiller. I found this instruction  https://wiki.dlang.org/LDC_cross-compilation_for_ARM_GNU/Linux, but I have some doubts: will it works with ldc-1.1.0? Particularly interested in the patch https://gist.githubusercontent.com/claudemr/3367c13095b15d449b1591eb38d098d9/raw/3517a5db2228e57da9dd8880a82d6bfe6f0e38f1/ldc_1.0.0_gnu_arm. It's for ldc-1.0.0 and sources can be changed.
Maybe somewhere I found patch for ldc-1.1.0?
Maybe someone already build cross ldc for linux x86_64?))
February 08, 2017
On Wednesday, 8 February 2017 at 14:57:41 UTC, Oleg B wrote:
> Hello all! I want to build ldc cross compiller. I found this instruction  https://wiki.dlang.org/LDC_cross-compilation_for_ARM_GNU/Linux, but I have some doubts: will it works with ldc-1.1.0? Particularly interested in the patch https://gist.githubusercontent.com/claudemr/3367c13095b15d449b1591eb38d098d9/raw/3517a5db2228e57da9dd8880a82d6bfe6f0e38f1/ldc_1.0.0_gnu_arm. It's for ldc-1.0.0 and sources can be changed.
> Maybe somewhere I found patch for ldc-1.1.0?
> Maybe someone already build cross ldc for linux x86_64?))

Hi Oleg,

first of all, we have an LDC forum/NG (http://forum.dlang.org/group/ldc) which would be more appropriate for your question. The referenced LDC patch is derived from https://github.com/ldc-developers/ldc/pull/1317, which hasn't been merged yet (but will be in not-too-distant future).
As you haven't explicitly specified what your target platform is, I can only assume that it's 32-bit ARM. With a vanilla LDC, cross-compiling to ARM with its double-precision reals will only work correctly if your LDC host compiler uses double-precision reals too, which isn't the case for Linux x86(_64), but for Windows. My LDC PR would make it work with a non-Windows x86(_64) host too, but only if the target (not the host) uses at most double-precision reals.

February 08, 2017
On Wednesday, 8 February 2017 at 16:21:49 UTC, kinke wrote:
> On Wednesday, 8 February 2017 at 14:57:41 UTC, Oleg B wrote:
>> Hello all! I want to build ldc cross compiller. I found this instruction  https://wiki.dlang.org/LDC_cross-compilation_for_ARM_GNU/Linux, but I have some doubts: will it works with ldc-1.1.0? Particularly interested in the patch https://gist.githubusercontent.com/claudemr/3367c13095b15d449b1591eb38d098d9/raw/3517a5db2228e57da9dd8880a82d6bfe6f0e38f1/ldc_1.0.0_gnu_arm. It's for ldc-1.0.0 and sources can be changed.
>> Maybe somewhere I found patch for ldc-1.1.0?
>> Maybe someone already build cross ldc for linux x86_64?))
>
> Hi Oleg,
>
> first of all, we have an LDC forum/NG (http://forum.dlang.org/group/ldc) which would be more appropriate for your question. The referenced LDC patch is derived from https://github.com/ldc-developers/ldc/pull/1317, which hasn't been merged yet (but will be in not-too-distant future).
> As you haven't explicitly specified what your target platform is, I can only assume that it's 32-bit ARM. With a vanilla LDC, cross-compiling to ARM with its double-precision reals will only work correctly if your LDC host compiler uses double-precision reals too, which isn't the case for Linux x86(_64), but for Windows. My LDC PR would make it work with a non-Windows x86(_64) host too, but only if the target (not the host) uses at most double-precision reals.

Thank you, in future I create new question about ldc in special forum. Yes, my target arch is ARMv7 (rpi2 and beaglebone) and ARMv8 (rpi3). If I understand correctly with vanilla LDC I can't cross-compiling from host linux-x86_64, but with your patch I can. Right? Maximum precision for ARMv7(8) is 64bit doubles, for x86_64 is 80bit reals. If I use your patch must I use in my programs only double or I can stay real in existing code?
February 08, 2017
On Wednesday, 8 February 2017 at 17:21:03 UTC, Oleg B wrote:
> If I understand correctly with vanilla LDC I can't cross-compiling from host linux-x86_64, but with your patch I can. Right?

Right. Joakim Noah has worked on LDC for Android and as far as I know provides some prebuilt compilers, a native one and a cross-compiler (Linux x86_64 host) including that patch.
There's also a pre-built Windows -> ARM cross-compiler; see http://forum.dlang.org/thread/xzzzfvahuwvgslulifad@forum.dlang.org and more ARM-related threads in our subforum.

> If I use your patch must I use in my programs only double or I can stay real in existing code?

Don't worry, the reals can stay.
February 09, 2017
On Wednesday, 8 February 2017 at 17:57:49 UTC, kinke wrote:
> On Wednesday, 8 February 2017 at 17:21:03 UTC, Oleg B wrote:
>> If I understand correctly with vanilla LDC I can't cross-compiling from host linux-x86_64, but with your patch I can. Right?
>
> Right. Joakim Noah has worked on LDC for Android and as far as I know provides some prebuilt compilers, a native one and a cross-compiler (Linux x86_64 host) including that patch.
> There's also a pre-built Windows -> ARM cross-compiler; see http://forum.dlang.org/thread/xzzzfvahuwvgslulifad@forum.dlang.org and more ARM-related threads in our subforum.

That's not really a Windows build of ldc, he just used the new linux support in Windows 10.  There is a build of ldc 1.1.0 for native linux/ARM, if you want to compile D code on the ARM device itself:

https://github.com/ldc-developers/ldc/releases/tag/v1.1.0

If not, it's pretty straight forward to build a cross-compiler for ARM, take a look at my patches and instructions for Android:

https://github.com/joakim-noah/android/releases

>> If I use your patch must I use in my programs only double or I can stay real in existing code?
>
> Don't worry, the reals can stay.

The patch will make reals the same as double, ie they're all 64-bit, so it is irrelevant which one you use.  If you're writing cross-platform code and care about that difference on other platforms, you may need to check for it.  Take a look at std.math for examples of this, where it checks the length of the mantissa sometimes for reals.