druntime: Merge win64.mak into posix.mak

This commit is contained in:
Martin Kinkelin 2023-12-08 22:18:13 +01:00 committed by Nicholas Wilson
parent e41c56d5c8
commit bc6628cab3
2 changed files with 61 additions and 55 deletions

View file

@ -57,9 +57,7 @@ clean:
rm -rf $(GENERATED) rm -rf $(GENERATED)
cd compiler/test && rm -rf test_results *.lst trace.log trace.def cd compiler/test && rm -rf test_results *.lst trace.log trace.def
$(RM) tags $(RM) tags
ifneq (windows,$(OS))
$(QUIET)$(MAKE) -C druntime -f posix.mak clean $(QUIET)$(MAKE) -C druntime -f posix.mak clean
endif
dmd: $(BUILD_EXE) dmd: $(BUILD_EXE)
$(BUILD_EXE) $@ $(BUILD_EXE) $@
@ -69,18 +67,10 @@ dmd-test: dmd druntime $(BUILD_EXE) $(RUN_EXE)
$(RUN_EXE) --environment $(RUN_EXE) --environment
druntime: dmd druntime: dmd
ifeq (windows,$(OS))
@echo "Building druntime via top-level Makefile on Windows will come soon"
else
$(QUIET)$(MAKE) -C druntime -f posix.mak $(QUIET)$(MAKE) -C druntime -f posix.mak
endif
druntime-test: dmd druntime-test: dmd
ifeq (windows,$(OS))
@echo "Testing druntime via top-level Makefile on Windows will come soon"
else
$(QUIET)$(MAKE) -C druntime -f posix.mak unittest $(QUIET)$(MAKE) -C druntime -f posix.mak unittest
endif
test: dmd-test druntime-test test: dmd-test druntime-test

View file

