1# SPDX-License-Identifier: Apache-2.0
2
3# Enable debug support in mdb
4# Dwarf version 2 can be recognized by mdb
5# The default dwarf version in gdb is not recognized by mdb
6zephyr_cc_option(-g3 -gdwarf-2)
7
8# Without this (poorly named) option, compiler may generate undefined
9# references to abort().
10# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63691
11zephyr_cc_option(-fno-delete-null-pointer-checks)
12
13zephyr_cc_option_ifdef(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS -munaligned-access)
14
15if(NOT COMPILER STREQUAL arcmwdt)
16  if(CONFIG_THREAD_LOCAL_STORAGE)
17    # Instruct compiler to use proper register as cached thread pointer for thread local storage.
18    # For ARCv2 the default register is usually not specified - so we need to specify it
19    # For ARCv3 the register is fixed to r30, so we don't need to specify it
20    zephyr_compile_options_ifdef(CONFIG_ISA_ARCV2 -mtp-regno=26)
21  else()
22    # If thread local storage isn't used - we can safely schedule thread pointer register
23    zephyr_compile_options_ifdef(CONFIG_ISA_ARCV2 -mtp-regno=none)
24  endif()
25endif()
26
27add_subdirectory(core)
28
29if(COMPILER STREQUAL arcmwdt)
30  add_subdirectory(arcmwdt)
31
32  if(CONFIG_64BIT)
33    zephyr_compile_options(-Ml)
34    # Instruct MWDT assembler not to warn when we load only lower half (32bit) of symbol
35    # instead of full 64bit address in ASM code. It is valid as we don't support Zephyr
36    # linkage to high addresses for 64bit ARC platforms.
37    zephyr_compile_options(-Wa,-offwarn=168)
38  endif()
39endif()
40
41if(CONFIG_ISA_ARCV3 AND CONFIG_64BIT)
42  set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf64-littlearc64)
43elseif(CONFIG_ISA_ARCV3 AND NOT CONFIG_64BIT)
44  set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-littlearc64)
45else()
46  set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-littlearc)
47endif()
48