mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
Working dmd on OpenBSD.
This commit is contained in:
parent
36e80656e7
commit
03b336fa18
17 changed files with 80 additions and 23 deletions
5
ini/openbsd/bin32/dmd.conf
Normal file
5
ini/openbsd/bin32/dmd.conf
Normal file
|
@ -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
ini/openbsd/bin64/dmd.conf
Normal file
5
ini/openbsd/bin64/dmd.conf
Normal file
|
@ -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
|
|
@ -221,7 +221,7 @@ static if (TARGET_OPENBSD)
|
|||
if (!exe)
|
||||
config.flags3 |= CFG3pic;
|
||||
config.objfmt = OBJ_ELF;
|
||||
config.ehmethod = useExceptions ? EHmethod.EH_DM : EHmethod.EH_NONE;
|
||||
config.ehmethod = useExceptions ? EHmethod.EH_DWARF : EHmethod.EH_NONE;
|
||||
}
|
||||
static if (TARGET_DRAGONFLYBSD)
|
||||
{
|
||||
|
|
|
@ -798,7 +798,7 @@ Lagain:
|
|||
spoff = 0;
|
||||
char guessneedframe = needframe;
|
||||
int cfa_offset = 0;
|
||||
// if (needframe && config.exe & (EX_LINUX | EX_FREEBSD | EX_SOLARIS) && !(usednteh & (NTEH_try | NTEH_except | NTEHcpp | EHcleanup | EHtry | NTEHpassthru)))
|
||||
// if (needframe && config.exe & (EX_LINUX | EX_FREEBSD | EX_OPENBSD | EX_SOLARIS) && !(usednteh & (NTEH_try | NTEH_except | NTEHcpp | EHcleanup | EHtry | NTEHpassthru)))
|
||||
// usednteh |= NTEHpassthru;
|
||||
|
||||
/* Compute BP offsets for variables on stack.
|
||||
|
|
|
@ -2836,7 +2836,7 @@ void callclib(ref CodeBuilder cdb, elem* e, uint clib, regm_t* pretregs, regm_t
|
|||
}
|
||||
if (pushebx)
|
||||
{
|
||||
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64))
|
||||
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64))
|
||||
{
|
||||
cdb.gen1(0x50 + CX); // PUSH ECX
|
||||
cdb.gen1(0x50 + BX); // PUSH EBX
|
||||
|
@ -3304,7 +3304,7 @@ void cdfunc(ref CodeBuilder cdb, elem* e, regm_t* pretregs)
|
|||
|
||||
/* Assume called function access statics
|
||||
*/
|
||||
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_FREEBSD | EX_FREEBSD64) &&
|
||||
if (config.exe & (EX_LINUX | EX_LINUX64 | EX_OSX | EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64) &&
|
||||
config.flags3 & CFG3pic)
|
||||
cgstate.accessedTLS = true;
|
||||
|
||||
|
|
|
@ -319,7 +319,7 @@ L1:
|
|||
*/
|
||||
bool type_zeroSize(type *t, tym_t tyf)
|
||||
{
|
||||
if (tyf != TYjfunc && config.exe & (EX_FREEBSD | EX_OSX))
|
||||
if (tyf != TYjfunc && config.exe & (EX_FREEBSD | EX_OPENBSD | EX_OSX))
|
||||
{
|
||||
/* Use clang convention for 0 size structs
|
||||
*/
|
||||
|
|
|
@ -124,7 +124,7 @@ static if (1)
|
|||
{
|
||||
if (funcsym_p.Sfunc.Fflags3 & Feh_none)
|
||||
{
|
||||
return (config.exe & (EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64)) != 0;
|
||||
return (config.exe & (EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64)) != 0;
|
||||
}
|
||||
|
||||
/* FreeBSD fails when having some frames as having unwinding info and some not.
|
||||
|
@ -133,7 +133,7 @@ static if (1)
|
|||
*/
|
||||
assert(!(usednteh & ~(EHtry | EHcleanup)));
|
||||
return (usednteh & (EHtry | EHcleanup)) ||
|
||||
(config.exe & (EX_FREEBSD | EX_FREEBSD64 | EX_DRAGONFLYBSD64)) && config.useExceptions;
|
||||
(config.exe & (EX_FREEBSD | EX_FREEBSD64 | EX_OPENBSD | EX_OPENBSD64 | EX_DRAGONFLYBSD64)) && config.useExceptions;
|
||||
}
|
||||
|
||||
static if (ELFOBJ)
|
||||
|
|
|
@ -3365,6 +3365,20 @@ void ElfObj_moduleinfo(Symbol *scc)
|
|||
ElfObj_reftoident(seg, SegData[seg].SDoffset, scc, 0, CFflags);
|
||||
}
|
||||
|
||||
/***************************************
|
||||
* Stuff pointer to DEH into its own section (deh).
|
||||
*/
|
||||
void ElfObj_dehinfo(Symbol *scc)
|
||||
{
|
||||
const CFflags = I64 ? (CFoffset64 | CFoff) : CFoff;
|
||||
|
||||
// needs to be writeable for PIC code, see Bugzilla 13117
|
||||
const shf_flags = SHF_ALLOC | SHF_WRITE;
|
||||
const seg = ElfObj_getsegment("deh", null, SHT_PROGBITS, shf_flags, _tysize[TYnptr]);
|
||||
SegData[seg].SDoffset +=
|
||||
ElfObj_reftoident(seg, SegData[seg].SDoffset, scc, 0, CFflags);
|
||||
}
|
||||
|
||||
/***************************************
|
||||
* Create startup/shutdown code to register an executable/shared
|
||||
* library (DSO) with druntime. Create one for each object file and
|
||||
|
@ -3378,10 +3392,26 @@ private void obj_rtinit()
|
|||
// make the symbols hidden so that each DSO gets its own brackets
|
||||
IDXSYM minfo_beg, minfo_end, dso_rec;
|
||||
|
||||
static if (TARGET_OPENBSD)
|
||||
{
|
||||
IDXSYM deh_beg, deh_end;
|
||||
}
|
||||
|
||||
{
|
||||
// needs to be writeable for PIC code, see Bugzilla 13117
|
||||
const shf_flags = SHF_ALLOC | SHF_WRITE;
|
||||
|
||||
static if (TARGET_OPENBSD)
|
||||
{
|
||||
const namidx3 = ElfObj_addstr(symtab_strings,"__start_deh");
|
||||
deh_beg = elf_addsym(namidx3, 0, 0, STT_NOTYPE, STB_GLOBAL, SHN_UNDEF, STV_HIDDEN);
|
||||
|
||||
ElfObj_getsegment("deh", null, SHT_PROGBITS, shf_flags, _tysize[TYnptr]);
|
||||
|
||||
const namidx4 = ElfObj_addstr(symtab_strings,"__stop_deh");
|
||||
deh_end = elf_addsym(namidx4, 0, 0, STT_NOTYPE, STB_GLOBAL, SHN_UNDEF, STV_HIDDEN);
|
||||
}
|
||||
|
||||
const namidx = ElfObj_addstr(symtab_strings,"__start_minfo");
|
||||
minfo_beg = elf_addsym(namidx, 0, 0, STT_NOTYPE, STB_GLOBAL, SHN_UNDEF, STV_HIDDEN);
|
||||
|
||||
|
@ -3532,7 +3562,14 @@ private void obj_rtinit()
|
|||
reltype = I64 ? R_X86_64_32 : R_386_32;
|
||||
}
|
||||
|
||||
const IDXSYM[3] syms = [dso_rec, minfo_beg, minfo_end];
|
||||
static if (TARGET_OPENBSD)
|
||||
{
|
||||
const IDXSYM[5] syms = [dso_rec, minfo_beg, minfo_end, deh_beg, deh_end];
|
||||
}
|
||||
else
|
||||
{
|
||||
const IDXSYM[3] syms = [dso_rec, minfo_beg, minfo_end];
|
||||
}
|
||||
|
||||
for (size_t i = (syms).sizeof / (syms[0]).sizeof; i--; )
|
||||
{
|
||||
|
|
|
@ -910,7 +910,6 @@ int os_critsecsize32()
|
|||
|
||||
int os_critsecsize64()
|
||||
{
|
||||
assert(0);
|
||||
return 8; // sizeof(pthread_mutex_t) on 64 bit
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ enum TargetOS : ubyte
|
|||
DragonFlyBSD = 0x40,
|
||||
|
||||
// Combination masks
|
||||
all = linux | Windows | OSX | FreeBSD | Solaris | DragonFlyBSD,
|
||||
Posix = linux | OSX | FreeBSD | Solaris | DragonFlyBSD,
|
||||
all = linux | Windows | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD,
|
||||
Posix = linux | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD,
|
||||
}
|
||||
|
||||
// Detect the current TargetOS
|
||||
|
@ -50,6 +50,10 @@ else version(OSX)
|
|||
{
|
||||
private enum targetOS = TargetOS.OSX;
|
||||
}
|
||||
else version(OpenBSD)
|
||||
{
|
||||
private enum targetOS = TargetOS.OpenBSD;
|
||||
}
|
||||
else version(FreeBSD)
|
||||
{
|
||||
private enum targetOS = TargetOS.FreeBSD;
|
||||
|
|
|
@ -1999,8 +1999,8 @@ enum class TargetOS : uint8_t
|
|||
FreeBSD = 16u,
|
||||
Solaris = 32u,
|
||||
DragonFlyBSD = 64u,
|
||||
all = 119u,
|
||||
Posix = 117u,
|
||||
all = 127u,
|
||||
Posix = 125u,
|
||||
};
|
||||
|
||||
extern Module* rootHasMain;
|
||||
|
@ -6737,8 +6737,8 @@ enum class TargetOS : uint8_t
|
|||
FreeBSD = 16u,
|
||||
Solaris = 32u,
|
||||
DragonFlyBSD = 64u,
|
||||
all = 119u,
|
||||
Posix = 117u,
|
||||
all = 127u,
|
||||
Posix = 125u,
|
||||
};
|
||||
|
||||
enum class TARGET : bool
|
||||
|
|
|
@ -32,8 +32,8 @@ enum TargetOS : ubyte
|
|||
DragonFlyBSD = 0x40,
|
||||
|
||||
// Combination masks
|
||||
all = linux | Windows | OSX | FreeBSD | Solaris | DragonFlyBSD,
|
||||
Posix = linux | OSX | FreeBSD | Solaris | DragonFlyBSD,
|
||||
all = linux | Windows | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD,
|
||||
Posix = linux | OSX | OpenBSD | FreeBSD | Solaris | DragonFlyBSD,
|
||||
}
|
||||
|
||||
template xversion(string s)
|
||||
|
|
|
@ -34,8 +34,8 @@ enum
|
|||
TargetOS_DragonFlyBSD = 0x40,
|
||||
|
||||
// Combination masks
|
||||
all = TargetOS_linux | TargetOS_Windows | TargetOS_OSX | TargetOS_FreeBSD | TargetOS_Solaris | TargetOS_DragonFlyBSD,
|
||||
Posix = TargetOS_linux | TargetOS_OSX | TargetOS_FreeBSD | TargetOS_Solaris | TargetOS_DragonFlyBSD,
|
||||
all = TargetOS_linux | TargetOS_Windows | TargetOS_OSX | TargetOS_OpenBSD | TargetOS_FreeBSD | TargetOS_Solaris | TargetOS_DragonFlyBSD,
|
||||
Posix = TargetOS_linux | TargetOS_OSX | TargetOS_OpenBSD | TargetOS_FreeBSD | TargetOS_Solaris | TargetOS_DragonFlyBSD,
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -743,6 +743,11 @@ public int runLINK()
|
|||
// Link against libdl for phobos usage of dlopen
|
||||
argv.push("-ldl");
|
||||
}
|
||||
else version (OpenBSD)
|
||||
{
|
||||
// Link against -lc++abi for Unwind symbols
|
||||
argv.push("-lc++abi");
|
||||
}
|
||||
if (global.params.verbose)
|
||||
{
|
||||
// Print it
|
||||
|
|
|
@ -1338,7 +1338,7 @@ void addDefaultVersionIdentifiers(const ref Param params)
|
|||
VersionCondition.addPredefinedGlobalIdent("Posix");
|
||||
VersionCondition.addPredefinedGlobalIdent("OpenBSD");
|
||||
VersionCondition.addPredefinedGlobalIdent("ELFv1");
|
||||
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Gcc");
|
||||
VersionCondition.addPredefinedGlobalIdent("CppRuntime_Clang");
|
||||
}
|
||||
else if (params.targetOS == TargetOS.DragonFlyBSD)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,8 @@ else version (FreeBSD)
|
|||
import core.sys.freebsd.sys.elf;
|
||||
else version (DragonFlyBSD)
|
||||
import core.sys.dragonflybsd.sys.elf;
|
||||
else version (OpenBSD)
|
||||
import core.sys.openbsd.sys.elf;
|
||||
else version (Solaris)
|
||||
import core.sys.solaris.elf;
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ extern (C++) struct Target
|
|||
assert(0);
|
||||
if (params.is64bit)
|
||||
{
|
||||
if (params.targetOS & (TargetOS.linux | TargetOS.FreeBSD | TargetOS.DragonFlyBSD | TargetOS.Solaris))
|
||||
if (params.targetOS & (TargetOS.linux | TargetOS.FreeBSD | TargetOS.OpenBSD | TargetOS.DragonFlyBSD | TargetOS.Solaris))
|
||||
{
|
||||
realsize = 16;
|
||||
realpad = 6;
|
||||
|
@ -755,7 +755,7 @@ extern (C++) struct Target
|
|||
extern (C++) ulong parameterSize(const ref Loc loc, Type t)
|
||||
{
|
||||
if (!params.is64bit &&
|
||||
(params.targetOS & (TargetOS.FreeBSD | TargetOS.OSX)))
|
||||
(params.targetOS & (TargetOS.FreeBSD | TargetOS.OpenBSD | TargetOS.OSX)))
|
||||
{
|
||||
/* These platforms use clang, which regards a struct
|
||||
* with size 0 as being of size 0 on the parameter stack,
|
||||
|
@ -962,7 +962,7 @@ struct TargetC
|
|||
assert(0);
|
||||
if (params.is64bit)
|
||||
{
|
||||
if (params.targetOS & (TargetOS.linux | TargetOS.FreeBSD | TargetOS.DragonFlyBSD | TargetOS.Solaris))
|
||||
if (params.targetOS & (TargetOS.linux | TargetOS.FreeBSD | TargetOS.OpenBSD | TargetOS.DragonFlyBSD | TargetOS.Solaris))
|
||||
longsize = 8;
|
||||
else if (params.targetOS == TargetOS.OSX)
|
||||
longsize = 8;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue