Skip to content

Commit

Permalink
Issue 17375 - use -fPIC by default for Phobos on Posix
Browse files Browse the repository at this point in the history
This also fixes:

Fix Issue 17107 - Running phobos unittests do not work with PIE
  • Loading branch information
wilzbach committed Sep 14, 2017
1 parent fc46850 commit 3d36e43
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions posix.mak
Expand Up @@ -54,7 +54,12 @@ ifneq ($(BUILD),release)
endif
endif

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

# Configurable stuff that's rarely edited
INSTALL_DIR = ../install
Expand Down Expand Up @@ -115,7 +120,7 @@ else
endif

# Set DFLAGS
DFLAGS=-conf= -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) -w -de -dip25 $(MODEL_FLAG) $(PIC)
DFLAGS=-conf= -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) -w -de -dip25 $(MODEL_FLAG) $(PIC_FLAG)
ifeq ($(BUILD),debug)
DFLAGS += -g -debug
else
Expand Down Expand Up @@ -316,7 +321,6 @@ $(ROOT)/libphobos2.so: $(ROOT)/$(SONAME)
$(ROOT)/$(SONAME): $(LIBSO)
ln -sf $(notdir $(LIBSO)) $@

$(LIBSO): override PIC:=-fPIC
$(LIBSO): $(OBJS) $(ALL_D_FILES) $(DRUNTIMESO)
$(DMD) $(DFLAGS) -shared -debuglib= -defaultlib= -of$@ -L-soname=$(SONAME) $(DRUNTIMESO) $(LINKDL) $(D_FILES) $(OBJS)

Expand Down Expand Up @@ -358,7 +362,6 @@ UT_LIBSO:=$(ROOT)/unittest/libphobos2-ut.so

$(UT_D_OBJS): $(DRUNTIMESO)

$(UT_LIBSO): override PIC:=-fPIC
$(UT_LIBSO): $(UT_D_OBJS) $(OBJS) $(DRUNTIMESO)
$(DMD) $(DFLAGS) -shared -unittest -of$@ $(UT_D_OBJS) $(OBJS) $(DRUNTIMESO) $(LINKDL) -defaultlib= -debuglib=

Expand Down

0 comments on commit 3d36e43

Please sign in to comment.