@ -11,12 +11,28 @@ TOOLS_DIR=../../tools
include $(DMD_DIR)/src/osmodel.mak include $(DMD_DIR)/src/osmodel.mak
ifeq (windows,$(OS))
DOTEXE:=.exe
DOTDLL:=.dll
DOTLIB:=.lib
DOTOBJ:=.obj
else
DOTEXE:=
DOTDLL:=$(if $(findstring $(OS),osx),.dylib,.so)
DOTLIB:=.a
DOTOBJ:=.o
endif
ifeq (osx,$(OS))
export MACOSX_DEPLOYMENT_TARGET=10.9
endif
# Default to a release built, override with BUILD=debug # Default to a release built, override with BUILD=debug
ifeq (,$(BUILD)) ifeq (,$(BUILD))
BUILD_WAS_SPECIFIED=0 BUILD_WAS_SPECIFIED=0
BUILD=release BUILD=release
else else
BUILD_WAS_SPECIFIED=1 BUILD_WAS_SPECIFIED=1
endif endif
ifneq ($(BUILD),release) ifneq ($(BUILD),release)
@ -25,7 +41,7 @@ ifneq ($(BUILD),release)
endif endif
endif endif
DMD=$(DMD_DIR)/../generated/$(OS)/$(BUILD)/$(MODEL)/dmd DMD=$(DMD_DIR)/../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE)
INSTALL_DIR=../../install INSTALL_DIR=../../install
# directory where the html files for the documentation are placed # directory where the html files for the documentation are placed
@ -36,22 +52,17 @@ OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov=ctfe,)
# default to PIC, use PIC=1/0 to en-/disable PIC. # default to PIC, use PIC=1/0 to en-/disable PIC.
# Note that shared libraries and C files are always compiled with PIC. # Note that shared libraries and C files are always compiled with PIC.
ifeq ($(PIC),) ifeq (windows,$(OS))
PIC:=1
endif
ifeq ($(PIC),1)
override PIC:=-fPIC
else
override PIC:= override PIC:=
endif
ifeq (osx,$(OS))
DOTDLL:=.dylib
DOTLIB:=.a
export MACOSX_DEPLOYMENT_TARGET=10.9
else else
DOTDLL:=.so ifeq ($(PIC),)
DOTLIB:=.a PIC:=1
endif
ifeq ($(PIC),1)
override PIC:=-fPIC
else
override PIC:=
endif
endif endif
# build with shared library support # build with shared library support
@ -65,7 +76,7 @@ MAKEFILE = $(firstword $(MAKEFILE_LIST))
DDOCFLAGS=-conf= -c -w -o- -Iimport -version=CoreDdoc DDOCFLAGS=-conf= -c -w -o- -Iimport -version=CoreDdoc
# Set CFLAGS # Set CFLAGS
CFLAGS=$(MODEL_FLAG) -fPIC -DHAVE_UNISTD_H CFLAGS=$(if $(findstring $(OS),windows),,$(MODEL_FLAG) -fPIC -DHAVE_UNISTD_H)
ifeq ($(BUILD),debug) ifeq ($(BUILD),debug)
CFLAGS += -g CFLAGS += -g
else else
@ -98,17 +109,16 @@ SHARED=$(if $(findstring $(OS),linux freebsd),1,)
ROOT_DIR := $(shell pwd) ROOT_DIR := $(shell pwd)
PHOBOS_DFLAGS=-conf= $(MODEL_FLAG) -I$(ROOT_DIR)/import -I$(PHOBOS_PATH) -L-L$(PHOBOS_PATH)/generated/$(OS)/$(BUILD)/$(MODEL) $(PIC) PHOBOS_DFLAGS=-conf= $(MODEL_FLAG) -I$(ROOT_DIR)/import -I$(PHOBOS_PATH) -L-L$(PHOBOS_PATH)/generated/$(OS)/$(BUILD)/$(MODEL) $(PIC)
ifeq (1,$(SHARED)) ifeq (1,$(SHARED))
PHOBOS_DFLAGS+=-defaultlib=libphobos2.so -L-rpath=$(PHOBOS_PATH)/generated/$(OS)/$(BUILD)/$(MODEL) PHOBOS_DFLAGS+=-defaultlib=libphobos2$(DOTDLL) -L-rpath=$(PHOBOS_PATH)/generated/$(OS)/$(BUILD)/$(MODEL)
endif endif
ROOT_OF_THEM_ALL = ../generated ROOT_OF_THEM_ALL = ../generated
ROOT = $(ROOT_OF_THEM_ALL)/$(OS)/$(BUILD)/$(MODEL) ROOT = $(ROOT_OF_THEM_ALL)/$(OS)/$(BUILD)/$(MODEL)
OBJDIR=obj/$(OS)/$(BUILD)/$(MODEL) OBJDIR=obj/$(OS)/$(BUILD)/$(MODEL)
DRUNTIME_BASE=druntime-$(OS)$(MODEL) DRUNTIME=$(ROOT)/$(if $(findstring $(OS),windows),,lib)druntime$(DOTLIB)
DRUNTIME=$(ROOT)/libdruntime.a DRUNTIMESO=$(ROOT)/$(if $(findstring $(OS),windows),,lib)druntime$(DOTDLL)
DRUNTIMESO=$(ROOT)/libdruntime.so DRUNTIMESOOBJ=$(DRUNTIMESO)$(DOTOBJ)
DRUNTIMESOOBJ=$(ROOT)/libdruntime.so.o DRUNTIMESOLIB=$(DRUNTIMESO)$(DOTLIB)
DRUNTIMESOLIB=$(ROOT)/libdruntime.so.a
STDDOC= STDDOC=
@ -123,10 +133,6 @@ SRCS:=$(subst \,/,$(SRCS))
# NOTE: trace.d and cover.d are not necessary for a successful build # NOTE: trace.d and cover.d are not necessary for a successful build
# as both are used for debugging features (profiling and coverage) # as both are used for debugging features (profiling and coverage)
# NOTE: a pre-compiled minit.obj has been provided in dmd for Win32 and
# minit.asm is not used by dmd for Linux
OBJS= $(ROOT)/errno_c.o $(ROOT)/threadasm.o $(ROOT)/valgrind.o
# use timelimit to avoid deadlocks if available # use timelimit to avoid deadlocks if available
TIMELIMIT:=$(if $(shell which timelimit 2>/dev/null || true),timelimit -t 10 ,) TIMELIMIT:=$(if $(shell which timelimit 2>/dev/null || true),timelimit -t 10 ,)
@ -352,7 +358,7 @@ $(IMPDIR)/%.h : src/%.h
######################## Build DMD if non-existent ############################## ######################## Build DMD if non-existent ##############################
$(DMD_DIR)/../generated/$(OS)/$(BUILD)/$(MODEL)/dmd: $(DMD_DIR)/../generated/$(OS)/$(BUILD)/$(MODEL)/dmd$(DOTEXE):
$(MAKE) -C $(DMD_DIR)/.. dmd BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL) DMD="" $(MAKE) -C $(DMD_DIR)/.. dmd BUILD=$(BUILD) OS=$(OS) MODEL=$(MODEL) DMD=""
# alias using the absolute path (the Phobos Makefile specifies an absolute path) # alias using the absolute path (the Phobos Makefile specifies an absolute path)
@ -360,32 +366,41 @@ $(abspath $(DMD_DIR)/../generated/$(OS)/$(BUILD)/$(MODEL)/dmd): $(DMD_DIR)/../ge
################### C/ASM Targets ############################ ################### C/ASM Targets ############################
$(ROOT)/%.o : src/rt/%.c $(DMD) # Although dmd is compiling the .c files, the preprocessor used on Windows is cl.exe.
# The INCLUDE environment variable needs to be set with the path to the VC system include files.
# NOTE: minit.asm is only used for -m32omf on Windows
OBJS:=$(ROOT)/errno_c$(DOTOBJ)
ifneq (windows,$(OS))
OBJS+=$(ROOT)/threadasm$(DOTOBJ) $(ROOT)/valgrind$(DOTOBJ)
endif
$(ROOT)/%$(DOTOBJ) : src/rt/%.c $(DMD)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(DMD) -c $(DFLAGS) -I. $< -of$@ $(DMD) -c $(DFLAGS) -I. $< -of$@
$(ROOT)/errno_c.o : src/core/stdc/errno.c $(DMD) $(ROOT)/errno_c$(DOTOBJ) : src/core/stdc/errno.c $(DMD)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(DMD) -c $(DFLAGS) -I. $< -of$@ $(DMD) -c $(DFLAGS) -I. -P=-I. $< -of$@
$(ROOT)/threadasm.o : src/core/threadasm.S $(ROOT)/threadasm$(DOTOBJ) : src/core/threadasm.S
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $< -o$@ $(CC) -c $(CFLAGS) $< -o$@
$(ROOT)/valgrind.o : src/etc/valgrind/valgrind.c src/etc/valgrind/valgrind.h src/etc/valgrind/memcheck.h $(ROOT)/valgrind$(DOTOBJ) : src/etc/valgrind/valgrind.c src/etc/valgrind/valgrind.h src/etc/valgrind/memcheck.h
@mkdir -p `dirname $@` @mkdir -p `dirname $@`
$(CC) -c $(CFLAGS) $< -o$@ $(CC) -c $(CFLAGS) $< -o$@
######################## Create a shared library ############################## ######################## Create a shared library ##############################
$(DRUNTIMESO) $(DRUNTIMESOLIB) dll: DFLAGS+=-version=Shared -fPIC $(DRUNTIMESO) $(DRUNTIMESOLIB) dll: DFLAGS+=-version=Shared $(if $(findstring $(OS),windows),,-fPIC)
dll: $(DRUNTIMESOLIB) dll: $(DRUNTIMESOLIB)
$(DRUNTIMESO): $(OBJS) $(SRCS) $(DMD) $(DRUNTIMESO): $(OBJS) $(SRCS) $(DMD)
$(DMD) -shared -debuglib= -defaultlib= -of$(DRUNTIMESO) $(DFLAGS) $(SRCS) $(OBJS) $(LINKDL) -L-lpthread -L-lm $(DMD) -shared -debuglib= -defaultlib= -of$(DRUNTIMESO) $(DFLAGS) $(SRCS) $(OBJS) $(LINKDL) -L-lpthread -L-lm
$(DRUNTIMESOLIB): $(OBJS) $(SRCS) $(DMD) $(DRUNTIMESOLIB): $(OBJS) $(SRCS) $(DMD)
$(DMD) -c -fPIC -of$(DRUNTIMESOOBJ) $(DFLAGS) $(SRCS) $(DMD) -c $(if $(findstring $(OS),windows),,-fPIC) -of$(DRUNTIMESOOBJ) $(DFLAGS) $(SRCS)
$(DMD) -conf= -lib -of$(DRUNTIMESOLIB) $(DRUNTIMESOOBJ) $(OBJS) $(DMD) -conf= -lib -of$(DRUNTIMESOLIB) $(DRUNTIMESOOBJ) $(OBJS)
################### Library generation ######################### ################### Library generation #########################
@ -396,7 +411,8 @@ $(DRUNTIME): $(OBJS) $(SRCS) $(DMD)
lib: $(DRUNTIME) lib: $(DRUNTIME)
UT_MODULES:=$(patsubst src/%.d,$(ROOT)/unittest/%,$(SRCS)) UT_MODULES:=$(patsubst src/%.d,$(ROOT)/unittest/%,$(SRCS))
HAS_ADDITIONAL_TESTS:=$(shell test -d test && echo 1) # TODO: Windows
HAS_ADDITIONAL_TESTS:=$(if $(findstring $(OS),windows),,$(shell test -d test && echo 1))
ifeq ($(HAS_ADDITIONAL_TESTS),1) ifeq ($(HAS_ADDITIONAL_TESTS),1)
ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage test/profile test/cycles test/allocations test/typeinfo \ ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage test/profile test/cycles test/allocations test/typeinfo \
test/aa test/cpuid test/gc test/hash test/lifetime \ test/aa test/cpuid test/gc test/hash test/lifetime \
@ -428,19 +444,19 @@ $(addprefix $(ROOT)/unittest/,$(DISABLED_TESTS)) :
ifeq (,$(SHARED)) ifeq (,$(SHARED))
$(ROOT)/unittest/test_runner: $(OBJS) $(SRCS) src/test_runner.d $(DMD) $(ROOT)/unittest/test_runner$(DOTEXE): $(OBJS) $(SRCS) src/test_runner.d $(DMD)
$(DMD) $(UDFLAGS) $(UTFLAGS) -of$@ src/test_runner.d $(SRCS) $(OBJS) -debuglib= -defaultlib= -L-lpthread -L-lm $(DMD) $(UDFLAGS) $(UTFLAGS) -of$@ src/test_runner.d $(SRCS) $(OBJS) -defaultlib= $(if $(findstring $(OS),windows),user32.lib,-L-lpthread -L-lm)
else else
UT_DRUNTIME:=$(ROOT)/unittest/libdruntime-ut$(DOTDLL) UT_DRUNTIME:=$(ROOT)/unittest/libdruntime-ut$(DOTDLL)
$(UT_DRUNTIME): UDFLAGS+=-version=Shared -fPIC $(UT_DRUNTIME): UDFLAGS+=-version=Shared $(if $(findstring $(OS),windows),,-fPIC)
$(UT_DRUNTIME): $(OBJS) $(SRCS) $(DMD) $(UT_DRUNTIME): $(OBJS) $(SRCS) $(DMD)
$(DMD) $(UDFLAGS) -shared $(UTFLAGS) -of$@ $(SRCS) $(OBJS) $(LINKDL) -debuglib= -defaultlib= -L-lpthread -L-lm $(DMD) $(UDFLAGS) -shared $(UTFLAGS) -of$@ $(SRCS) $(OBJS) $(LINKDL) -defaultlib= $(if $(findstring $(OS),windows),user32.lib,-L-lpthread -L-lm)
$(ROOT)/unittest/test_runner: $(UT_DRUNTIME) src/test_runner.d $(DMD) $(ROOT)/unittest/test_runner$(DOTEXE): $(UT_DRUNTIME) src/test_runner.d $(DMD)
$(DMD) $(UDFLAGS) -of$@ src/test_runner.d -L$(UT_DRUNTIME) -debuglib= -defaultlib= -L-lpthread -L-lm $(DMD) $(UDFLAGS) -of$@ src/test_runner.d -L$(UT_DRUNTIME) -defaultlib= $(if $(findstring $(OS),windows),user32.lib,-L-lpthread -L-lm)
endif endif
@ -450,7 +466,7 @@ BETTERCTESTS_DIR=$(ROOT)/betterctests
# macro that returns the module name given the src path # macro that returns the module name given the src path
moduleName=$(subst rt.invariant,invariant,$(subst object_,object,$(subst /,.,$(1)))) moduleName=$(subst rt.invariant,invariant,$(subst object_,object,$(subst /,.,$(1))))
$(ROOT)/unittest/% : $(ROOT)/unittest/test_runner $(ROOT)/unittest/% : $(ROOT)/unittest/test_runner$(DOTEXE)
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
# make the file very old so it builds and runs again if it fails # make the file very old so it builds and runs again if it fails
@touch -t 197001230123 $@ @touch -t 197001230123 $@