[core] Organize GCC compilation flags
This commit is contained in:
@@ -44,32 +44,9 @@ queue.AppendPublic(
|
||||
"-march=armv5te",
|
||||
"-mthumb",
|
||||
"-mthumb-interwork",
|
||||
"-g",
|
||||
"-O2",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fno-strict-aliasing",
|
||||
"-fsigned-char",
|
||||
"-Wno-comment",
|
||||
"-Wno-write-strings",
|
||||
"-Wno-char-subscripts",
|
||||
"-Wno-missing-braces",
|
||||
"-Wno-attributes",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
"-nostdlib",
|
||||
"-Wall",
|
||||
"-Wno-format",
|
||||
"-Wno-unknown-pragmas",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++11",
|
||||
"-MMD",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-Wno-literal-suffix",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
# SDK options
|
||||
("CFG_OS_FREERTOS", "1"),
|
||||
@@ -92,9 +69,7 @@ queue.AppendPublic(
|
||||
"-mcpu=arm968e-s",
|
||||
"-marm",
|
||||
"-mthumb-interwork",
|
||||
"-g",
|
||||
"--specs=nano.specs",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-wrap,bk_flash_get_info",
|
||||
"-Wl,-wrap,bk_flash_erase",
|
||||
"-Wl,-wrap,bk_flash_write",
|
||||
@@ -103,6 +78,17 @@ queue.AppendPublic(
|
||||
"-Wl,-wrap,bk_printf",
|
||||
],
|
||||
)
|
||||
queue.AppendPrivate(
|
||||
CCFLAGS=[
|
||||
"-Wno-comment",
|
||||
"-Wno-char-subscripts",
|
||||
"-Wno-missing-braces",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-Wno-format",
|
||||
"-Wno-unknown-pragmas",
|
||||
],
|
||||
)
|
||||
|
||||
srcs_core = []
|
||||
|
||||
@@ -330,8 +316,8 @@ queue.AddLibrary(
|
||||
CCFLAGS=[
|
||||
"-Wno-unused-variable",
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-w",
|
||||
],
|
||||
CFLAGS=["-<-Wall>"],
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -17,27 +17,7 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-g2",
|
||||
"-w",
|
||||
"-O2",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fmessage-length=0",
|
||||
"-fno-common",
|
||||
"-fno-short-enums",
|
||||
"-fomit-frame-pointer",
|
||||
"-fsigned-char",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
"-Wno-pointer-sign",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
# borrowed from RtlDuino/development/rtl87xx/platform.txt
|
||||
"-std=gnu++11",
|
||||
"-MMD",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
# other options
|
||||
@@ -52,17 +32,11 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mfloat-abi=hard",
|
||||
"-mfpu=fpv4-sp-d16",
|
||||
"-g",
|
||||
"--specs=nano.specs",
|
||||
"-Os",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--cref",
|
||||
# the entrypoint in ROM (?)
|
||||
"-Wl,--entry=Reset_Handler",
|
||||
# start function table in startup.c
|
||||
"-Wl,--undefined=gImage2EntryFun0",
|
||||
"-Wl,--no-enum-size-warning",
|
||||
"-Wl,--no-wchar-size-warning",
|
||||
"-Wl,-wrap,rom_psk_CalcGTK",
|
||||
"-Wl,-wrap,rom_psk_CalcPTK",
|
||||
"-Wl,-wrap,CalcMIC",
|
||||
@@ -88,6 +62,14 @@ queue.AppendPublic(
|
||||
"-Wl,-wrap,__rtl_vfprintf_r_v1_00",
|
||||
],
|
||||
)
|
||||
queue.AppendPrivate(
|
||||
CFLAGS=[
|
||||
"-Wno-implicit-function-declaration",
|
||||
"-Wno-incompatible-pointer-types",
|
||||
"-Wno-int-conversion",
|
||||
"-Wno-pointer-sign",
|
||||
],
|
||||
)
|
||||
|
||||
# Sources - from SDK project/realtek_amebaz_va0_example/GCC-RELEASE/application.mk
|
||||
# - "console" is disabled as it introduces build error, and is generally useless
|
||||
@@ -203,6 +185,9 @@ queue.AddLibrary(
|
||||
"+<component/common/network/mdns>",
|
||||
"+<component/common/network/libwsclient>",
|
||||
],
|
||||
options=dict(
|
||||
CFLAGS=["-w"],
|
||||
),
|
||||
)
|
||||
|
||||
# Sources - lwIP
|
||||
|
||||
@@ -21,30 +21,14 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mcmse",
|
||||
"-mfloat-abi=soft",
|
||||
"-g",
|
||||
"-gdwarf-3",
|
||||
"-Os",
|
||||
"-MMD",
|
||||
"-fstack-usage",
|
||||
"-fdata-sections",
|
||||
"-ffunction-sections",
|
||||
"-fmessage-length=0",
|
||||
"-fno-common",
|
||||
"-fno-short-enums",
|
||||
"-fomit-frame-pointer",
|
||||
"-fsigned-char",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
"-Wall",
|
||||
"-Wpointer-arith",
|
||||
"-Wno-write-strings",
|
||||
"-Wno-maybe-uninitialized",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-std=c++11",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-fno-use-cxa-atexit",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
@@ -68,19 +52,9 @@ queue.AppendPublic(
|
||||
"-mthumb",
|
||||
"-mcmse",
|
||||
"-mfloat-abi=soft",
|
||||
"-g",
|
||||
"--specs=nosys.specs",
|
||||
"-nostartfiles",
|
||||
"-nodefaultlibs",
|
||||
"-nostdlib",
|
||||
"-Os",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--warn-section-align",
|
||||
"-Wl,--cref",
|
||||
"-Wl,--build-id=none",
|
||||
"-Wl,--use-blx",
|
||||
"-Wl,--undefined=gRamStartFun",
|
||||
"-Wl,-no-enum-size-warning",
|
||||
"-Wl,-wrap,aesccmp_construct_mic_iv",
|
||||
"-Wl,-wrap,aesccmp_construct_mic_header1",
|
||||
"-Wl,-wrap,aesccmp_construct_ctr_preload",
|
||||
@@ -362,6 +336,11 @@ queue.AddLibrary(
|
||||
"+<src/include>",
|
||||
"+<src/include/netif>",
|
||||
],
|
||||
options=dict(
|
||||
CFLAGS=[
|
||||
"-Wno-implicit-function-declaration",
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
# Sources - mbedTLS
|
||||
|
||||
@@ -18,11 +18,33 @@ family: Family = env["FAMILY_OBJ"]
|
||||
# Move common core sources (env.AddCoreSources()) and Arduino libs
|
||||
# below per-family sources (to maintain child families taking precedence)
|
||||
|
||||
# Global flags (applying to the SDK)
|
||||
# Global public flags
|
||||
# Refer to https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html
|
||||
env.Append(
|
||||
CCFLAGS=[
|
||||
# Newer versions of GCC complain about undefined macros in #if
|
||||
"-Wno-undef",
|
||||
# C Language Options
|
||||
"-fsigned-char", # Let the type char be signed
|
||||
# Debugging Options
|
||||
"-g2", # produce debugging information; the default level is 2
|
||||
# Optimization Options
|
||||
"-Os", # optimize for size; enables all -O2 optimizations except those that often increase code size
|
||||
"-fdata-sections", # place each function or data item into its own section
|
||||
"-ffunction-sections", # place each function or data item into its own section
|
||||
"-fno-strict-aliasing", # (don't) assume the strictest aliasing rules applicable
|
||||
# Preprocessor Options
|
||||
"-MMD", # output a rule suitable for make describing the dependencies of the main source file
|
||||
# Code Generation Options
|
||||
"-fno-common", # place uninitialized global variables in the BSS section of the object file
|
||||
"-fno-exceptions", # disable exception handling
|
||||
# Developer Options
|
||||
"-fstack-usage", # output stack usage information for the program, on a per-function basis
|
||||
],
|
||||
CFLAGS=[
|
||||
"-std=gnu99",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-std=gnu++11",
|
||||
"-fno-rtti", # disable generation of information about every class with virtual functions
|
||||
],
|
||||
)
|
||||
|
||||
@@ -62,11 +84,19 @@ queue.AddExternalLibrary("ltchiptool") # uf2ota source code
|
||||
queue.AddExternalLibrary("flashdb")
|
||||
queue.AddExternalLibrary("printf")
|
||||
|
||||
# Flags & linker options
|
||||
# Non-SDK defines & linker options
|
||||
queue.AppendPublic(
|
||||
CCFLAGS=[
|
||||
"-Wreturn-type",
|
||||
"-Wno-undef",
|
||||
],
|
||||
CFLAGS=[
|
||||
"-Werror=implicit-function-declaration",
|
||||
],
|
||||
CXXFLAGS=[
|
||||
"-Wno-literal-suffix",
|
||||
"-Wno-write-strings",
|
||||
],
|
||||
CPPDEFINES=[
|
||||
("LIBRETUYA", 1),
|
||||
("LT_VERSION", env.ReadLTVersion(platform.get_dir(), platform.version)),
|
||||
@@ -82,6 +112,13 @@ queue.AppendPublic(
|
||||
"$VARIANTS_DIR",
|
||||
],
|
||||
LINKFLAGS=[
|
||||
"-g2",
|
||||
"-Os",
|
||||
"-Wl,--build-id=none",
|
||||
"-Wl,--cref",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,--no-enum-size-warning",
|
||||
"-Wl,--no-wchar-size-warning",
|
||||
# malloc.c wrappers
|
||||
"-Wl,-wrap,malloc",
|
||||
"-Wl,-wrap,calloc",
|
||||
|
||||
@@ -48,7 +48,6 @@ def env_add_core_sources(env: Environment, queue, name: str, path: str) -> bool:
|
||||
"+<*.c*>",
|
||||
"+<common/*.c*>",
|
||||
"+<compat/*.c*>",
|
||||
"+<fixups/*.c*>",
|
||||
"+<port/*.c*>",
|
||||
"+<posix/*.c>",
|
||||
"+<wraps/*.c>",
|
||||
@@ -58,10 +57,23 @@ def env_add_core_sources(env: Environment, queue, name: str, path: str) -> bool:
|
||||
"!<.>",
|
||||
"!<compat>",
|
||||
"!<config>",
|
||||
"!<fixups>",
|
||||
"!<port>",
|
||||
],
|
||||
)
|
||||
queue.AddLibrary(
|
||||
name=f"core_{name}_fixups",
|
||||
base_dir=path,
|
||||
srcs=[
|
||||
"+<fixups/*.c*>",
|
||||
],
|
||||
includes=[
|
||||
"!<fixups>",
|
||||
],
|
||||
options=dict(
|
||||
# disable all warnings for fixups
|
||||
CCFLAGS=["-w"],
|
||||
),
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -166,7 +166,6 @@ class LibraryQueue:
|
||||
def BuildLibraries(self):
|
||||
if self.built:
|
||||
raise RuntimeError("Cannot build a library queue twice")
|
||||
self.Print()
|
||||
|
||||
# add public options to the environment
|
||||
apply_options(self.env, self.options_public)
|
||||
|
||||
Reference in New Issue
Block a user