diff --git a/dmd/cppmangle.d b/dmd/cppmangle.d index 96a1605c7ce..05b0418b96b 100644 --- a/dmd/cppmangle.d +++ b/dmd/cppmangle.d @@ -1196,7 +1196,15 @@ extern(C++): case Tint128: c = 'n'; break; case Tuns128: c = 'o'; break; case Tfloat64: c = 'd'; break; +version (IN_LLVM) +{ + // there are special cases for D `real`, handled via Target.cppTypeMangle() in the default case + case Tfloat80: goto default; +} +else +{ case Tfloat80: c = 'e'; break; +} case Tbool: c = 'b'; break; case Tchar: c = 'c'; break; case Twchar: c = 't'; break; // unsigned short (perhaps use 'Ds' ? diff --git a/dmd/target.d b/dmd/target.d index 0d469fe5995..cc9a57b2618 100644 --- a/dmd/target.d +++ b/dmd/target.d @@ -109,11 +109,10 @@ struct Target // implemented in gen/target.cpp: static void _init(); - // Type sizes and support. static uint alignsize(Type type); static uint fieldalign(Type type); static uint critsecsize(); - static Type va_listType(); // get type of va_list + static Type va_listType(); static int isVectorTypeSupported(int sz, Type type); static bool isVectorOpSupported(Type type, TOK op, Type t2 = null); @@ -133,7 +132,7 @@ struct Target return cppTypeInfoMangleItanium(cd); } - static Expression getTargetInfo(const(char)* name, const ref Loc loc); + static const(char)* cppTypeMangle(Type t); } else // !IN_LLVM { @@ -500,7 +499,6 @@ struct Target else static assert(0, "fix this"); } - } // !IN_LLVM /** * Gets vendor-specific type mangling for C++ ABI. @@ -514,6 +512,7 @@ struct Target { return null; } + } // !IN_LLVM /** * Get the type that will really be used for passing the given argument @@ -548,6 +547,17 @@ struct Target return global.params.isWindows ? LINK.windows : LINK.c; } + version (IN_LLVM) + { + extern (C++): + + static TypeTuple toArgTypes(Type t); + static bool isReturnOnStack(TypeFunction tf, bool needsThis); + // unused: static ulong parameterSize(const ref Loc loc, Type t); + static Expression getTargetInfo(const(char)* name, const ref Loc loc); + } + else // !IN_LLVM + { /** * Describes how an argument type is passed to a function on target. * Params: @@ -557,19 +567,12 @@ struct Target * empty tuple if type is always passed on the stack * null if the type is a `void` or argtypes aren't supported by the target */ - version (IN_LLVM) - { - extern (C++) static TypeTuple toArgTypes(Type t); - } - else - { extern (C++) static TypeTuple toArgTypes(Type t) { if (global.params.is64bit && global.params.isWindows) return null; return .toArgTypes(t); } - } /** * Determine return style of function - whether in registers or @@ -580,12 +583,6 @@ struct Target * Returns: * true if return value from function is on the stack */ - version (IN_LLVM) - { - extern (C++) static bool isReturnOnStack(TypeFunction tf, bool needsThis); - } - else - { extern (C++) static bool isReturnOnStack(TypeFunction tf, bool needsThis) { if (tf.isref) @@ -738,10 +735,7 @@ struct Target return false; } } - } // !IN_LLVM - version (IN_LLVM) {} else - { /*** * Determine the size a value of type `t` will be when it * is passed on the function parameter stack. diff --git a/driver/linker-gcc.cpp b/driver/linker-gcc.cpp index 17ce1ebbf81..421f5d27789 100644 --- a/driver/linker-gcc.cpp +++ b/driver/linker-gcc.cpp @@ -524,7 +524,9 @@ void ArgsBuilder::build(llvm::StringRef outputPath, void ArgsBuilder::addLinker() { if (!opts::linker.empty()) { args.push_back("-fuse-ld=" + opts::linker); - } else if (global.params.isLinux) { + } else if (global.params.isLinux && + global.params.targetTriple->getEnvironment() != + llvm::Triple::Android) { // Default to ld.gold on Linux due to ld.bfd issues with ThinLTO (see #2278) // and older bfd versions stripping llvm.used symbols (e.g., ModuleInfo // refs) with --gc-sections (see #2870). diff --git a/gen/target.cpp b/gen/target.cpp index 4a0dd1707b1..25cdcf196f7 100644 --- a/gen/target.cpp +++ b/gen/target.cpp @@ -26,6 +26,11 @@ using llvm::APFloat; +// in dmd/argtypes.d: +TypeTuple *toArgTypes(Type *t); +// in dmd/argtypes_sysv_x64.d: +TypeTuple *toArgTypes_sysv_x64(Type *t); + void Target::_init() { CTFloat::initialize(); @@ -206,6 +211,34 @@ bool Target::isVectorOpSupported(Type *type, TOK op, Type *t2) { return true; } +/** + * Gets vendor-specific type mangling for C++ ABI. + * Params: + * t = type to inspect + * Returns: + * string if type is mangled specially on target + * null if unhandled + */ +const char *Target::cppTypeMangle(Type *t) { + if (t->ty == Tfloat80) { + const auto &triple = *global.params.targetTriple; + // `long double` on Android/x64 is __float128 and mangled as `g` + bool isAndroidX64 = triple.getEnvironment() == llvm::Triple::Android && + triple.getArch() == llvm::Triple::x86_64; + return isAndroidX64 ? "g" : "e"; + } + return nullptr; +} + +TypeTuple *Target::toArgTypes(Type *t) { + const auto &triple = *global.params.targetTriple; + if (triple.getArch() == llvm::Triple::x86) + return ::toArgTypes(t); + if (triple.getArch() == llvm::Triple::x86_64 && !triple.isOSWindows()) + return toArgTypes_sysv_x64(t); + return nullptr; +} + bool Target::isReturnOnStack(TypeFunction *tf, bool needsThis) { return gABI->returnInArg(tf, needsThis); } @@ -256,15 +289,3 @@ Expression *Target::getTargetInfo(const char *name_, const Loc &loc) { return nullptr; } - -TypeTuple *toArgTypes(Type *t); -TypeTuple *toArgTypes_sysv_x64(Type *t); - -TypeTuple *Target::toArgTypes(Type *t) { - const auto &triple = *global.params.targetTriple; - if (triple.getArch() == llvm::Triple::x86) - return ::toArgTypes(t); - if (triple.getArch() == llvm::Triple::x86_64 && !triple.isOSWindows()) - return toArgTypes_sysv_x64(t); - return nullptr; -} diff --git a/runtime/druntime b/runtime/druntime index 8b42b5787aa..e901e9dc3c0 160000 --- a/runtime/druntime +++ b/runtime/druntime @@ -1 +1 @@ -Subproject commit 8b42b5787aaeb786ddbc71fdf32e24d263d9cb99 +Subproject commit e901e9dc3c0edcecd9d9b581933fc3c421769421 diff --git a/runtime/phobos b/runtime/phobos index 59fc794f065..e16ecf941e0 160000 --- a/runtime/phobos +++ b/runtime/phobos @@ -1 +1 @@ -Subproject commit 59fc794f065088522ae73d623d86449e08662742 +Subproject commit e16ecf941e02b9c595beb1990d148609189839d5