Skip to content
Open
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
5 changes: 5 additions & 0 deletions compiler/ini/hurd/bin32/dmd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Environment32]
DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L--export-dynamic -fPIC

[Environment64]
DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib64 -L--export-dynamic -fPIC
5 changes: 5 additions & 0 deletions compiler/ini/hurd/bin64/dmd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Environment32]
DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib32 -L--export-dynamic -fPIC

[Environment64]
DFLAGS=-I%@P%/../../src/phobos -I%@P%/../../src/druntime/import -L-L%@P%/../lib64 -L--export-dynamic -fPIC
4 changes: 3 additions & 1 deletion compiler/src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,7 @@ bool download(string to, string from, uint tries = 3)
/**
Detects the host OS.

Returns: a string from `{windows, osx,linux,freebsd,openbsd,netbsd,dragonflybsd,solaris}`
Returns: a string from `{windows, osx,linux,freebsd,openbsd,netbsd,dragonflybsd,solaris,hurd}`
*/
string detectOS()
{
Expand All @@ -1709,6 +1709,8 @@ string detectOS()
return "dragonflybsd";
else version(Solaris)
return "solaris";
else version(Hurd)
return "hurd";
else
static assert(0, "Unrecognized or unsupported OS.");
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/backend/arm/cod1.d
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ void cdfunc(ref CGstate cg, ref CodeBuilder cdb, elem* e, ref regm_t pretregs)

/* Assume called function accesses TLS statics
*/
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64) &&
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_HURD | EX_HURD64) &&
Comment thread
ibuclaw marked this conversation as resolved.
config.flags3 & CFG3pic)
cg.accessedTLS = true;

Expand Down
46 changes: 41 additions & 5 deletions compiler/src/dmd/backend/backconfig.d
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,42 @@ void out_config_init(
cfg.objfmt = OBJ_ELF;
cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE;
}
else if (cfg.exe & (EX_HURD | EX_HURD64))
{
cfg.fpxmmregs = true;
cfg.avx = avx;
if (model == 64)
{
cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE;
}
else
{
cfg.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE;
if (!exe)
cfg.flags |= CFGromable; // put switch tables in code segment
}
cfg.flags |= CFGnoebp;
switch (pic)
{
case 0: // PIC.fixed
break;

case 1: // PIC.pic
cfg.flags3 |= CFG3pic;
break;

case 2: // PIC.pie
cfg.flags3 |= CFG3pic | CFG3pie;
break;

default:
assert(0);
}
if (symdebug)
cfg.flags |= CFGalwaysframe;

cfg.objfmt = OBJ_ELF;
}

cfg.flags2 |= CFG2nodeflib; // no default library
cfg.flags3 |= CFG3eseqds;
Expand Down Expand Up @@ -320,7 +356,7 @@ static if (0)
if (symdebug)
{
if (cfg.exe & (EX_LINUX | EX_LINUX64 | EX_OPENBSD | EX_OPENBSD64 | EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64 |
EX_SOLARIS | EX_SOLARIS64 | EX_OSX | EX_OSX64))
EX_SOLARIS | EX_SOLARIS64 | EX_OSX | EX_OSX64 | EX_HURD | EX_HURD64))
{
cfg.addlinenumbers = 1;
cfg.fulltypes = (symdebug == 1) ? CVDWARF_D : CVDWARF_C;
Expand Down Expand Up @@ -446,7 +482,7 @@ void util_set32(exefmt_t exe)
_tysize[TYnullptr] = LONGSIZE;
_tysize[TYnptr] = LONGSIZE;
_tysize[TYnref] = LONGSIZE;
if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64))
if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_HURD | EX_HURD64))
{
_tysize[TYreal] = 12;
_tysize[TYireal] = 12;
Expand Down Expand Up @@ -477,7 +513,7 @@ if (exe & EX_windos)
_tyalignsize[TYnullptr] = LONGSIZE;
_tyalignsize[TYnref] = LONGSIZE;
_tyalignsize[TYnptr] = LONGSIZE;
if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64))
if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_HURD | EX_HURD64))
{
_tyalignsize[TYreal] = 4;
_tyalignsize[TYireal] = 4;
Expand Down Expand Up @@ -533,7 +569,7 @@ void util_set64(exefmt_t exe)
_tysize[TYnptr] = 8;
_tysize[TYnref] = 8;
if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD |
EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OSX | EX_OSX64))
EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_OSX | EX_OSX64 | EX_HURD | EX_HURD64))
{
_tysize[TYreal] = 16;
_tysize[TYireal] = 16;
Expand All @@ -557,7 +593,7 @@ void util_set64(exefmt_t exe)
_tyalignsize[TYnullptr] = 8;
_tyalignsize[TYnptr] = 8;
_tyalignsize[TYnref] = 8;
if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64))
if (exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS | EX_SOLARIS64 | EX_HURD | EX_HURD64))
{
_tyalignsize[TYreal] = 16;
_tyalignsize[TYireal] = 16;
Expand Down
12 changes: 10 additions & 2 deletions compiler/src/dmd/backend/cdef.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum TARGET_OPENBSD = xversion!`OpenBSD`;
enum TARGET_SOLARIS = xversion!`Solaris`;
enum TARGET_WINDOS = xversion!`Windows`;
enum TARGET_DRAGONFLYBSD = xversion!`DragonFlyBSD`;
enum TARGET_HURD = xversion!`Hurd`;

//
// Attributes
Expand Down Expand Up @@ -304,6 +305,8 @@ enum
EX_OPENBSD = 0x400000,
EX_OPENBSD64 = 0x800000,
EX_DRAGONFLYBSD64 = 0x1000000,
EX_HURD = 0x2000000,
EX_HURD64 = 0x4000000,
}

// All of them
Expand All @@ -328,7 +331,9 @@ enum exefmt_t EX_all =
EX_SOLARIS64 |
EX_OPENBSD |
EX_OPENBSD64 |
EX_DRAGONFLYBSD64;
EX_DRAGONFLYBSD64 |
EX_HURD |
EX_HURD64;

// All segmented memory models
enum exefmt_t EX_segmented = EX_DOSX | EX_ZPM | EX_RATIONAL | EX_PHARLAP |
Expand All @@ -350,6 +355,7 @@ enum exefmt_t EX_posix = EX_LINUX | EX_LINUX64 |
EX_FREEBSD | EX_FREEBSD64 |
EX_SOLARIS | EX_SOLARIS64 |
EX_OPENBSD | EX_OPENBSD64 |
EX_HURD | EX_HURD64 |
Comment thread
yelninei marked this conversation as resolved.
EX_DRAGONFLYBSD64;

// All 16 bit targets
Expand All @@ -362,7 +368,8 @@ enum exefmt_t EX_32 = EX_DOSX | EX_OS2 | EX_PHARLAP |
EX_OSX |
EX_FREEBSD |
EX_SOLARIS |
EX_OPENBSD;
EX_OPENBSD |
EX_HURD;

// All 64 bit targets
enum exefmt_t EX_64 =
Expand All @@ -372,6 +379,7 @@ enum exefmt_t EX_64 =
EX_FREEBSD64 |
EX_SOLARIS64 |
EX_OPENBSD64 |
EX_HURD64 |
EX_DRAGONFLYBSD64;
Comment thread
yelninei marked this conversation as resolved.

// Constraints
Expand Down
9 changes: 7 additions & 2 deletions compiler/src/dmd/backend/elfobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ else
enum DMDV2 = false;
bool REQUIRE_DSO_REGISTRY()
{
return DMDV2 && (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64));
return DMDV2 && (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64 | EX_HURD | EX_HURD64));
}

/**
Expand All @@ -81,7 +81,7 @@ bool USE_INIT_ARRAY() { return true; }
* FreeBSD defaults to lld as of FreeBSD 13 (2021); OpenBSD as of 6.5 (2019).
*/

bool ELF_COMDAT() { return (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64)) != 0; }
bool ELF_COMDAT() { return (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_HURD | EX_HURD64)) != 0; }

