Skip to content

Commit 45d2676

Browse files
committed
driver/main + gen/target: fix environment detection for ppc64 real type
1 parent 79d4e43 commit 45d2676

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

driver/main.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,13 @@ void registerPredefinedTargetVersions() {
683683
if (triple.getOS() == llvm::Triple::Linux) {
684684
VersionCondition::addPredefinedGlobalIdent(
685685
triple.getArch() == llvm::Triple::ppc64 ? "ELFv1" : "ELFv2");
686-
if (opts::mABI == "ieeelongdouble" && triple.isOSGlibc()) {
687-
// Only GLibc needs this for IEEELongDouble
688-
VersionCondition::addPredefinedGlobalIdent("D_PPCUseIEEE128");
686+
if (opts::mABI == "ieeelongdouble") {
687+
if (triple.getEnvironment() == llvm::Triple::GNU) {
688+
// Only GLibc needs this for IEEELongDouble
689+
VersionCondition::addPredefinedGlobalIdent("D_PPCUseIEEE128");
690+
} else {
691+
warning(Loc(), "float ABI 'ieeelongdouble' is not supported by the target system");
692+
}
689693
}
690694
}
691695
break;

gen/target.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,16 @@ const char *TargetCPP::typeMangle(Type *t) {
266266
triple.getArch() == llvm::Triple::x86_64;
267267
if (triple.getArch() == llvm::Triple::ppc64 ||
268268
triple.getArch() == llvm::Triple::ppc64le) {
269-
if (opts::mABI == "ieeelongdouble") {
269+
if (opts::mABI == "ieeelongdouble" &&
270+
triple.getEnvironment() == llvm::Triple::GNU) {
270271
return "u9__ieee128";
271272
}
272-
return "g";
273+
if (size(t) == 16) {
274+
// IBM long double
275+
return "g";
276+
}
277+
// fall back to 64-bit double type
278+
return "e";
273279
}
274280
return isAndroidX64 ? "g" : "e";
275281
}

0 commit comments

Comments
 (0)