Skip to content

Commit

Permalink
more removal of static compilation from headers (#11962)
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright authored Nov 23, 2020
1 parent 8fa3dad commit 0339f54
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 53 deletions.
15 changes: 1 addition & 14 deletions src/dmd/backend/cc.d
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ enum WM
WM_ccast = 25,
WM_obsolete = 26,

// if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS
// Posix
WM_skip_attribute = 27, // skip GNUC attribute specification
WM_warning_message = 28, // preprocessor warning message
WM_bad_vastart = 29, // args for builtin va_start bad
Expand All @@ -87,19 +87,6 @@ enum LANG
LANGjapanese,
}


//#if SPP || SCPP
//#include "msgs2.h"
//#endif
//#include "ty.h"
//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS
//#include "../tk/mem.h"
//#else
//#include "mem.h"
//#endif
//#include "list.h"
//#include "vec.h"

version (SPP)
{
enum COMPILER = "Preprocessor";
Expand Down
9 changes: 0 additions & 9 deletions src/dmd/backend/code_x86.d
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,12 @@ enum RMstore = (1 << 31);
extern (C++) extern __gshared regm_t ALLREGS;
extern (C++) extern __gshared regm_t BYTEREGS;

static if (TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS)
{
// To support positional independent code,
// must be able to remove BX from available registers
enum ALLREGS_INIT = (mAX|mBX|mCX|mDX|mSI|mDI);
enum ALLREGS_INIT_PIC = (mAX|mCX|mDX|mSI|mDI);
enum BYTEREGS_INIT = (mAX|mBX|mCX|mDX);
enum BYTEREGS_INIT_PIC = (mAX|mCX|mDX);
}
else
{
enum ALLREGS_INIT = (mAX|mBX|mCX|mDX|mSI|mDI);
enum BYTEREGS_INIT = (mAX|mBX|mCX|mDX);
}


/* We use the same IDXREGS for the 386 as the 8088, because if
we used ALLREGS, it would interfere with mMSW
Expand Down
53 changes: 32 additions & 21 deletions src/dmd/backend/elfobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,6 @@ import dmd.backend.melf;

extern bool symbol_iscomdat2(Symbol* s) @system;

static if (TARGET_LINUX)
enum ELFOSABI = ELFOSABI_LINUX;
else static if (TARGET_FREEBSD)
enum ELFOSABI = ELFOSABI_FREEBSD;
else static if (TARGET_SOLARIS)
enum ELFOSABI = ELFOSABI_SYSV;
else static if (TARGET_OPENBSD)
enum ELFOSABI = ELFOSABI_OPENBSD;
else static if (TARGET_DRAGONFLYBSD)
enum ELFOSABI = ELFOSABI_SYSV;
else
static assert(0, "No ELF OS ABI defined. Please fix");

//#define DEBSYM 0x7E

private __gshared Outbuffer *fobjbuf;
Expand Down Expand Up @@ -1275,6 +1262,34 @@ debug
// Now that we have correct offset to section header table, e_shoff,
// go back and re-output the elf header
//
ubyte ELFOSABI;
switch (config.exe)
{
case EX_LINUX:
case EX_LINUX64:
ELFOSABI = ELFOSABI_LINUX;
break;

case EX_FREEBSD:
case EX_FREEBSD64:
ELFOSABI = ELFOSABI_FREEBSD;
break;

case EX_OPENBSD:
case EX_OPENBSD64:
ELFOSABI = ELFOSABI_OPENBSD;
break;

case EX_SOLARIS:
case EX_SOLARIS64:
case EX_DRAGONFLYBSD64:
ELFOSABI = ELFOSABI_SYSV;
break;

default:
assert(0);
}

fobjbuf.position(0, hdrsize);
if (I64)
{
Expand All @@ -1285,7 +1300,7 @@ debug
ELFCLASS64, // EI_CLASS
ELFDATA2LSB, // EI_DATA
EV_CURRENT, // EI_VERSION
ELFOSABI,0, // EI_OSABI,EI_ABIVERSION
0,0, // EI_OSABI,EI_ABIVERSION
0,0,0,0,0,0,0
],
ET_REL, // e_type
Expand All @@ -1302,6 +1317,7 @@ debug
0, // e_shnum
SHN_SECNAMES // e_shstrndx
};
h64.EHident[EI_OSABI] = ELFOSABI;
h64.e_shoff = e_shoff;
h64.e_shnum = e_shnum;
fobjbuf.write(&h64, hdrsize);
Expand All @@ -1315,7 +1331,7 @@ debug
ELFCLASS32, // EI_CLASS
ELFDATA2LSB, // EI_DATA
EV_CURRENT, // EI_VERSION
ELFOSABI,0, // EI_OSABI,EI_ABIVERSION
0,0, // EI_OSABI,EI_ABIVERSION
0,0,0,0,0,0,0
],
ET_REL, // e_type
Expand All @@ -1332,6 +1348,7 @@ debug
0, // e_shnum
SHN_SECNAMES // e_shstrndx
};
h32.EHident[EI_OSABI] = ELFOSABI;
h32.e_shoff = cast(uint)e_shoff;
h32.e_shnum = e_shnum;
fobjbuf.write(&h32, hdrsize);
Expand Down Expand Up @@ -2142,13 +2159,7 @@ else
break;
case mTYman_std:
{
static if (TARGET_LINUX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS)
bool cond = (tyfunc(s.ty()) && !variadic(s.Stype));
else
bool cond = (!(config.flags4 & CFG4oldstdmangle) &&
config.exe == EX_WIN32 && tyfunc(s.ty()) &&
!variadic(s.Stype));

if (cond)
{
char *pstr = unsstr(type_paramsize(s.Stype));
Expand Down
2 changes: 1 addition & 1 deletion src/dmd/backend/global.d
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ void dwarf_CFA_set_reg_offset(int reg, int offset);
void dwarf_CFA_offset(int reg, int offset);
void dwarf_CFA_args_size(size_t sz);

// TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS
// Posix
elem *exp_isconst();
elem *lnx_builtin_next_arg(elem *efunc,list_t arglist);
char *lnx_redirect_funcname(const(char)*);
Expand Down
8 changes: 0 additions & 8 deletions src/dmd/backend/ty.d
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,9 @@ enum
mTYxmmgpr = 0x00400000, // first slice in XMM register, the other in GPR
mTYgprxmm = 0x00800000, // first slice in GPR register, the other in XMM

// Used only by C/C++ compiler
//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS
mTYnoret = 0x01000000, // function has no return
mTYtransu = 0x01000000, // transparent union
//#else
mTYfar16 = 0x01000000,
//#endif
mTYstdcall = 0x02000000,
mTYfastcall = 0x04000000,
mTYinterrupt = 0x08000000,
Expand All @@ -207,11 +203,7 @@ enum
mTYsyscall = 0x40000000,
mTYjava = 0x80000000,

//#if TARGET_LINUX || TARGET_OSX || TARGET_FREEBSD || TARGET_OPENBSD || TARGET_DRAGONFLYBSD || TARGET_SOLARIS
// mTYTFF = 0xFE000000,
//#else
mTYTFF = 0xFF000000,
//#endif
}

pure
Expand Down

0 comments on commit 0339f54

Please sign in to comment.