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 15ifeq ($(IS_NANOAPP_BUILD),) 16ifeq ($(SLPI_PREFIX),) 17$(error "You must supply an SLPI_PREFIX environment variable \ 18 containing a path to the SLPI source tree. Example: \ 19 export SLPI_PREFIX=$$HOME/slpi_proc") 20endif 21endif 22 23# Hexagon Tools ################################################################ 24 25TARGET_AR = $(HEXAGON_TOOLS_PREFIX)/Tools/bin/hexagon-ar 26TARGET_CC = $(HEXAGON_TOOLS_PREFIX)/Tools/bin/hexagon-clang 27TARGET_LD = $(HEXAGON_TOOLS_PREFIX)/Tools/bin/hexagon-link 28 29# Hexagon Compiler Flags ####################################################### 30 31# Define CUST_H to allow including the customer header file. 32TARGET_CFLAGS += -DCUST_H='"custaaaaaaaaq.h"' 33 34# Add Hexagon compiler flags 35TARGET_CFLAGS += $(HEXAGON_CFLAGS) 36 37# Enable position independence. 38TARGET_CFLAGS += -fpic 39 40# Disable splitting double registers. 41TARGET_CFLAGS += -mllvm -disable-hsdr 42 43# Don't use small data section. 44TARGET_CFLAGS += -G0 45 46# Enable default visibility for FastRPC entry points. 47TARGET_CFLAGS += -D'__QAIC_SKEL_EXPORT=__attribute__((visibility("default")))' 48 49# This code is loaded into a dynamic module. Define this symbol in the event 50# that any Qualcomm code needs it. 51TARGET_CFLAGS += -D__V_DYNAMIC__ 52 53# This flag is used by some QC-supplied code to differentiate things intended to 54# run on Hexagon vs. other architectures 55TARGET_CFLAGS += -DQDSP6 56 57# Declare support for std headers that the QC SDK contains so that libs like 58# pigweed don't try to redefine functionality. 59TARGET_CFLAGS += -D__cpp_lib_byte=201603L 60TARGET_CFLAGS += -D__cpp_lib_integer_sequence=201304L 61TARGET_CFLAGS += -D__cpp_lib_is_null_pointer=201309L 62TARGET_CFLAGS += -D__cpp_lib_logical_traits=201510L 63TARGET_CFLAGS += -D__cpp_lib_nonmember_container_access=201411L 64TARGET_CFLAGS += -D__cpp_lib_transformation_trait_aliases=201304L 65 66# Hexagon Shared Object Linker Flags ########################################### 67 68TARGET_SO_LDFLAGS += --gc-sections 69TARGET_SO_LDFLAGS += -shared 70TARGET_SO_LDFLAGS += -call_shared 71TARGET_SO_LDFLAGS += -Bsymbolic 72TARGET_SO_LDFLAGS += --wrap=malloc 73TARGET_SO_LDFLAGS += --wrap=calloc 74TARGET_SO_LDFLAGS += --wrap=free 75TARGET_SO_LDFLAGS += --wrap=realloc 76TARGET_SO_LDFLAGS += --wrap=memalign 77TARGET_SO_LDFLAGS += --wrap=__stack_chk_fail 78TARGET_SO_LDFLAGS += --no-threads 79 80HEXAGON_LIB_PATH = $(HEXAGON_TOOLS_PREFIX)/Tools/target/hexagon/lib 81TARGET_SO_EARLY_LIBS += $(HEXAGON_LIB_PATH)/$(HEXAGON_ARCH)/G0/pic/initS.o 82TARGET_SO_LATE_LIBS += $(HEXAGON_LIB_PATH)/$(HEXAGON_ARCH)/G0/pic/finiS.o 83TARGET_SO_LATE_LIBS += $(LDLIBS) 84 85# Supported Hexagon Architectures ############################################## 86 87HEXAGON_SUPPORTED_ARCHS = v55 v60 v62 v65 v66 88 89# Environment Checks ########################################################### 90 91# Ensure that an architecture is chosen. 92ifeq ($(filter $(HEXAGON_ARCH), $(HEXAGON_SUPPORTED_ARCHS)),) 93$(error "The HEXAGON_ARCH variable must be set to a supported architecture \ 94 ($(HEXAGON_SUPPORTED_ARCHS))") 95endif 96 97# Target Architecture ########################################################## 98 99# Set the Hexagon architecture. 100TARGET_CFLAGS += -m$(strip $(HEXAGON_ARCH)) 101 102# Optimization Level ########################################################### 103 104TARGET_CFLAGS += -O$(OPT_LEVEL) 105 106# TODO: Consider disabling this when compiling for >-O0. 107TARGET_CFLAGS += -D_DEBUG 108 109# Variant Specific Sources ##################################################### 110 111TARGET_VARIANT_SRCS += $(HEXAGON_SRCS) 112