aboutsummaryrefslogtreecommitdiff
path: root/config/mh-darwin
blob: fb2bb5ad1d9ce70a58e80e7e700860fd065f330d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# The -mdynamic-no-pic ensures that the compiler executable is built without
# position-independent-code -- the usual default on Darwin. This speeds compiles
# by 8-20% (measurements made against GCC-11).
# However, we cannot add it unless the bootstrap compiler supports
# -mno-dynamic-no-pic to undo it, since libiberty, at least, needs this.

# We use Werror, since some versions of clang report unknown command line flags
# as a warning only.

# We only need to determine this for the host tool used to build stage1 (or a
# non-bootstrapped compiler), later stages will be built by GCC which supports
# the required flags.

BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC := $(shell \
  $(CC) -S -xc /dev/null -o /dev/null -Werror -mno-dynamic-no-pic 2>/dev/null \
  && echo true)

@if gcc-bootstrap
ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true)
STAGE1_CFLAGS += -mdynamic-no-pic
else
STAGE1_CFLAGS += -fPIC
endif
# Add -mdynamic-no-pic to later stages when we know it is built with GCC.
BOOT_CFLAGS += -mdynamic-no-pic
@endif gcc-bootstrap

@unless gcc-bootstrap
ifeq (${BOOTSTRAP_TOOL_CAN_USE_MDYNAMIC_NO_PIC},true)
# FIXME: we should also enable this for cross and non-bootstrap builds but
# that needs amendment to libcc1.
# CFLAGS += -mdynamic-no-pic
# CXXFLAGS += -mdynamic-no-pic
else
CFLAGS += -fPIC
CXXFLAGS += -fPIC
endif
@endunless gcc-bootstrap