Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ append("-DOPAQUE_VTBLS" LDC_CXXFLAGS)
append("\"-DLDC_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}\"" LDC_CXXFLAGS)
append("-DLDC_LLVM_VER=${LDC_LLVM_VER}" LDC_CXXFLAGS)
append("\"-DLDC_LIBDIR_SUFFIX=\\\"${LIB_SUFFIX}\\\"\"" LDC_CXXFLAGS)
append("-DLDC_HOST_FE_VER=${D_COMPILER_FE_VERSION}" LDC_CXXFLAGS)

if(GENERATE_OFFTI)
append("-DGENERATE_OFFTI" LDC_CXXFLAGS)
Expand Down
4 changes: 4 additions & 0 deletions cmake/Modules/FindDCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# D_COMPILER_FLAGS - D compiler flags (could be passed in the DMD environment variable)
# D_COMPILER_ID = {"DigitalMars", "LDMD", "LDC", "GDC"}
# D_COMPILER_VERSION_STRING - String containing the compiler version, e.g. "DMD64 D Compiler v2.070.2"
# D_COMPILER_FE_VERSION - compiler front-end version, e.g. "2070"
# D_COMPILER_DMD_COMPAT - true if the D compiler cmdline interface is compatible with DMD


Expand Down Expand Up @@ -64,13 +65,16 @@ if (D_COMPILER)
OUTPUT_VARIABLE D_COMPILER_VERSION_STRING
ERROR_VARIABLE D_COMPILER_VERSION_STRING
ERROR_QUIET)
string(REGEX MATCH " (D Compiler|based on DMD) v([0-9]+)\\.([0-9]+)" D_COMPILER_FE_VERSION "${D_COMPILER_VERSION_STRING}")
math(EXPR D_COMPILER_FE_VERSION ${CMAKE_MATCH_2}*1000+${CMAKE_MATCH_3}) # e.g., 2079
string(REGEX MATCH "^[^\r\n:]*" D_COMPILER_VERSION_STRING "${D_COMPILER_VERSION_STRING}")
endif()


if (D_COMPILER_FOUND)
message(STATUS "Found host D compiler ${D_COMPILER}, with default flags '${D_COMPILER_FLAGS}'")
message(STATUS "Host D compiler version: ${D_COMPILER_VERSION_STRING}")
message(STATUS "Host D compiler front-end version: ${D_COMPILER_FE_VERSION}")
else()
message(FATAL_ERROR "No D compiler found! Try setting the 'D_COMPILER' variable or 'DMD' environment variable.")
endif()
6 changes: 5 additions & 1 deletion dmd/cppmangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -943,14 +943,18 @@ public:
if (t.isImmutable() || t.isShared())
return error(t);

/* __c_long and __c_ulong get special mangling
/* magic structs __c_(u)long(long) get special mangling
*/
const id = t.sym.ident;
//printf("struct id = '%s'\n", id.toChars());
if (id == Id.__c_long)
return writeBasicType(t, 0, 'l');
else if (id == Id.__c_ulong)
return writeBasicType(t, 0, 'm');
else if (id == Id.__c_longlong)
return writeBasicType(t, 0, 'x');
else if (id == Id.__c_ulonglong)
return writeBasicType(t, 0, 'y');

