Using the real target "real" type (cross compiling)

Kai Nacke kai at redstar.de
Mon Feb 10 11:47:30 PST 2014


Hi Dan!

On Monday, 10 February 2014 at 16:55:47 UTC, Dan Olson wrote:
> I switched to using ldc merge-2.064 branch for all my iOS 
> hacking. The
> newer std.math has some nice static asserts that failed because 
> dmd is
> using the compile host "long double" type for determing the 
> properties
> of type real.  Thank you for static assertions!
>
> Mac x86_64 long double != Arm long double
>
> I hacked dmd to make longdouble = double so I could cross 
> compile this
> newer phobos to iOS.  But are there other things like real 
> types that
> dmd code is learning from host, but should be told what the 
> target is
> using?
>
> Anyway, this seems like more of a dmd thing.  What is the best 
> approach
> to solve?  I am ok for now with hacking on my own branch but 
> wishing for
> a better solution.
>
> Thanks,

I know this annoying issue. It also prevents cross compiling from 
x86_64 to ppc64 because 80bit floats are not 128bit floats. It's 
issue #259 (https://github.com/ldc-developers/ldc/issues/259).

I don't have a workaround. But I am working on a solution. :-)

As discussed in the issue, I replace the real_t data type with a 
wrapper around llvm::APFloat. Then it is possible to configure 
the float properties based on the target architecture.

I have a first prototype already implemented. With the 
refactorings of dmd 2.065 (see my other post from today) it is 
much easier to integrate: it is now more obvious how to disable 
some built-in functions. (E.g. I have an implementation of sqrt() 
which still has a 1-bit difference compared to sqrtl() on x86_64. 
IMHO it is better to disable CTFE for these functions then to 
introduce some subtle differences between CTFE and runtime.)

I'll post it here when it is integrated.

Regards,
Kai



More information about the digitalmars-d-ldc mailing list