/***************************************************
* Correspondence of relocation types
Expand Down Expand Up @@ -1239,6 +1239,11 @@ void ElfObj_term(const(char)[] objfilename)
ELFOSABI = ELFOSABI_OPENBSD;
break;

case EX_HURD:
case EX_HURD64:
ELFOSABI = ELFOSABI_GNU;
break;

case EX_SOLARIS:
case EX_SOLARIS64:
case EX_DRAGONFLYBSD64:
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dmd/backend/melf.d
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ nothrow:
enum ELFOSABI_SYSV = 0; /* UNIX System V ABI */
enum ELFOSABI_HPUX = 1; /* HP-UX */
enum ELFOSABI_NETBSD = 2;
enum ELFOSABI_LINUX = 3;
enum ELFOSABI_GNU = 3;
enum ELFOSABI_LINUX = ELFOSABI_GNU;
enum ELFOSABI_FREEBSD = 9;
enum ELFOSABI_OPENBSD = 12;
enum ELFOSABI_ARM = 97; /* ARM */
Expand Down
21 changes: 11 additions & 10 deletions compiler/src/dmd/backend/x86/cod1.d
Original file line number Diff line number Diff line change
Expand Up @@ -2152,7 +2152,8 @@ void getClibFunction(uint clib, ref Symbol* s, ref ClibInfo* cinfo, objfmt_t obj
EX_FREEBSD | EX_FREEBSD64 |
EX_OPENBSD | EX_OPENBSD64 |
EX_DRAGONFLYBSD64 |
EX_SOLARIS | EX_SOLARIS64);
EX_SOLARIS | EX_SOLARIS64 |
EX_HURD | EX_HURD64);

switch (clib)
{
Expand All @@ -2174,7 +2175,7 @@ void getClibFunction(uint clib, ref Symbol* s, ref ClibInfo* cinfo, objfmt_t obj

case CLIB.ldiv:
cinfo.retregs16 = mDX|mAX;
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_HURD))
{
s = symboly("__divdi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand Down Expand Up @@ -2202,7 +2203,7 @@ void getClibFunction(uint clib, ref Symbol* s, ref ClibInfo* cinfo, objfmt_t obj

case CLIB.lmod:
cinfo.retregs16 = mCX|mBX;
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_HURD))
{
s = symboly("__moddi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand Down Expand Up @@ -2230,7 +2231,7 @@ void getClibFunction(uint clib, ref Symbol* s, ref ClibInfo* cinfo, objfmt_t obj

case CLIB.uldiv:
cinfo.retregs16 = mDX|mAX;
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_HURD))
{
s = symboly("__udivdi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand Down Expand Up @@ -2258,7 +2259,7 @@ void getClibFunction(uint clib, ref Symbol* s, ref ClibInfo* cinfo, objfmt_t obj

case CLIB.ulmod:
cinfo.retregs16 = mCX|mBX;
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD))
if (exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_HURD))
{
s = symboly("__umoddi3", mAX|mBX|mCX|mDX);
cinfo.flags = INFpushebx;
Expand Down Expand Up @@ -2899,7 +2900,7 @@ void callclib(ref CGstate cg, ref CodeBuilder cdb, elem* e, uint clib, ref regm_
}
if (pushebx)
{
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64))
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_HURD | EX_HURD64))
{
cdb.gen1(0x50 + CX); // PUSH ECX
cdb.gen1(0x50 + BX); // PUSH EBX
Expand All @@ -2920,7 +2921,7 @@ void callclib(ref CGstate cg, ref CodeBuilder cdb, elem* e, uint clib, ref regm_
cdb.gen1(0x50 + DX); // PUSH EDX
cdb.gen1(0x50 + AX); // PUSH EAX
}
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS))
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS | EX_HURD))
{
// Note: not for OSX
/* Pass EBX on the stack instead, this is because EBX is used
Expand Down Expand Up @@ -3408,7 +3409,7 @@ void cdfunc(ref CGstate cg, ref CodeBuilder cdb, elem* e, ref regm_t pretregs)

/* Assume called function access statics
*/
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64) &&
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_HURD | EX_HURD64) &&
config.flags3 & CFG3pic)
cgstate.accessedTLS = true;

