1# The -mdynamic-no-pic ensures that the compiler executable is built without
2# position-independent-code -- the usual default on Darwin. This speeds compiles
3# by 8-20% (measurements made against GCC-11).
4# However, we cannot add it unless the bootstrap compiler supports
5# -mno-dynamic-no-pic to undo it, since libiberty, at least, needs this.
6
7#��We use Werror, since some versions of clang report unknown command line flags
8# as a warning only.
9
10# We only need to determine this for the host tool used to build stage1 (or a
11# non-bootstrapped compiler), later stages will be built by GCC which supports
12# the required flags.
13
14# We cannot use mdynamic-no-pic when building shared host resources.
15
16ifeq (${host_shared},no)
17BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC := $(shell \
18  $(CC) -S -xc /dev/null -o /dev/null -Werror -mno-dynamic-no-pic 2>/dev/null \
19  && echo true)
20else
21BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC := false
22endif
23
24@if gcc-bootstrap
25ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true)
26STAGE1_CFLAGS += -mdynamic-no-pic
27else
28STAGE1_CFLAGS += -fPIC
29endif
30ifeq (${host_shared},no)
31# Add -mdynamic-no-pic to later stages when we know it is built with GCC.
32BOOT_CFLAGS += -mdynamic-no-pic
33endif
34@endif gcc-bootstrap
35
36@unless gcc-bootstrap
37ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true)
38# FIXME: we should also enable this for cross and non-bootstrap builds but
39# that needs amendment to libcc1.
40# CFLAGS += -mdynamic-no-pic
41# CXXFLAGS += -mdynamic-no-pic
42else
43CFLAGS += -fPIC
44CXXFLAGS += -fPIC
45endif
46@endunless gcc-bootstrap
47