From 3d36e434b84cf6ebd7341aaffe2b3b0b588a0262 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Sun, 9 Jul 2017 21:42:00 +0200 Subject: [PATCH] Issue 17375 - use -fPIC by default for Phobos on Posix This also fixes: Fix Issue 17107 - Running phobos unittests do not work with PIE --- posix.mak | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/posix.mak b/posix.mak index 122fe84bc39..d76db9354f8 100644 --- a/posix.mak +++ b/posix.mak @@ -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 @@ -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 @@ -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) @@ -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=