Introduction
The Build System section contains information on subjects such as the GCC Compiler and Build Environment.
Overload Directory
A project can replace any NetBurner system file with a local copy. Place the copy under a directory named overload in the project root, at the path the system file has relative to $(NNDK_ROOT). The build system finds it by name. No makefile change is required.
Three lines in $(NNDK_ROOT)/make/boilerplate.mk implement this:
| Line | What it does |
| LOCAL_OVERLOAD_DIR ?= overload | Names the directory. A project makefile can override it, but no example does. |
| NBINCLUDE := $(subst $(NNDK_ROOT),$(LOCAL_OVERLOAD_DIR),$(NBINCLUDE)) $(NBINCLUDE) | Rewrites every -I$(NNDK_ROOT)/... entry into an -Ioverload/... entry and puts the rewritten list first, so an overloaded header is found before the system copy. |
| VPATH := $(LOCAL_OVERLOAD_DIR) $(NNDK_ROOT) | Makes the pattern rules resolve an overloaded .c, .cpp, or .s before the system copy. Library source paths are stripped of their $(NNDK_ROOT)/ prefix first, so VPATH can search both trees. |
The build also preprocesses predef.h through the same include path to see whether the project enabled NBRTOS_STACKOVERFLOW or NBRTOS_STACKUNDERFLOW. If so, it adds -fstack-check to CPPFLAGS and DBCPPFLAGS automatically.
- Note
- The directory must be named overload, not override. The first time you add a file to it, run make clean so the system library is rebuilt against the new file.
For how to use the feature, including the predef-overload.h shortcut for system configuration, see Modifying System Files with Overload and Overload Directory. A working project is at Overload Directory & System Files.
GCC Compiler Flags
Compiler flags can be added or modified in both NBEclipse and command line makefiles.
Generic
| Language | Mode | Flag | Description |
| C/C++ | R, D | -gdwarf-2 | Adds dwarf-2 debug symbols to the binary. This makes it easier to resolve symbols in gdb. |
| C/C++ | R, D | -Wall | Enables all warnings. |
| C/C++ | R, D | -Werror=return-type | Treats warnings as errors for functions that are missing a return statement. |
| C/C++ | R, D | -Wno-unused | Suppresses warnings for unused variables. |
| C/C++ | R, D | -falign-functions=4 | Aligns functions to 4-byte boundaries for improved performance. |
| C/C++ | R | -O2 | Enables level 2 optimization for improved performance. |
| C/C++ | D | -O0 | Disables optimization for debugging. |
| C/C++ | R, D | -D PLATFORM_NAME=$(PLATFORM_NAME) | Defines the PLATFORM_NAME macro with the value of the PLATFORM_NAME environment variable. |
| C/C++ | R, D | $(NBINCLUDE) | Includes the specified directories in the search path for header files. |
| C | R, D | -std=gnu17 | Sets the C standard to GNU C17. |
| C | R, D | -ffunction-sections | Places each function in a separate section to enable linker optimizations. |
| C | R, D | -fdata-sections | Places each data object in a separate section to enable linker optimizations. |
| C++ | R, D | -std=gnu++17 | Sets the C++ standard to GNU C++17. |
| C++ | R, D | -fno-rtti | Disables runtime type information (RTTI) for improved performance. |
| C++ | R, D | -fno-exceptions | Disables C++ exceptions for improved performance. |
| C++ | R, D | -Wno-register | Suppresses warnings for unused register variables. |
| C++ | R, D | -ffunction-sections | Places each function in a separate section to enable linker optimizations. |
| C++ | R, D | -fdata-sections | Places each data object in a separate section to enable linker optimizations. |
| Assembler | R, D | $(CPUFLAG) | Specifies the CPU architecture flag. |
Architecture-Specific Compiler Flags
ARM Cortex-M7
| Language | Mode | Flag | Description |
| C/C++ | R, D | -fasynchronous-unwind-tables | Enables asynchronous unwind tables |
| C/C++ | R, D | -D_C11_SOURCE | Defines the _C11_SOURCE macro. |
| C/C++ | R, D | -DCORTEX_M7 | Defines the CORTEX_M7 macro. |
ARM Cortex-M0+
| Language | Mode | Flag | Description |
| C/C++ | R, D | -fasynchronous-unwind-tables | Enables asynchronous unwind tables |
| C/C++ | D | -fomit-frame-pointer | Omit frame pointer for improved performance. |
| C/C++ | R, D | -D_C11_SOURCE | Defines the _C11_SOURCE macro. |
| C/C++ | R, D | -DCORTEX_M0PLUS | Defines the CORTEX_M0PLUS macro. |
ColdFire
| Language | Mode | Flag | Description |
| C/C++ | R, D | -fno-omit-frame-pointer | Do not omit frame pointer for improved debugging |
| C/C++ | R, D | -fasynchronous-unwind-tables | Enables asynchronous unwind tables |
| C/C++ | R, D | -DCOLDFIRE | Defines the COLDFIRE macro |
| Assembler | D | --defsym _DEBUG=1 | Defines the _DEBUG symbol. |
CPU-Specific Compiler Flags
SAME70
| Language | Mode | Flag | Description |
| C/C++ | R, D | -mcpu=cortex-m7 | Specifies the CPU architecture. |
| C/C++ | R, D | -mthumb | Specifies the Thumb instruction set. |
| C/C++ | R, D | -mfpu=fpv5-d16 | Specifies the floating-point unit. |
| C/C++ | R, D | -mfloat-abi=$(ABI_OPT) | Specifies the floating-point ABI. Defaults to softfp |
| C/C++ | R, D | -D$(CPU) | Defines the $(CPU) macro. |
| C++ | R, D | -fno-use-cxa-atexit | Disables the use of __cxa_atexit |
| C++ | R, D | -falign-fuinctions=4 | Aligns functions to 4-byte boundaries for improved performance. |
MIMXRT11xx, MIMXRT10xx
| Language | Mode | Flag | Description |
| C/C++ | R, D | -mcpu=cortex-m7 | Specifies the CPU architecture. |
| C/C++ | R, D | -mthumb | Specifies the Thumb instruction set. |
| C/C++ | R, D | -mfpu=fpv5-d16 | Specifies the floating-point unit. |
| C/C++ | R, D | -mfloat-abi=$(ABI_OPT) | Specifies the floating-point ABI. Defaults to softfp |
| C/C++ | R, D | -D$(CPU) | Defines the $(CPU) macro. |
| C++ | R, D | -fno-use-cxa-atexit | Disables the use of __cxa_atexit |
| C++ | R, D | -falign-fuinctions=8 | Aligns functions to 8-byte boundaries for improved performance. |
SAMD20
| Language | Mode | Flag | Description |
| C/C++ | R, D | -mcpu=cortex-m0plus | Specifies the CPU architecture. |
| C/C++ | R, D | -mthumb | Specifies the Thumb instruction set. |
| C++ | R | -fno-use-cxa-atexit | Disables the use of __cxa_atexit |
| C++ | R | -falign-fuinctions=4 | Aligns functions to 4-byte boundaries for improved performance. |
MCF5441X
| Language | Mode | Flag | Description |
| C/C++ | R, D | -D$(CPU) | Defines the $(CPU) macro. |
| C/C++ | R, D | -mcpu=54415 | Specifies the CPU architecture. |
Platform-Specific Compiler Flags
MODM7AE70
| Language | Mode | Flag | Description |
| C/C++ | R, D | -D__SAME70Q21__ | Defines the __SAME70Q21__ macro. |
| C/C++ | R, D | -DMODM7AE70 | Defines the MODM7AE70 macro. |
SBE70LC
| Language | Mode | Flag | Description |
| C/C++ | R, D | -D__SAME70Q21__ | Defines the __SAME70Q21__ macro. |
| C/C++ | R, D | -DSBE70LC | Defines the SBE70LC macro. |
SOMRT1061
| Language | Mode | Flag | Description |
| C/C++ | R, D | -D__MIMXRT106xx__ | Defines the __MIMXRT106xx__ macro. |
| C/C++ | R, D | -D__MIMXRT1061__ | Defines the __MIMXRT1061__ macro. |
| C/C++ | R, D | -DSOMRT1061 | Defines the SOMRT1061 macro. |
MOD5441X
| Language | Mode | Flag | Description |
| C/C++ | R, D | -DMOD5441X | Defines the MOD5441X macro. |
NANO54415
| Language | Mode | Flag | Description |
| C/C++ | R, D | -DNANO54415 | Defines the NANO54415 macro. |
SB800EX
| Language | Mode | Flag | Description |
| C/C++ | R, D | -DSB800EX | Defines the SB800EX macro. |
Linker Flags
Generic
| Flag | Description |
| $(CPUFLAG) | Specifies the CPU architecture flag. |
| -Wl,-n | Disables linking to dyn |
| -T$(NNDK_ROOT)/platform/$(PLATFORM)/lib/$(PLATFORM).ld | Specifies the linker script. |
| -Wl,-R$(NNDK_ROOT)/platform/$(PLATFORM)/lib/sys.ld | Specifies the linker script. |
| -Wl,-Map=$(@:.elf=.map) | Generates a map file. |
| -Wl,--cref | Generates a cross-reference table. |
| -Wl,--gc-sections | Removes unused sections to reduce the size of the binary. |
| -Wl,--start-group,$(NBLIBS) $(XTRALIB) -lstdc++ -lc -Wl,--end-group | Specifies the libraries to link. |
Architecture-Specific Linker Flags
None
CPU-Specific Linker Flags
SAME70
| Flag | Description |
| -nostartfiles | Disables linking to the default startup files. |
| -mfloat-abi=$(ABI_OPT) | Specifies the floating-point ABI. Defaults to softfp |
| -Wl--thumb-entry=Reset_Handler | Specifies the entry point. |
| -Wl--thumb-entry=_start_ | Specifies the entry point. (SOMRT1061) |
MIMXRT11xx, MIMXRT10xx
| Flag | Description |
| -nostartfiles | Disables linking to the default startup files. |
| -mfloat-abi=$(ABI_OPT) | Specifies the floating-point ABI. Defaults to softfp |
| -Wl--thumb-entry=Reset_Handler | Specifies the entry point. |
SAMD20
| Flag | Description |
| -nostartfiles | Disables linking to the default startup files. |
| -Wl--thumb-entry=Reset_Handler | Specifies the entry point. |
MCF5441X
None
Platform-Specific Linker Flags
None
Pack Binary
Generic
None
Architecture-Specific
None
CPU-Specific
MCF5441X
| Executable | I/O | Flag | Description |
| m68k-elf-objcopy | .elf -> .s19 | -O srec | Converts the elf file to s19 |
| m68k-elf-objcopy | .elf -> .s19 | -Wl,--gc-sections | Removes unused sections to reduce the size of the binary. |
| m68k-elf-objcopy | .elf -> .s19 | --strip-all | Removes all symbols from the binary. |
| compcode | .s19 -> _APP.s19 | -M $(^:.s19=.map) | Specifies the map file. |
| compcode | .s19 -> _APP.s19 | -R | Print report. |
| compcode | .s19 -> _APP.s19 | -P$(PLATFORM) | Specifies the platform. |
| compcode | .s19 -> .bin | -O binary | Converts the s19 file to binary |
| compcode | .s19 -> .bin | -M $(^:.s19=.map) | Specifies the map file. |
| compcode | .s19 -> .bin | -B | Specifies binary output. |
| compcode | .s19 -> .bin | -P$(PLATFORM) | Specifies the platform. |
| compcode | .s19 -> .bin | -R | Print report. |
SAMD20
| Executable | I/O | Flag | Description |
| nbfspack | .elf -> .bin | -output-target bin | Converts the elf file to binary |
SAME70
| Executable | I/O | Flag | Description |
| arm-none-eabi-size | .elf -> .bin | | Displays the size of the binary. |
| nbfspack | .elf -> .bin | -output-target bin | Converts the elf file to binary |
| nbfspack | .elf -> .bin | -S | Show build statistics. |
| nbfspack | .elf -> .bin | -P $(PLATFORM) | Specifies the platform. |
MIMXRT11xx, MIMXRT10xx
| Executable | I/O | Flag | Description |
| nbfspack | .elf -> .bin | -output-target bin | Converts the elf file to binary |
Platform-Specific
MODM7AE70
| Executable | I/O | Flag | Description |
| nbfspack | .elf -> .bin | -C | Compress program sections |
| nbfspack | .elf -> .bin | -cflag S:3 | . |
| nbfspack | .elf -> .bin | -cflag S:0 | . |
| nbfspack | .elf -> .bin | -cflag S:1 | . |
SBE70LC
| Executable | I/O | Flag | Description |
| nbfspack | .elf -> .bin | -C | Compress program sections |
| nbfspack | .elf -> .bin | -cflag S:3 | . |
| nbfspack | .elf -> .bin | -cflag S:0 | . |
| nbfspack | .elf -> .bin | -cflag S:1 | . |
SOMRT1061
None
MOD5441X
| Executable | I/O | Flag | Description |
| compcode | .s19 -> .bin | 0xC0040000 0xC1FC0000 | Application address range. |
NANO54415
| Executable | I/O | Flag | Description |
| compcode | .s19 -> .bin | 0x04000 0x800000 | Application address range. |
SB800EX
| Executable | I/O | Flag | Description |
| compcode | .s19 -> .bin | 0x04000 0x800000 | Application address range. |