From 168a5788cd4d04fb69fe4cf02cb1483d758e5e5b Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 25 Mar 2022 10:07:13 +0100 Subject: [PATCH 1/3] Add custom json to fix lto on some systems --- custom.json | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 custom.json diff --git a/custom.json b/custom.json new file mode 100644 index 0000000..be18569 --- /dev/null +++ b/custom.json @@ -0,0 +1,58 @@ +{ + "GCC_ARM": { + "common": ["-Wall", "-Wextra", + "-Wno-unused-parameter", "-Wno-missing-field-initializers", + "-fmessage-length=0", "-fno-exceptions", + "-ffunction-sections", "-fdata-sections", "-funsigned-char", + "-MMD", "-flto", + "-fomit-frame-pointer", "-Os", "-DNDEBUG", "-g"], + "asm": ["-c", "-x", "assembler-with-cpp"], + "c": ["-c", "-std=gnu11"], + "cxx": ["-c", "-std=gnu++14", "-fno-rtti", "-Wvla"], + "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", + "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r", + "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", + "-Wl,-n", "-u printf", "-u main", "-u malloc", "-u snprintf", "-u _malloc_r"] + }, + "ARMC6": { + "common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Oz", + "-Wno-armcc-pragma-push-pop", "-Wno-armcc-pragma-anon-unions", + "-Wno-reserved-user-defined-literal", "-Wno-deprecated-register", + "-DMULADDC_CANNOT_USE_R7", "-fdata-sections", + "-fno-exceptions", "-MMD", "-fshort-enums", "-fshort-wchar", + "-DNDEBUG"], + "asm": [], + "c": ["-D__ASSERT_MSG", "-std=gnu11"], + "cxx": ["-fno-rtti", "-std=gnu++14"], + "ld": ["--show_full_path", "--legacyalign", "--any_contingency", + "--keep=os_cb_sections"] + }, + "ARM": { + "common": ["-c", "--gnu", "-Ospace", "--split_sections", + "--apcs=interwork", "--brief_diagnostics", "--restrict", + "--multibyte_chars", "-O3", "-DNDEBUG"], + "asm": [], + "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], + "cxx": ["--cpp11", "--no_rtti", "--no_vla"], + "ld": ["--show_full_path", "--any_contingency", "--keep=os_cb_sections"] + }, + "uARM": { + "common": ["-c", "--gnu", "-Ospace", "--split_sections", + "--apcs=interwork", "--brief_diagnostics", "--restrict", + "--multibyte_chars", "-O3", "-D__MICROLIB", + "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD", "-DNDEBUG"], + "asm": [], + "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"], + "cxx": ["--cpp11", "--no_rtti", "--no_vla"], + "ld": ["--library_type=microlib"] + }, + "IAR": { + "common": [ + "--no_wrap_diagnostics", "-e", + "--diag_suppress=Pa050,Pa084,Pa093,Pa082,Pe540", "-Ohz", "-DNDEBUG", "--enable_restrict"], + "asm": [], + "c": ["--vla", "--diag_suppress=Pe546"], + "cxx": ["--guard_calls", "--no_static_destruction"], + "ld": ["--skip_dynamic_initialization", "--threaded_lib", "--inline"] + } +} From 5c1c578f9817a6d03e0dc25800bdbb1b7eef1355 Mon Sep 17 00:00:00 2001 From: pennam Date: Tue, 6 Sep 2022 16:33:40 +0200 Subject: [PATCH 2/3] Fix ld options to improve lto --- custom.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom.json b/custom.json index be18569..3638fec 100644 --- a/custom.json +++ b/custom.json @@ -12,7 +12,7 @@ "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r", "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r", "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit", - "-Wl,-n", "-u printf", "-u main", "-u malloc", "-u snprintf", "-u _malloc_r"] + "-Wl,-n", "-u __wrap_printf", "-u main", "-u malloc", "-u __wrap_snprintf", "-u _malloc_r"] }, "ARMC6": { "common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Oz", From b4efb4b327d0e441cf83dee99f8125680c0b42eb Mon Sep 17 00:00:00 2001 From: pennam Date: Tue, 6 Sep 2022 16:34:28 +0200 Subject: [PATCH 3/3] Update mbed compile command using custom.json profile --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 08b8f58..4b94aa8 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ The following command will setup the mbed environment and clone the needed repos ``` mbed config root . && mbed deploy -mbed compile -m PORTENTA_H7_M7 -t GCC_ARM --profile=release --profile mbed-os/tools/profiles/extensions/lto.json +mbed compile -m PORTENTA_H7_M7 -t GCC_ARM --profile=release --profile custom.json ``` Additional flags are needed for [Lite](generate_rel.sh#L24), [Lite Connected](generate_rel.sh#L35) and [Nicla Vision](generate_rel.sh#L46) boards.