1#
2# Build targets for a Hexagon-based processor
3#
4
5# Hexagon Environment Checks ###################################################
6
7# Ensure that the user has specified a path to the Hexagon toolchain that they
8# wish to use.
9ifeq ($(HEXAGON_TOOLS_PREFIX),)
10$(error "You must supply a HEXAGON_TOOLS_PREFIX environment variable \
11         containing a path to the hexagon toolchain. Example: \
12         export HEXAGON_TOOLS_PREFIX=$$HOME/Qualcomm/HEXAGON_Tools/8.0.07")
13endif
14
15# Hexagon Tools ################################################################
16
17TARGET_AR = $(HEXAGON_TOOLS_PREFIX)/Tools/bin/hexagon-ar
18TARGET_CC = $(HEXAGON_TOOLS_PREFIX)/Tools/bin/hexagon-clang
19TARGET_LD = $(HEXAGON_TOOLS_PREFIX)/Tools/bin/hexagon-link
20
21# Hexagon Compiler Flags #######################################################
22
23# Add Hexagon compiler flags
24TARGET_CFLAGS += $(HEXAGON_CFLAGS)
25
26# Enable position independence.
27TARGET_CFLAGS += -fpic
28
29# Disable splitting double registers.
30TARGET_CFLAGS += -mllvm -disable-hsdr
31
32# This code is loaded into a dynamic module. Define this symbol in the event
33# that any Qualcomm code needs it.
34TARGET_CFLAGS += -D__V_DYNAMIC__
35
36# Hexagon Shared Object Linker Flags ###########################################
37
38TARGET_SO_LDFLAGS += -shared
39TARGET_SO_LDFLAGS += -call_shared
40TARGET_SO_LDFLAGS += -Bsymbolic
41TARGET_SO_LDFLAGS += --wrap=malloc
42TARGET_SO_LDFLAGS += --wrap=calloc
43TARGET_SO_LDFLAGS += --wrap=free
44TARGET_SO_LDFLAGS += --wrap=realloc
45TARGET_SO_LDFLAGS += --wrap=memalign
46TARGET_SO_LDFLAGS += --wrap=__stack_chk_fail
47
48HEXAGON_LIB_PATH = $(HEXAGON_TOOLS_PREFIX)/Tools/target/hexagon/lib
49TARGET_SO_EARLY_LIBS += $(HEXAGON_LIB_PATH)/$(HEXAGON_ARCH)/G0/pic/initS.o
50TARGET_SO_LATE_LIBS += $(HEXAGON_LIB_PATH)/$(HEXAGON_ARCH)/G0/pic/finiS.o
51
52# Supported Hexagon Architectures ##############################################
53
54HEXAGON_SUPPORTED_ARCHS = v60 v62
55
56# Environment Checks ###########################################################
57
58# Ensure that an architecture is chosen.
59ifeq ($(filter $(HEXAGON_ARCH), $(HEXAGON_SUPPORTED_ARCHS)),)
60$(error "The HEXAGON_ARCH variable must be set to a supported architecture \
61         ($(HEXAGON_SUPPORTED_ARCHS))")
62endif
63
64# Target Architecture ##########################################################
65
66# Set the Hexagon architecture.
67TARGET_CFLAGS += -m$(strip $(HEXAGON_ARCH))
68
69# Optimization Level ###########################################################
70
71TARGET_CFLAGS += -O$(OPT_LEVEL)
72
73# TODO: Consider disabling this when compiling for >-O0.
74TARGET_CFLAGS += -D_DEBUG
75
76# Variant Specific Sources #####################################################
77
78TARGET_VARIANT_SRCS += $(HEXAGON_SRCS)
79