//printf("TypeStruct %s\n", t.toChars());
doSymbol(t);
Expand Down
21 changes: 12 additions & 9 deletions dmd/cppmanglewin.d
Original file line number Diff line number Diff line change
Expand Up @@ -374,16 +374,18 @@ public:
override void visit(TypeStruct type)
{
const id = type.sym.ident;
char c;
string c;
if (id == Id.__c_long_double)
c = 'O'; // VC++ long double
c = "O"; // VC++ long double
else if (id == Id.__c_long)
c = 'J'; // VC++ long
c = "J"; // VC++ long
else if (id == Id.__c_ulong)
c = 'K'; // VC++ unsigned long
else
c = 0;
if (c)
c = "K"; // VC++ unsigned long
else if (id == Id.__c_longlong)
c = "_J"; // VC++ long long
else if (id == Id.__c_ulonglong)
c = "_K"; // VC++ unsigned long long
if (c.length)
{
if (type.isImmutable() || type.isShared())
{
Expand All @@ -396,7 +398,7 @@ public:
return;
}
mangleModifier(type);
buf.writeByte(c);
buf.writestring(c);
}
else
{
Expand Down Expand Up @@ -1025,7 +1027,8 @@ private:
if (rettype.ty == Tstruct || rettype.ty == Tenum)
{
const id = rettype.toDsymbol(null).ident;
if (id != Id.__c_long_double && id != Id.__c_long && id != Id.__c_ulong)
if (id != Id.__c_long_double && id != Id.__c_long && id != Id.__c_ulong &&
id != Id.__c_longlong && id != Id.__c_ulonglong)
{
tmp.buf.writeByte('?');
tmp.buf.writeByte('A');
Expand Down
2 changes: 2 additions & 0 deletions dmd/id.d
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ immutable Msgtable[] msgtable =
{ "gate", "__gate" },
{ "__c_long" },
{ "__c_ulong" },
{ "__c_longlong" },
{ "__c_ulonglong" },
{ "__c_long_double" },
{ "cpp_type_info_ptr", "__cpp_type_info_ptr" },
{ "_assert", "assert" },
Expand Down
2 changes: 2 additions & 0 deletions dmd/id.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct Id
static Identifier *offsetof;
static Identifier *__c_long;
static Identifier *__c_ulong;
static Identifier *__c_longlong;
static Identifier *__c_ulonglong;
static Identifier *__c_long_double;
static Identifier *__switch;
static Identifier *crt_constructor;
Expand Down
12 changes: 9 additions & 3 deletions dmd/mars.d
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,14 @@ extern (C++) int mars_mainBody(ref Strings files, ref Strings libmodules)
Objc._init();
builtin_init();

version (IN_LLVM) {} else
version (IN_LLVM)
{
// LDC prints binary/version/config before entering this function.
// DMD prints the predefined versions as part of addDefaultVersionIdentifiers().
// Let's do it here after initialization, as e.g. Objc.init() may add `D_ObjectiveC`.
printPredefinedVersions();
}
else
{
printPredefinedVersions();

Expand Down Expand Up @@ -1610,8 +1617,7 @@ void addDefaultVersionIdentifiers()

} // !IN_LLVM

// IN_LLVM replaced: `private` by `extern (C++)`
extern (C++) void printPredefinedVersions()
private void printPredefinedVersions()
{
if (global.params.verbose && global.versionids)
{
Expand Down
1 change: 0 additions & 1 deletion dmd/mars.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ void ensurePathToNameExists(Loc loc, const char *name);

#if IN_LLVM
int mars_mainBody(Strings &files, Strings &libmodules);
void printPredefinedVersions();
#endif

const char *importHint(const char *s);
Expand Down
1 change: 0 additions & 1 deletion driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,6 @@ int cppmain(int argc, char **argv) {

void addDefaultVersionIdentifiers() {
registerPredefinedVersions();
printPredefinedVersions();
}

void codegenModules(Modules &modules) {
Expand Down
1 change: 1 addition & 0 deletions gen/abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ bool TargetABI::isMagicCppStruct(Type *t) {

Identifier *id = static_cast<TypeStruct *>(t)->sym->ident;
return (id == Id::__c_long) || (id == Id::__c_ulong) ||
(id == Id::__c_longlong) || (id == Id::__c_ulonglong) ||
(id == Id::__c_long_double);
}

Expand Down
4 changes: 2 additions & 2 deletions gen/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ struct TargetABI {
/// * complex number
static bool isAggregate(Type *t);

/// The frontend uses magic structs to express the variable-sized C types
/// ((unsigned) long, long double) for C++ mangling purposes.
/// The frontend uses magic structs to express some primitive C types
/// ((unsigned) long (long), long double) for C++ mangling purposes.
static bool isMagicCppStruct(Type *t);

/// Returns true if the D type is a Plain-Old-Datatype, optionally excluding
Expand Down
8 changes: 5 additions & 3 deletions gen/target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ void Target::_init() {

cppExceptions = true;

c_longsize = global.params.is64bit ? 8 : 4;
c_longsize =
global.params.is64bit && !triple.isWindowsMSVCEnvironment() ? 8 : 4;
c_long_doublesize = realsize;
classinfosize = 0; // unused
maxStaticDataSize = std::numeric_limits<unsigned long long>::max();

int64Mangle = triple.isOSDarwin() ? 'x' : 'l';
uint64Mangle = triple.isOSDarwin() ? 'y' : 'm';
// These C++ mangling characters are only used for 64-bit POSIX targets.
int64Mangle = 'l'; // C++ long
uint64Mangle = 'm'; // C++ unsigned long

// {Float,Double,Real}Properties have been initialized with the D host
// compiler's properties.
Expand Down
2 changes: 1 addition & 1 deletion runtime/druntime