Sysprogs forums › Forums › VisualGDB › Reduce size of C++ binaries in Stand-alone project
Tagged: Embedded memory explorer
- This topic has 11 replies, 2 voices, and was last updated 7 years, 5 months ago by janulo.
-
AuthorPosts
-
June 5, 2017 at 13:05 #11399januloParticipant
Hi everyone!
I’m working on project on STM32 using VisualGDB. Our project was converted to Stand-alone year ago. I would like to reduce size of output binaries using “Reduce size of C++ binaries” feature described here at the end of page :
The solution in this case would be to replace __cxa_pure_virtual() with something more compact that will for example just trigger a breakpoint. The “Reduce size of C++ binaries” option does exactly that…
Unfortunately, I didn’t find any option like this in our project settings. Is there any way to do such a size reduction in case of Stand-alone project?
Our output from Embedded Memory Explorer looks similar to output from tutorial mentioned above.
June 6, 2017 at 04:35 #11400supportKeymasterHi,
Yes, please try adding “compactcpp” to the list of library names in VisualGDB Project Properties. This should be equivalent to checking the “reduce size of C++ binaries” checkbox.
- This reply was modified 7 years, 5 months ago by support.
June 15, 2017 at 22:25 #11489januloParticipantHi,
thanks for your response. I tried your recommendation, but no change in flash memory used. We are not using any pure virtual methods, but still a lot of classes and std::arrays, it may be related?
I will try to insert screenshot from memory explorer:
- This reply was modified 7 years, 5 months ago by janulo. Reason: screenshot edit
June 17, 2017 at 19:26 #11496supportKeymasterHi,
If you are using a 3rd-party toolchain, it may be configured slightly differently and the compactcpp library won’t override the necessary symbols. Please try switching to our ARM toolchain.
June 18, 2017 at 09:21 #11497januloParticipantHi,
If I’m not wrong, we are already using arm toolchain: VisualGDB properties – Makefile settings – Toolchain: ARM in c:\SysGCC\arm-eabi.
During compilation, I can see in Output window instructions starting with following (so this should not be the case of 3rd-party toolchain):
c:\SysGCC\arm-eabi/bin/arm-eabi-gcc.exe c:\SysGCC\arm-eabi/bin/arm-eabi-g++.exe c:\SysGCC\arm-eabi/bin/arm-eabi-objcopy.exe
June 19, 2017 at 02:53 #11499supportKeymasterHi,
That does indeed look like our toolchain. Please try enabling the map file generation via Linker Properties and ensure that the _ZSt9terminatev (std::terminate) function is coming from the libcompactcpp.a:
.text 0x08000188 0xa4 e:/sysgcc/arm-eabi/bin/../lib/gcc/arm-eabi/6.2.0/thumb/cortex_m4/crtbegin.o .text 0x0800022c 0xc e:/sysgcc/arm-eabi/bin/../lib/gcc/arm-eabi/6.2.0/../../../../arm-eabi/lib/thumb/cortex_m4\libcompactcpp.a(libcompactcpp.o) 0x0800022c __cxa_pure_virtual 0x08000232 _ZSt9terminatev
June 19, 2017 at 22:54 #11530januloParticipantHi,
It looks like this _ZSt9terminatev is comming from libstdc++.a:
.text._ZN10__cxxabiv111__terminateEPFvvE 0x0804bfc0 0x28 c:/sysgcc/arm-eabi/bin/../lib/gcc/arm-eabi/6.2.0/../../../../arm-eabi/lib/thumb/fpu/cortex_m4\libstdc++.a(eh_terminate.o) 0x0804bfc0 _ZN10__cxxabiv111__terminateEPFvvE .text._ZSt9terminatev 0x0804bfe8 0x14 c:/sysgcc/arm-eabi/bin/../lib/gcc/arm-eabi/6.2.0/../../../../arm-eabi/lib/thumb/fpu/cortex_m4\libstdc++.a(eh_terminate.o) 0x0804bfe8 _ZSt9terminatev
June 20, 2017 at 04:13 #11532supportKeymasterHi,
OK, this looks like the libcompactcpp.a is actually not being compiled in. Please check the verbose link log (if you are using MSBuild, simply check the .link.rsp file) for the linker command line and ensure it contains the “-lcompactcpp” argument. If you are not sure, please post the linker command line here and we will help you resolve this.
June 20, 2017 at 07:24 #11537januloParticipantHi, thanks for trying to help me 🙂
I’m not using MSBuild, but when I check output window, the almost last line is quite long (I skipped the .o file and left only some to make this shorter, my comments are inside { }. Also I put this on multiple lines to make it more readable ):
c:\SysGCC\arm-eabi/bin/arm-eabi-g++.exe -o Release/BCR-G2_demo.elf -Wl,-gc-sections -Wl,-q -Wl, -TSTM32L471VG_flash_wCRC.lds -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -Wl,-Map=Release/BCR-G2_demo.map -Wl,--start-group Release/system_stm32l4xx.o Release/stm32l4xx_hal.o {lot of other .o files} -lcompactcpp {local path}STemWin528_CM4_GCC.a -Wl,--end-group
June 20, 2017 at 07:35 #11540januloParticipantI’m fighting with text editor 🙂 Using <> for my comments was not good idea, so one more try with { }.
c:\SysGCC\arm-eabi/bin/arm-eabi-g++.exe -o Release/BCR-G2_demo.elf -Wl,-gc-sections -Wl,-q -Wl, -TSTM32L471VG_flash_wCRC.lds -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -Wl,-Map=Release/BCR-G2_demo.map -Wl,--start-group Release/system_stm32l4xx.o Release/stm32l4xx_hal.o {skipped .o files here} -lcompactcpp {local path}STemWin528_CM4_GCC.a -Wl,--end-group
June 21, 2017 at 04:11 #11548supportKeymasterHi,
Strange, it looks like the libcompactcpp library is specified in the command line, but is not linked.
In order to troubleshoot this, please try creating a new project from scratch with the following code:
#include <exception> int main(void) { std::terminate(); }
Then link it with libcompactcpp. If the map file shows that the _ZSt9terminatev function is taken from libcompactcpp.a, please try understanding the differences between your main project and the test project. If not, please try re-downloading our latest toolchain.
If nothing helps, please add “-Wl,-verbose” to LDFLAGS and post the following:
- The full Map file
- The full verbose link log
This should help understand why libcompactcpp.a is not included.
June 27, 2017 at 06:54 #11583januloParticipantHi,
I’m sorry for my delayed response.
I’ve tried this simple project and _ZSt9terminatev function is linked correctly from libcompactcpp.a. Unfortunately, priorities on project have changed and I have to postpone this downsizing task. I’ll compare main project with the test project and I will come with results, or with full Map and verbose log, ASAP. Thanks for understanding.
Jan
-
AuthorPosts
- You must be logged in to reply to this topic.