diff --git a/CMakeLists.txt b/CMakeLists.txt index 16bc07ab7..29f83eb7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,12 @@ option(OT_BUILD_EXECUTABLES "Build executables" ON) option(OT_BUILTIN_MBEDTLS "Enable builtin mbedTLS" ON) option(OT_COVERAGE "enable coverage" OFF) +include(TestBigEndian) +TEST_BIG_ENDIAN(OT_BIG_ENDIAN) +if(OT_BIG_ENDIAN) + list(APPEND OT_PRIVATE_DEFINES "BYTE_ORDER_BIG_ENDIAN=1") +endif() + include("${PROJECT_SOURCE_DIR}/etc/cmake/checks.cmake") include("${PROJECT_SOURCE_DIR}/etc/cmake/options.cmake") include("${PROJECT_SOURCE_DIR}/etc/cmake/functions.cmake") diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake index da1b9e7ea..bd16a3ce1 100644 --- a/etc/cmake/options.cmake +++ b/etc/cmake/options.cmake @@ -31,11 +31,6 @@ if(OT_BACKBONE_ROUTER) list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1") endif() -option(OT_BIG_ENDIAN "host platform uses big-endian byte order") -if(OT_BIG_ENDIAN) - list(APPEND OT_PRIVATE_DEFINES "BYTE_ORDER_BIG_ENDIAN=1") -endif() - option(OT_BORDER_AGENT "enable border agent support") if(OT_BORDER_AGENT) list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1") diff --git a/examples/platforms/cc1352/CMakeLists.txt b/examples/platforms/cc1352/CMakeLists.txt index 6b96df719..a0f350503 100644 --- a/examples/platforms/cc1352/CMakeLists.txt +++ b/examples/platforms/cc1352/CMakeLists.txt @@ -78,6 +78,7 @@ target_link_options(openthread-cc1352 ) target_link_options(openthread-cc1352 PUBLIC + -Wl,--gc-sections -Wl,-Map=$.map ) diff --git a/examples/platforms/cc1352/arm-none-eabi.cmake b/examples/platforms/cc1352/arm-none-eabi.cmake index 334ad6387..c2789c3a5 100644 --- a/examples/platforms/cc1352/arm-none-eabi.cmake +++ b/examples/platforms/cc1352/arm-none-eabi.cmake @@ -39,14 +39,12 @@ set(COMMON_C_FLAGS "-mcpu=cortex-m4 -march=armv7e-m -mfloat-abi= set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_C_FLAGS} -nostartfiles -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -Wl,-Map=map.map") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -nostartfiles -specs=nano.specs -specs=nosys.specs") set(CMAKE_C_FLAGS_DEBUG "-Og -g") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") set(CMAKE_ASM_FLAGS_DEBUG "-g") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_ASM_FLAGS_RELEASE "") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") diff --git a/examples/platforms/cc2538/CMakeLists.txt b/examples/platforms/cc2538/CMakeLists.txt index aeb17c4d6..04dec2f6d 100644 --- a/examples/platforms/cc2538/CMakeLists.txt +++ b/examples/platforms/cc2538/CMakeLists.txt @@ -59,7 +59,7 @@ set_property(TARGET openthread-cc2538 PROPERTY C_STANDARD 99) target_link_libraries(openthread-cc2538 PRIVATE openthread-platform-utils) target_link_options(openthread-cc2538 PUBLIC -T${PROJECT_SOURCE_DIR}/examples/platforms/cc2538/cc2538.ld) -target_link_options(openthread-cc2538 PUBLIC -Wl,-Map=$.map) +target_link_options(openthread-cc2538 PUBLIC -Wl,--gc-sections -Wl,-Map=$.map) target_compile_definitions(openthread-cc2538 PUBLIC diff --git a/examples/platforms/cc2538/arm-none-eabi.cmake b/examples/platforms/cc2538/arm-none-eabi.cmake index 3dfbb5f55..dc06caed5 100644 --- a/examples/platforms/cc2538/arm-none-eabi.cmake +++ b/examples/platforms/cc2538/arm-none-eabi.cmake @@ -39,14 +39,12 @@ set(COMMON_C_FLAGS "-mthumb -fno-builtin -Wall -fdata-sections - set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_C_FLAGS} -Wl,--gc-sections -specs=nano.specs -specs=nosys.specs -nostartfiles") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -nostartfiles") set(CMAKE_C_FLAGS_DEBUG "-Og -g") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") set(CMAKE_ASM_FLAGS_DEBUG "-g") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_ASM_FLAGS_RELEASE "") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") diff --git a/examples/platforms/cc2650/CMakeLists.txt b/examples/platforms/cc2650/CMakeLists.txt index 2db69e5fc..c731eecb0 100644 --- a/examples/platforms/cc2650/CMakeLists.txt +++ b/examples/platforms/cc2650/CMakeLists.txt @@ -77,6 +77,7 @@ target_link_libraries(openthread-cc2650 target_link_options(openthread-cc2650 PUBLIC + -Wl,--gc-sections -Wl,-Map=$.map ) diff --git a/examples/platforms/cc2650/arm-none-eabi.cmake b/examples/platforms/cc2650/arm-none-eabi.cmake index 9612baace..c889e39f0 100644 --- a/examples/platforms/cc2650/arm-none-eabi.cmake +++ b/examples/platforms/cc2650/arm-none-eabi.cmake @@ -39,14 +39,12 @@ set(COMMON_C_FLAGS "-mthumb -fdata-sections -ffunction-sections set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_C_FLAGS} -Wl,--gc-sections -specs=nano.specs -specs=nosys.specs -nostartfiles") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -nostartfiles") set(CMAKE_C_FLAGS_DEBUG "-Og -g") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") set(CMAKE_ASM_FLAGS_DEBUG "-g") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_ASM_FLAGS_RELEASE "") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") diff --git a/examples/platforms/cc2652/CMakeLists.txt b/examples/platforms/cc2652/CMakeLists.txt index e52a6ee19..447e50c7b 100644 --- a/examples/platforms/cc2652/CMakeLists.txt +++ b/examples/platforms/cc2652/CMakeLists.txt @@ -75,6 +75,7 @@ target_link_libraries(openthread-cc2652 target_link_options(openthread-cc2652 PUBLIC -T${PROJECT_SOURCE_DIR}/third_party/ti/devices/cc13x2_cc26x2/linker_files/cc26x2r1f.lds + -Wl,--gc-sections -Wl,-Map=$.map ) diff --git a/examples/platforms/cc2652/arm-none-eabi.cmake b/examples/platforms/cc2652/arm-none-eabi.cmake index 334ad6387..bd81b366a 100644 --- a/examples/platforms/cc2652/arm-none-eabi.cmake +++ b/examples/platforms/cc2652/arm-none-eabi.cmake @@ -39,14 +39,12 @@ set(COMMON_C_FLAGS "-mcpu=cortex-m4 -march=armv7e-m -mfloat-abi= set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_C_FLAGS} -nostartfiles -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -Wl,-Map=map.map") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -nostartfiles -specs=nano.specs -specs=nosys.specs -Wl,-Map=map.map") set(CMAKE_C_FLAGS_DEBUG "-Og -g") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") set(CMAKE_ASM_FLAGS_DEBUG "-g") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_ASM_FLAGS_RELEASE "") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") diff --git a/examples/platforms/kw41z/CMakeLists.txt b/examples/platforms/kw41z/CMakeLists.txt index 578661e19..3d153035e 100644 --- a/examples/platforms/kw41z/CMakeLists.txt +++ b/examples/platforms/kw41z/CMakeLists.txt @@ -55,7 +55,7 @@ add_library(openthread-kw41z set_property(TARGET openthread-kw41z PROPERTY C_STANDARD 99) target_link_libraries(openthread-kw41z PRIVATE nxp-kw41z-driver) target_link_options(openthread-kw41z PRIVATE -T${PROJECT_SOURCE_DIR}/examples/platforms/kw41z/MKW41Z512xxx4.ld) -target_link_options(openthread-kw41z PRIVATE -Wl,-Map=$.map) +target_link_options(openthread-kw41z PRIVATE -Wl,--gc-sections -Wl,-Map=$.map) target_compile_definitions(openthread-kw41z PUBLIC diff --git a/examples/platforms/kw41z/arm-none-eabi.cmake b/examples/platforms/kw41z/arm-none-eabi.cmake index f6e83f44b..d67bcb61a 100644 --- a/examples/platforms/kw41z/arm-none-eabi.cmake +++ b/examples/platforms/kw41z/arm-none-eabi.cmake @@ -39,14 +39,12 @@ set(COMMON_C_FLAGS "-mthumb -fdata-sections -ffunction-sections set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_C_FLAGS} -Wl,--gc-sections -specs=nano.specs -specs=nosys.specs") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs") set(CMAKE_C_FLAGS_DEBUG "-Og -g") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") set(CMAKE_ASM_FLAGS_DEBUG "-g") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_ASM_FLAGS_RELEASE "") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") diff --git a/examples/platforms/qpg6095/CMakeLists.txt b/examples/platforms/qpg6095/CMakeLists.txt index f197f3d5e..a9e6126b3 100644 --- a/examples/platforms/qpg6095/CMakeLists.txt +++ b/examples/platforms/qpg6095/CMakeLists.txt @@ -78,6 +78,7 @@ target_link_libraries(openthread-qpg6095 target_link_options(openthread-qpg6095 PUBLIC -T${CMAKE_CURRENT_SOURCE_DIR}/qpg6095.ld + -Wl,--gc-sections -Wl,-Map=$.map ) diff --git a/examples/platforms/qpg6095/arm-none-eabi.cmake b/examples/platforms/qpg6095/arm-none-eabi.cmake index ee8787e51..227520aca 100644 --- a/examples/platforms/qpg6095/arm-none-eabi.cmake +++ b/examples/platforms/qpg6095/arm-none-eabi.cmake @@ -39,14 +39,12 @@ set(COMMON_C_FLAGS "-mcpu=cortex-m4 -mthumb -fdata-sections -ffu set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs") set(CMAKE_C_FLAGS_DEBUG "-Og -g") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") set(CMAKE_ASM_FLAGS_DEBUG "-g") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_ASM_FLAGS_RELEASE "") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "") diff --git a/examples/platforms/samr21/CMakeLists.txt b/examples/platforms/samr21/CMakeLists.txt index c3ba4531d..38f92df86 100644 --- a/examples/platforms/samr21/CMakeLists.txt +++ b/examples/platforms/samr21/CMakeLists.txt @@ -75,6 +75,7 @@ target_link_libraries(openthread-samr21 target_link_options(openthread-samr21 PUBLIC + -Wl,--gc-sections -Wl,-Map=$.map ) diff --git a/examples/platforms/samr21/arm-none-eabi.cmake b/examples/platforms/samr21/arm-none-eabi.cmake index bf25f83f4..ff983a5ed 100644 --- a/examples/platforms/samr21/arm-none-eabi.cmake +++ b/examples/platforms/samr21/arm-none-eabi.cmake @@ -39,14 +39,12 @@ set(COMMON_C_FLAGS "-mcpu=cortex-m0plus -mfloat-abi=soft -mthumb set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99") set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti") set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}") -set(CMAKE_EXE_LINKER_FLAGS "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -Wl,--gc-sections -Wl,--entry=Reset_Handler") +set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -specs=nano.specs -specs=nosys.specs -Wl,--entry=Reset_Handler") set(CMAKE_C_FLAGS_DEBUG "-Og -g") set(CMAKE_CXX_FLAGS_DEBUG "-Og -g") set(CMAKE_ASM_FLAGS_DEBUG "-g") -set(CMAKE_EXE_LINKER_FLAGS_DEBUG "") set(CMAKE_C_FLAGS_RELEASE "-Os") set(CMAKE_CXX_FLAGS_RELEASE "-Os") set(CMAKE_ASM_FLAGS_RELEASE "") -set(CMAKE_EXE_LINKER_FLAGS_RELEASE "")