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

Commit 84ac676

Browse files
committed
fix Issue 17966 - don't build libphobos2.a with PIC for i386
- use MODEL=64/32 to decide on default - allow overriding default with explicit PIC=0/1 make args
1 parent 938e674 commit 84ac676

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

posix.mak

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

32-
OPTIONAL_PIC:=$(if $(PIC),-fPIC,)
3332
OPTIONAL_COVERAGE:=$(if $(TEST_COVERAGE),-cov,)
3433

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
45+
else
46+
override PIC:=
47+
endif
48+
3549
ifeq (osx,$(OS))
3650
DOTDLL:=.dylib
3751
DOTLIB:=.a
@@ -55,7 +69,7 @@ ifeq (solaris,$(OS))
5569
endif
5670

5771
# Set DFLAGS
58-
UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(OPTIONAL_PIC) $(OPTIONAL_COVERAGE)
72+
UDFLAGS:=-conf= -Isrc -Iimport -w -dip1000 $(MODEL_FLAG) $(PIC) $(OPTIONAL_COVERAGE)
5973
ifeq ($(BUILD),debug)
6074
UDFLAGS += -g -debug
6175
DFLAGS:=$(UDFLAGS)

test/common.mak

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

17-
OPTIONAL_PIC:=$(if $(PIC),-fPIC,)
18-
1917
ifneq (default,$(MODEL))
2018
MODEL_FLAG:=-m$(MODEL)
2119
endif
22-
CFLAGS:=$(MODEL_FLAG) -Wall
23-
DFLAGS:=$(MODEL_FLAG) -w -I../../src -I../../import -I$(SRC) -defaultlib= -debuglib= -dip1000 $(OPTIONAL_PIC)
20+
CFLAGS:=$(MODEL_FLAG) $(PIC) -Wall
21+
DFLAGS:=$(MODEL_FLAG) $(PIC) -w -I../../src -I../../import -I$(SRC) -defaultlib= -debuglib= -dip1000
2422
# LINK_SHARED may be set by importing makefile
2523
DFLAGS+=$(if $(LINK_SHARED),-L$(DRUNTIMESO),-L$(DRUNTIME))
2624
ifeq ($(BUILD),debug)

0 commit comments

Comments
 (0)