contiki/cpu/x86/Makefile.x86_common

45 lines
1.6 KiB
Makefile
Raw Normal View History

CONTIKI_CPU_DIRS += . init/common
CONTIKI_SOURCEFILES += gdt.c helpers.S idt.c cpu.c
CC = gcc
LD = $(CC)
# Use gcc to invoke the assembler so that the preprocessor will be run on each
# file first, enabling us to use macros within assembly language files:
AS = $(CC)
OBJCOPY = objcopy
SIZE = size
STRIP = strip
# Omit exception handling unwind tables (see
# http://wiki.dwarfstd.org/index.php?title=Exception_Handling). Removing these
# tables saves space and has not caused any readily-apparent functional
# changes.
#
x86, galileo: Add UEFI support This patch adds support for optionally building EFI binaries in addition to Multiboot ELF binaries. It includes a script, build_uefi.sh, that downloads tool and library sources from the EDK II project, builds the GenFw tool that is used to create UEFI binaries, and creates a makefile that is included from the main x86 common makefile and enables UEFI support in the Contiki build system. If the script is not run prior to building Contiki, then an informational message will be displayed with instructions for running build_uefi.sh if UEFI support is desired. This patch also adds the path to the auto-generated makefile to .gitignore. This patch modifies the linker script for the Intel Quark X1000 to account for the output file section offsets and alignment expectations of the EDK II GenFw project. This patch also adds a newlib patch to remove the weak symbol attribute from floating point stdio support routines. See <newlib>/newlib/README for an explanation of how the newlib developers intended for _printf_float and _scanf_float to be linked. Newlib declares them as weak symbols with the intention that developers would force them to be linked only when needed using a linker command line option. However, some but not all Contiki programs require them, so we cannot simply always include or exclude them. Instead, we remove the weak symbol attributes and rely on the linker to automatically determine whether or not they should be linked. This avoids an issue in which weak symbols were undefined in the intermediate DLL generated as part of the UEFI build process. That resulted in the GenFw program emitting "ERROR 3000" messages when it encountered relocations referencing such an undefined symbol. Finally, this patch updates README.md to both make some revisions to account for the UART support introduced in previous patches as well as to provide instructions for using the UEFI support.
2015-07-10 18:21:00 +00:00
# Furthermore, the .eh_frame and .eh_frame_hdr sections that are otherwise
# generated are treated as code sections by the UEFI GenFw program, since they
# are read-only alloc sections. They get grouped with the actual code
# sections, ahead of the data sections. This perturbs symbols and complicates
# debugging.
#
# Synchronize the unwind table options here with the CFLAGS and CXXFLAGS in
# ./bsp/libc/build_newlib.sh.
CFLAGS += -Wall -fno-asynchronous-unwind-tables -fno-unwind-tables
LDFLAGS += -Wl,-Map=contiki-$(TARGET).map,--build-id=none
ifeq ($(BUILD_RELEASE),1)
CFLAGS += -Os -fno-strict-aliasing -ffunction-sections -fdata-sections
# XXX: --gc-sections can be very tricky sometimes. If somehow the release
# binary seems to be broken, check if removing this option fixes the issue.
x86, galileo: Add UEFI support This patch adds support for optionally building EFI binaries in addition to Multiboot ELF binaries. It includes a script, build_uefi.sh, that downloads tool and library sources from the EDK II project, builds the GenFw tool that is used to create UEFI binaries, and creates a makefile that is included from the main x86 common makefile and enables UEFI support in the Contiki build system. If the script is not run prior to building Contiki, then an informational message will be displayed with instructions for running build_uefi.sh if UEFI support is desired. This patch also adds the path to the auto-generated makefile to .gitignore. This patch modifies the linker script for the Intel Quark X1000 to account for the output file section offsets and alignment expectations of the EDK II GenFw project. This patch also adds a newlib patch to remove the weak symbol attribute from floating point stdio support routines. See <newlib>/newlib/README for an explanation of how the newlib developers intended for _printf_float and _scanf_float to be linked. Newlib declares them as weak symbols with the intention that developers would force them to be linked only when needed using a linker command line option. However, some but not all Contiki programs require them, so we cannot simply always include or exclude them. Instead, we remove the weak symbol attributes and rely on the linker to automatically determine whether or not they should be linked. This avoids an issue in which weak symbols were undefined in the intermediate DLL generated as part of the UEFI build process. That resulted in the GenFw program emitting "ERROR 3000" messages when it encountered relocations referencing such an undefined symbol. Finally, this patch updates README.md to both make some revisions to account for the UART support introduced in previous patches as well as to provide instructions for using the UEFI support.
2015-07-10 18:21:00 +00:00
# Applying the --strip-all option to the UEFI build may induce an "Invalid operation" error.
# The UEFI GenFw program strips symbols.
MULTIBOOT_LDFLAGS += -Wl,--strip-all,--gc-sections
x86: Improve debugging experience This patch appends some gcc options to CFLAGS when building the default image in order to improve the debugging experience on GDB. We use the '-ggdb' option which produces debugging information used by GDB (including GDB extensions) with level 3 which includes preprocessor macros information. We also use '-Og' which enables optimizations that do not interfere with debugging. According to gcc manpage, it should be the optimization level of choice for the standard edit-compile-debug cycle, offering a reasonable level of optimization while maintaining fast compilation and a good debugging experience. Also, this patch removes the '-g' option from the default CFLAGS because there is no point in using it when BUILD_RELEASE=1. As expected, the overall ELF image increases (due to -ggdb3 option) while the .text section is reduced (due to -Og). For the sake of comparison, below follows the output of 'size'. Before patch: $ size -A hello-world.galileo hello-world.galileo : section size addr .text 13766 1048576 .rodata 241 1064960 .eh_frame 5160 1065204 .eh_frame_hdr 1212 1070364 .data 1188 1073152 .bss 12808 1077248 .debug_info 14351 0 .debug_abbrev 6281 0 .debug_aranges 768 0 .debug_line 6443 0 .debug_str 4805 0 .comment 17 0 .note 40 0 .debug_ranges 24 0 Total 67104 After patch: $ size -A hello-world.galileo hello-world.galileo : section size addr .text 11718 1048576 .rodata 249 1060864 .eh_frame 5496 1061116 .eh_frame_hdr 1204 1066612 .data 1156 1069056 .bss 12808 1073152 .debug_info 16727 0 .debug_abbrev 7254 0 .debug_loc 2083 0 .debug_aranges 768 0 .debug_macro 17273 0 .debug_line 13433 0 .debug_str 42192 0 .comment 17 0 .note 40 0 Total 132418
2015-07-10 14:44:28 +00:00
else
CFLAGS += -O0
ifeq ($(findstring clang,$(CC)),clang)
CFLAGS += -g
else
CFLAGS += -ggdb3
endif
endif