Skip to content

Commit bffad2e

Browse files
committed
Overcome longdouble_soft problem on WoA64 hosts
That 'soft' implementation (of an 80-bit x87 value used for compile-time reals on Windows MSVC x86[_64] hosts, if their native `real` is a 64-bit double with an LDC host compiler) is still based on x87 inline asm, so cannot be used in a WoA64 compiler binary. So use a 64-bit native `real` for compile-time reals on WoA64 hosts.
1 parent 2a12b66 commit bffad2e

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

dmd/main.d

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,11 @@ else
442442
reconcileLinkRunLib(params, files.length, target.obj_ext);
443443
version(CRuntime_Microsoft)
444444
{
445-
import dmd.root.longdouble;
446-
initFPU();
445+
version(AArch64) { /* no longdouble_soft support on arm64 host */ } else
446+
{
447+
import dmd.root.longdouble;
448+
initFPU();
449+
}
447450
}
448451
import dmd.root.ctfloat : CTFloat;
449452
CTFloat.initialize();

dmd/root/ctfloat.d

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ private
2727
{
2828
version(CRuntime_DigitalMars) __gshared extern (C) extern const(char)* __locale_decpoint;
2929

30-
version(CRuntime_Microsoft) extern (C++)
30+
version(CRuntime_Microsoft)
3131
{
32-
public import dmd.root.longdouble : longdouble_soft, ld_sprint;
32+
version(AArch64) { /* 64-bit real_t */ } else
33+
{
34+
version = MSVC_X87;
35+
import dmd.root.longdouble : longdouble_soft, ld_sprint;
3336
version (IN_LLVM) {} else
3437
{
35-
import dmd.root.strtold;
38+
import dmd.root.strtold;
3639
}
40+
}
3741
}
3842
}
3943

@@ -193,7 +197,7 @@ extern (C++) struct CTFloat
193197
// the implementation of longdouble for MSVC is a struct, so mangling
194198
// doesn't match with the C++ header.
195199
// add a wrapper just for isSNaN as this is the only function called from C++
196-
version(CRuntime_Microsoft) static if (is(real_t == real))
200+
version(MSVC_X87) static if (is(real_t == real))
197201
pure @trusted
198202
static bool isSNaN(longdouble_soft ld)
199203
{
@@ -239,7 +243,7 @@ extern (C++) struct CTFloat
239243
@system
240244
static int sprint(char* str, size_t size, char fmt, real_t x)
241245
{
242-
version(CRuntime_Microsoft)
246+
version(MSVC_X87)
243247
{
244248
auto len = cast(int) ld_sprint(str, size, fmt, longdouble_soft(x));
245249
}

dmd/root/longdouble.d

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ module dmd.root.longdouble;
1313

1414
version (CRuntime_Microsoft)
1515
{
16-
static if (real.sizeof > 8)
16+
version (AArch64)
17+
alias longdouble = real; // 64-bit
18+
else static if (real.sizeof > 8)
1719
alias longdouble = real;
1820
else
1921
alias longdouble = longdouble_soft;
@@ -24,6 +26,7 @@ else
2426
// longdouble_soft needed when building the backend with
2527
// Visual C or the frontend with LDC on Windows
2628
version (CRuntime_Microsoft):
29+
version (AArch64) { /* cannot use x87 inline asm on arm64 host */ } else:
2730
extern (C++):
2831
nothrow:
2932
@nogc:

0 commit comments

Comments
 (0)