1# Copyright (c) 2019 Intel Corp. 2# SPDX-License-Identifier: Apache-2.0 3 4# Find out if we are optimizing for size 5get_target_property(zephyr_COMPILE_OPTIONS zephyr_interface INTERFACE_COMPILE_OPTIONS) 6#Any -Os is (or may be) wraped in $<COMPILE_LANGUAGE> guards 7list(FILTER zephyr_COMPILE_OPTIONS INCLUDE REGEX "-Os") 8list(LENGTH zephyr_COMPILE_OPTIONS have_os) 9if (${have_os} GREATER 0) 10 zephyr_cc_option(-mpreferred-stack-boundary=2) 11else() 12 zephyr_compile_definitions(PERF_OPT) 13endif() 14 15set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH "i386") 16set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT "elf32-i386") 17 18if(CMAKE_C_COMPILER_ID STREQUAL "Clang" 19 OR CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM") 20 zephyr_compile_options(-Qunused-arguments) 21 22 zephyr_cc_option( 23 -m32 24 -gdwarf-2 25 ) 26endif() 27 28if(CONFIG_X86_MMX) 29 zephyr_cc_option(-mmmx) 30else() 31 zephyr_cc_option(-mno-mmx) 32endif() 33 34if(CONFIG_X86_SSE) 35 zephyr_cc_option(-msse) 36 37 if(CONFIG_X86_SSE_FP_MATH) 38 zephyr_cc_option(-mfpmath=sse) 39 else() 40 zephyr_cc_option(-mfpmath=387) 41 endif() 42 43 if(CONFIG_X86_SSE2) 44 zephyr_cc_option(-msse2) 45 else() 46 zephyr_cc_option(-mno-sse2) 47 endif() 48 49 if(CONFIG_X86_SSE3) 50 zephyr_cc_option(-msse3) 51 else() 52 zephyr_cc_option(-mno-sse3) 53 endif() 54 55 if(CONFIG_X86_SSSE3) 56 zephyr_cc_option(-mssse3) 57 else() 58 zephyr_cc_option(-mno-ssse3) 59 endif() 60 61 if(CONFIG_X86_SSE41) 62 zephyr_cc_option(-msse4.1) 63 else() 64 zephyr_cc_option(-mno-sse4.1) 65 endif() 66 67 if(CONFIG_X86_SSE42) 68 zephyr_cc_option(-msse4.2) 69 else() 70 zephyr_cc_option(-mno-sse4.2) 71 endif() 72 73 if(CONFIG_X86_SSE4A) 74 zephyr_cc_option(-msse4a) 75 else() 76 zephyr_cc_option(-mno-sse4a) 77 endif() 78 79else() 80 zephyr_cc_option(-mno-sse) 81endif() 82 83if(CMAKE_VERBOSE_MAKEFILE) 84 set(GENIDT_EXTRA_ARGS --verbose) 85else() 86 set(GENIDT_EXTRA_ARGS "") 87endif() 88 89set(GENIDT ${ZEPHYR_BASE}/arch/x86/gen_idt.py) 90 91define_property(GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH BRIEF_DOCS " " FULL_DOCS " ") 92 93# Use gen_idt.py and objcopy to generate irq_int_vector_map.o, 94# irq_vectors_alloc.o, and staticIdt.o from the elf file ${ZEPHYR_PREBUILT_EXECUTABLE} 95set(gen_idt_output_files 96 ${CMAKE_CURRENT_BINARY_DIR}/irq_int_vector_map.bin 97 ${CMAKE_CURRENT_BINARY_DIR}/staticIdt.bin 98 ${CMAKE_CURRENT_BINARY_DIR}/irq_vectors_alloc.bin 99 ) 100add_custom_target( 101 gen_idt_output 102 DEPENDS 103 ${gen_idt_output_files} 104 ) 105add_custom_command( 106 OUTPUT irq_int_vector_map.bin staticIdt.bin irq_vectors_alloc.bin 107 COMMAND 108 ${PYTHON_EXECUTABLE} 109 ${GENIDT} 110 --kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}> 111 --output-idt staticIdt.bin 112 --vector-map irq_int_vector_map.bin 113 --output-vectors-alloc irq_vectors_alloc.bin 114 ${GENIDT_EXTRA_ARGS} 115 DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE} 116 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 117 ) 118 119# Must be last so that soc/ can override default exception handlers 120add_subdirectory(core) 121 122get_property(OUTPUT_ARCH GLOBAL PROPERTY PROPERTY_OUTPUT_ARCH) 123get_property(OUTPUT_FORMAT GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT) 124 125 126 127add_bin_file_to_the_next_link(gen_idt_output staticIdt) 128add_bin_file_to_the_next_link(gen_idt_output irq_int_vector_map) 129add_bin_file_to_the_next_link(gen_idt_output irq_vectors_alloc) 130 131if(CONFIG_GDT_DYNAMIC) 132 # Use gen_gdt.py and objcopy to generate gdt.o from the elf 133 # file ${ZEPHYR_PREBUILT_EXECUTABLE}, creating the temp file gdt.bin along the 134 # way. 135 # 136 # ${ZEPHYR_PREBUILT_EXECUTABLE}.elf -> gdt.bin -> gdt.o 137 add_custom_target( 138 gdt_bin_target 139 DEPENDS 140 gdt.bin 141 ) 142 add_custom_command( 143 OUTPUT gdt.bin 144 COMMAND 145 ${PYTHON_EXECUTABLE} 146 ${ZEPHYR_BASE}/arch/x86/gen_gdt.py 147 --kernel $<TARGET_FILE:${ZEPHYR_PREBUILT_EXECUTABLE}> 148 --output-gdt gdt.bin 149 $<$<BOOL:${CMAKE_VERBOSE_MAKEFILE}>:--verbose> 150 DEPENDS ${ZEPHYR_PREBUILT_EXECUTABLE} 151 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 152 ) 153 154 add_bin_file_to_the_next_link(gdt_bin_target gdt) 155endif() 156