Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive
Merged
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
23 changes: 16 additions & 7 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,22 @@ INSTALL_DIR=../install
DOCDIR=doc
IMPDIR=import

# -fPIC is enabled by default and can be disabled with DISABLE_PIC=1
ifeq (,$(DISABLE_PIC))
PIC_FLAG:=-fPIC
OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov,)

# default to PIC on x86_64, use PIC=1/0 to en-/disable PIC.
# Note that shared libraries and C files are always compiled with PIC.
ifeq ($(PIC),)
ifeq ($(MODEL),64) # x86_64
PIC:=1
else
PIC:=0
endif
endif
ifeq ($(PIC),1)
override PIC:=-fPIC
else
PIC_FLAG:=
override PIC:=
endif
OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov,)

ifeq (osx,$(OS))
DOTDLL:=.dylib
Expand All @@ -60,7 +69,7 @@ ifeq (solaris,$(OS))
endif

# Set DFLAGS
UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(PIC_FLAG) $(OPTIONAL_COVERAGE)
UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(PIC) $(OPTIONAL_COVERAGE)
ifeq ($(BUILD),debug)
UDFLAGS += -g -debug
DFLAGS:=$(UDFLAGS)
Expand Down Expand Up @@ -186,7 +195,7 @@ $(ROOT)/threadasm.o : src/core/threadasm.S

######################## Create a shared library ##############################

$(DRUNTIMESO) $(DRUNTIMESOLIB) dll: DFLAGS+=-version=Shared
$(DRUNTIMESO) $(DRUNTIMESOLIB) dll: DFLAGS+=-version=Shared -fPIC
dll: $(DRUNTIMESOLIB)

$(DRUNTIMESO): $(OBJS) $(SRCS)
Expand Down
11 changes: 2 additions & 9 deletions test/common.mak
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,11 @@ SRC:=src
GENERATED:=./generated
ROOT:=$(GENERATED)/$(OS)/$(BUILD)/$(MODEL)

# -fPIC is enabled by default and can be disabled with DISABLE_PIC=1
ifeq (,$(DISABLE_PIC))
PIC_FLAG:=-fPIC
else
PIC_FLAG:=
endif

ifneq (default,$(MODEL))
MODEL_FLAG:=-m$(MODEL)
endif
CFLAGS:=$(MODEL_FLAG) -Wall
DFLAGS:=$(MODEL_FLAG) -w -I../../src -I../../import -I$(SRC) -defaultlib= -debuglib= -dip1000 $(PIC_FLAG)
CFLAGS:=$(MODEL_FLAG) $(PIC) -Wall
DFLAGS:=$(MODEL_FLAG) $(PIC) -w -I../../src -I../../import -I$(SRC) -defaultlib= -debuglib= -dip1000
# LINK_SHARED may be set by importing makefile
DFLAGS+=$(if $(LINK_SHARED),-L$(DRUNTIMESO),-L$(DRUNTIME))
ifeq ($(BUILD),debug)
Expand Down