From ba383d94197f8febe1bff33d60dce79ac23f9e5d Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Sat, 3 Mar 2018 15:10:16 +0100 Subject: [PATCH] Backport PIC logic from stable into dmd-cxx --- posix.mak | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/posix.mak b/posix.mak index 3ec4db77e7..5eed42ef24 100644 --- a/posix.mak +++ b/posix.mak @@ -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 @@ -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)