Expand Down Expand Up @@ -3455,7 +3456,7 @@ void cdfunc(ref CGstate cg, ref CodeBuilder cdb, elem* e, ref regm_t pretregs)
parameters[i].numalign = 0;
if (alignsize > stackalign &&
(I64 || (alignsize >= 16 &&
(config.exe & (EX_OSX | EX_LINUX) && (tyaggregate(ep.Ety) || tyvector(ep.Ety))))))
(config.exe & (EX_OSX | EX_LINUX | EX_HURD) && (tyaggregate(ep.Ety) || tyvector(ep.Ety))))))
{
if (alignsize > STACKALIGN)
{
Expand Down Expand Up @@ -4023,7 +4024,7 @@ private void funccall(ref CGstate cg, ref CodeBuilder cdb, elem* e, uint numpara
tym_t e11ty = tybasic(e11.Ety);
assert(!I16 || (e11ty == (farfunc ? TYfptr : TYnptr)));
load_localgot(cdb);
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS)) // 32 bit only
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS | EX_HURD)) // 32 bit only
{
if (config.flags3 & CFG3pic)
keepmsk |= mBX;
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dmd/backend/x86/cod3.d
Original file line number Diff line number Diff line change
Expand Up @@ -2460,7 +2460,7 @@ void outjmptab(block* b)
break;
}
}
if (config.exe & (EX_LINUX64 | EX_FREEBSD64 | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS64))
if (config.exe & (EX_LINUX64 | EX_FREEBSD64 | EX_OPENBSD64 | EX_DRAGONFLYBSD64 | EX_SOLARIS64 | EX_HURD64))
{
if (config.flags3 & CFG3pic)
{
Expand All @@ -2473,7 +2473,7 @@ void outjmptab(block* b)
*poffset += 8;
}
}
else if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS))
else if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS | EX_HURD))
{
if (config.flags3 & CFG3pic)
{
Expand Down Expand Up @@ -3126,7 +3126,7 @@ void cdgot(ref CGstate cg, ref CodeBuilder cdb, elem* e, ref regm_t pretregs)
@trusted
void load_localgot(ref CodeBuilder cdb)
{
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS)) // note: I32 only
if (config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS | EX_HURD)) // note: I32 only
{
if (config.flags3 & CFG3pic)
{
Expand Down
12 changes: 9 additions & 3 deletions compiler/src/dmd/cli.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ enum TargetOS : ubyte
FreeBSD = 0x10,
Solaris = 0x20,
DragonFlyBSD = 0x40,
Hurd = 0x80,

// Combination masks
all = linux | Windows | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD,
Posix = linux | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD,
all = linux | Windows | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD | Hurd,
Posix = linux | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD | Hurd,
}

// Detect the current TargetOS
Expand Down Expand Up @@ -68,6 +69,10 @@ else version(Solaris)
{
private enum targetOS = TargetOS.Solaris;
}
else version(Hurd)
{
private enum targetOS = TargetOS.Hurd;
}
else
{
private enum targetOS = TargetOS.all;
Expand Down Expand Up @@ -791,6 +796,7 @@ dmd -cov -unittest myprog.d
$(LI $(I openbsd): OpenBSD)
$(LI $(I osx): OSX)
$(LI $(I solaris): Solaris)
$(LI $(I hurd): Hurd)
$(LI $(I windows): Windows)
)`
),
Expand Down Expand Up @@ -881,7 +887,7 @@ dmd -cov -unittest myprog.d
$(LI `freestanding` for no operating system)
$(LI `darwin` or `osx` for MacOS)
$(LI `dragonfly` or `dragonflybsd` for DragonflyBSD)
$(LI `freebsd`, `openbsd`, `linux`, `solaris` or `windows` for their respective operating systems)
$(LI `freebsd`, `openbsd`, `linux`, `solaris`, `hurd` or `windows` for their respective operating systems)
)
$(LI $(I cenv) is the C runtime environment and is optional:)
$(UL
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dmd/dmdparams.d
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ struct Triple
os = Target.OS.OpenBSD;
else if (matches("linux"))
os = Target.OS.linux;
else if (matches("hurd"))
os = Target.OS.Hurd;
else if (matches("windows"))
os = Target.OS.Windows;
else
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dmd/dmsc.d
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void backend_init(const ref Param params, const ref DMDparams driverParams, cons
case Target.OS.OpenBSD: exfmt = is64 ? EX_OPENBSD64 : EX_OPENBSD; break;
case Target.OS.Solaris: exfmt = is64 ? EX_SOLARIS64 : EX_SOLARIS; break;
case Target.OS.DragonFlyBSD: assert(is64); exfmt = EX_DRAGONFLYBSD64; break;
case Target.OS.Hurd: exfmt = is64 ? EX_HURD64 : EX_HURD; break;
default: assert(0);
}

Expand Down
Loading
Loading