Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 7c8ca6a

Browse files
authored
Merge pull request #1974 from MartinNowak/fix17996
fix Issue 17966 - don't build libphobos2.a with PIC for i386 merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
2 parents 9fee0ca + 84ac676 commit 7c8ca6a

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

posix.mak

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,22 @@ INSTALL_DIR=../install
2929
DOCDIR=doc
3030
IMPDIR=import
3131

32-
# -fPIC is enabled by default and can be disabled with DISABLE_PIC=1
33-
ifeq (,$(DISABLE_PIC))
34-
PIC_FLAG:=-fPIC
32+
OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov,)
33+
34+
# default to PIC on x86_64, use PIC=1/0 to en-/disable PIC.
35+
# Note that shared libraries and C files are always compiled with PIC.
36+
ifeq ($(PIC),)
37+
ifeq ($(MODEL),64) # x86_64
38+
PIC:=1
39+
else
40+
PIC:=0
41+
endif
42+
endif
43+
ifeq ($(PIC),1)
44+
override PIC:=-fPIC
3545
else
36-
PIC_FLAG:=
46+
override PIC:=
3747
endif
38-
OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov,)
3948

4049
ifeq (osx,$(OS))
4150
DOTDLL:=.dylib
@@ -60,7 +69,7 @@ ifeq (solaris,$(OS))
6069
endif
6170

6271
# Set DFLAGS
63-
UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(PIC_FLAG) $(OPTIONAL_COVERAGE)
72+
UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(PIC) $(OPTIONAL_COVERAGE)
6473
ifeq ($(BUILD),debug)
6574
UDFLAGS += -g -debug
6675
DFLAGS:=$(UDFLAGS)
@@ -186,7 +195,7 @@ $(ROOT)/threadasm.o : src/core/threadasm.S
186195

187196
######################## Create a shared library ##############################
188197

189-
$(DRUNTIMESO) $(DRUNTIMESOLIB) dll: DFLAGS+=-version=Shared
198+
$(DRUNTIMESO) $(DRUNTIMESOLIB) dll: DFLAGS+=-version=Shared -fPIC
190199
dll: $(DRUNTIMESOLIB)
191200

192201
$(DRUNTIMESO): $(OBJS) $(SRCS)

test/common.mak

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,11 @@ SRC:=src
1414
GENERATED:=./generated
1515
ROOT:=$(GENERATED)/$(OS)/$(BUILD)/$(MODEL)
1616

17-
# -fPIC is enabled by default and can be disabled with DISABLE_PIC=1
18-
ifeq (,$(DISABLE_PIC))
19-
PIC_FLAG:=-fPIC
20-
else
21-
PIC_FLAG:=
22-
endif
23-
2417
ifneq (default,$(MODEL))
2518
MODEL_FLAG:=-m$(MODEL)
2619
endif
27-
CFLAGS:=$(MODEL_FLAG) -Wall
28-
DFLAGS:=$(MODEL_FLAG) -w -I../../src -I../../import -I$(SRC) -defaultlib= -debuglib= -dip1000 $(PIC_FLAG)
20+
CFLAGS:=$(MODEL_FLAG) $(PIC) -Wall
21+
DFLAGS:=$(MODEL_FLAG) $(PIC) -w -I../../src -I../../import -I$(SRC) -defaultlib= -debuglib= -dip1000
2922
# LINK_SHARED may be set by importing makefile
3023
DFLAGS+=$(if $(LINK_SHARED),-L$(DRUNTIMESO),-L$(DRUNTIME))
3124
ifeq ($(BUILD),debug)

0 commit comments

Comments
 (0)