Skip to content

Commit

Permalink
Second round of makefile/build.d consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
marler8997 committed Jul 24, 2019
1 parent 52c0570 commit 8f44a0b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 49 deletions.
44 changes: 29 additions & 15 deletions src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ alias opTabGen = memoize!(function() {
});

/// Returns: the dependencies that build the D backend
alias dBackend = memoize!(function () {
alias backendObj = memoize!(function () {
Dependency dependency = {
name: "dbackend",
target: env["G"].buildPath("dbackend").objName,
name: "backendObj",
target: env["G"].buildPath("backend").objName,
sources: sources.backend,
msg: "(DC) D_BACK_OBJS %-(%s, %)".format(sources.backend.map!(e => e.baseName).array),
deps: [opTabGen],
Expand All @@ -289,9 +289,9 @@ alias backend = memoize!(function() {
Dependency dependency = {
name: "backend",
msg: "(LIB) %s".format("BACKEND".libName),
sources: [ env["G"].buildPath("dbackend").objName ],
sources: [ env["G"].buildPath("backend").objName ],
target: env["G"].buildPath("backend").libName,
deps: [opTabGen, dBackend],
deps: [opTabGen, backendObj],
command: [env["HOST_DMD_RUN"], env["MODEL_FLAG"], "-lib", "-of$@", "$<"]
};
return new DependencyRef(dependency);
Expand Down Expand Up @@ -755,22 +755,36 @@ auto sourceFiles()
.map!(e => e.name)
.filter!(e => !lexerRootFiles.canFind(e.baseName.stripExtension))
.array,
backend:
dirEntries(env["C"], "*.d", SpanMode.shallow)
.map!(e => e.name)
.filter!(e => !e.baseName.among("dt.d", "obj.d", "optabgen.d"))
.array,
backendHeaders: [
// can't be built with -betterC
"dt",
"obj",
].map!(e => env["C"].buildPath(e ~ ".d")).array,
backend: ("
bcomplex.d evalu8.d divcoeff.d dvec.d go.d gsroa.d glocal.d gdag.d gother.d gflow.d
out.d
gloop.d compress.d cgelem.d cgcs.d ee.d cod4.d cod5.d nteh.d blockopt.d mem.d cg.d cgreg.d
dtype.d debugprint.d fp.d symbol.d elem.d dcode.d cgsched.d cg87.d cgxmm.d cgcod.d cod1.d cod2.d
cod3.d cv8.d dcgcv.d pdata.d util2.d var.d md5.d backconfig.d ph2.d drtlsym.d dwarfeh.d ptrntab.d
dvarstats.d dwarfdbginf.d cgen.d os.d goh.d barray.d cgcse.d elpicpie.d
".split
~ versionTernary!"OSX"(["machobj.d"], ["elfobj.d"])
~ versionTernary!"Windows"("cgobj.d filespec.d mscoffobj.d newman.d".split, ["aarray.d"])
).map!(e => env["C"].buildPath(e)).array,
backendHeaders: "
cc.d cdef.d cgcv.d code.d cv4.d dt.d el.d global.d
obj.d oper.d outbuf.d rtlsym.d code_x86.d iasm.d codebuilder.d
ty.d type.d exh.d mach.d mscoff.d dwarf.d dwarf2.d xmm.d
dlist.d melf.d varstats.di
".split.map!(e => env["C"].buildPath(e)).array,
};
sources.dmd = sources.frontend ~ sources.backendHeaders;

return sources;
}

/// Returns the first argument if the given version is true, otherwiser, returns the second argument.
auto versionTernary(string version_, T)(T trueCase, T falseCase)
{
mixin("version(" ~ version_ ~ ") { return trueCase; }");
return falseCase;
}

/**
Downloads a file from a given URL
Expand Down
4 changes: 2 additions & 2 deletions src/dmd/backend/cgobj.d
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,14 @@ int insidx(char *p,uint index)
mov ECX,p - [ESP] ;
}
else
asm
asm nothrow
{
naked ;
mov EAX,index - [ESP+4] ;
mov ECX,p - [ESP+4] ;
}

asm
asm nothrow
{
cmp EAX,0x7F ;
jae L1 ;
Expand Down
2 changes: 1 addition & 1 deletion src/dmd/backend/util2.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int binary(const(char)* p, const(char)* *table,int high)
version (X86asm)
{
alias len = high; // reuse parameter storage
asm
asm nothrow
{

// First find the length of the identifier.
Expand Down
35 changes: 4 additions & 31 deletions src/posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -338,21 +338,6 @@ GLUE_SRCS=$(addsuffix .d, $(addprefix $D/,irstate toctype glue gluelayer todt to

DMD_SRCS=$(FRONT_SRCS) $(GLUE_SRCS) $(BACK_HDRS)

BACK_DOBJS = bcomplex.o evalu8.o divcoeff.o dvec.o go.o gsroa.o glocal.o gdag.o gother.o gflow.o \
out.o \
gloop.o compress.o cgelem.o cgcs.o ee.o cod4.o cod5.o nteh.o blockopt.o mem.o cg.o cgreg.o \
dtype.o debugprint.o fp.o symbol.o elem.o dcode.o cgsched.o cg87.o cgxmm.o cgcod.o cod1.o cod2.o \
cod3.o cv8.o dcgcv.o pdata.o util2.o var.o md5.o backconfig.o ph2.o drtlsym.o dwarfeh.o ptrntab.o \
aarray.o dvarstats.o dwarfdbginf.o elfobj.o cgen.o os.o goh.o barray.o cgcse.o elpicpie.o

G_DOBJS = $(addprefix $G/, $(BACK_DOBJS))

ifeq (osx,$(OS))
BACK_DOBJS += machobj.o
else
# BACK_DOBJS += elfobj.o
endif

######## DMD glue layer and backend

GLUE_SRC = \
Expand Down Expand Up @@ -407,7 +392,7 @@ SRC_MAKE = posix.mak osmodel.mak

STRING_IMPORT_FILES = $G/VERSION $G/SYSCONFDIR.imp $(RES)/default_ddoc_theme.ddoc

DEPS = $(patsubst %.o,%.deps,$(DMD_OBJS) $(BACK_OBJS) $(BACK_DOBJS))
DEPS = $(patsubst %.o,%.deps,$(DMD_OBJS))

RUN_BUILD = $(GENERATED)/build HOST_DMD="$(HOST_DMD)" OS=$(OS) BUILD=$(BUILD) MODEL=$(MODEL) AUTO_BOOTSTRAP="$(AUTO_BOOTSTRAP)" --called-from-make

Expand Down Expand Up @@ -439,21 +424,13 @@ toolchain-info:
@echo '==== Toolchain Information ===='
@echo

$G/backend.a: $(G_DOBJS) $(SRC_MAKE)
$(AR) rcs $@ $(G_DOBJS)

$G/dmd_frontend: $(FRONT_SRCS) $D/gluelayer.d $(ROOT_SRCS) $G/lexer.a $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^) -version=NoBackend

ifdef ENABLE_LTO
$G/dmd: $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a $(G_DOBJS) $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
$G/dmd: $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a $G/backend.o $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^)
else
$G/dmd: $(DMD_SRCS) $(ROOT_SRCS) $G/backend.a $G/lexer.a $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH) $(LEXER_ROOT),$^)
endif

$G/dmd-unittest: $(DMD_SRCS) $(ROOT_SRCS) $(LEXER_SRCS) $(G_DOBJS) $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
$G/dmd-unittest: $(DMD_SRCS) $(ROOT_SRCS) $(LEXER_SRCS) $G/backend.o $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
$(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) $(DFLAGS) -g -unittest -main -version=NoMain $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^)

unittest: $G/dmd-unittest
Expand Down Expand Up @@ -546,10 +523,6 @@ FORCE: ;

-include $(DEPS)

$(G_DOBJS): $G/%.o: $C/%.d $(optabgen_files) posix.mak $(HOST_DMD_PATH)
@echo " (HOST_DMD_RUN) BACK_DOBJS $<"
$(HOST_DMD_RUN) -c -of$@ $(DFLAGS) $(MODEL_FLAG) $(BACK_BETTERC) $(BACK_DFLAGS) $<

################################################################################
# Generate the man pages
################################################################################
Expand Down Expand Up @@ -605,7 +578,7 @@ dscanner: $(DSCANNER_DIR)/dsc
$G/cxxfrontend.o: $G/%.o: tests/%.c $(SRC) $(ROOT_SRC) $(SRC_MAKE)
$(CXX) -c -o$@ $(CXXFLAGS) $(DMD_FLAGS) $(MMD) $<

$G/cxx-unittest: $G/cxxfrontend.o $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a $(G_DOBJS) $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
$G/cxx-unittest: $G/cxxfrontend.o $(DMD_SRCS) $(ROOT_SRCS) $G/lexer.a backend.o $(STRING_IMPORT_FILES) $(HOST_DMD_PATH)
CC=$(HOST_CXX) $(HOST_DMD_RUN) -of$@ $(MODEL_FLAG) -vtls -J$G -J$(RES) -L-lstdc++ $(DFLAGS) -version=NoMain $(filter-out $(STRING_IMPORT_FILES) $(HOST_DMD_PATH),$^)

cxx-unittest: $G/cxx-unittest
Expand Down

0 comments on commit 8f44a0b

Please sign in to comment.