Closed ladislas closed 3 years ago
How could you explain such a difference?
If I had to guess, it's likely due to mbed-cmake providing a default mbedignore that removes a lot of the mbed os code for additional features. In the standard mbed-os build these are always enabled by default, though the linker is supposed to discard the code that isn't called in the final binary.
You could try copying the .mbedignore and mbed_app.json from the mbed-cmake/mbed-src folder into mbed-os/ and run the MBed CLI build again. If the results are still different, then I don't really know what the reason could be.
On a side note, would it be possible to have a more detailed size output with mbed-cmake?
Not easily, no. It would require modifications to the size printing script and I'm not very familiar with how that works. And it might not be possible because cmake builds mbed-os's object files differently.
On a second side note, compiling with mbed-cmake (on macOS), doesn't use the CPU as much. With mbed-cli, my macbook pro is quickly heating and the fans have to be turned on.
If you just run make
with no arguments, then it will only perform a single-core build which runs slowly. This might be why it's using less CPU. You can use make -jn
(where n is the number of CPU cores on your machine) to run multicore make that executes faster (this matches how the MBed build system works by default). You could also use the Ninja build tool which runs the optimum number of parallel jobs automatically.
You could try copying the .mbedignore and mbed_app.json from the mbed-cmake/mbed-src folder into mbed-os/ and run the MBed CLI build again. If the results are still different, then I don't really know what the reason could be.
I'll wait for https://github.com/ARMmbed/mbed-os/pull/13281 to be merged to do more benchmark.
You could also use the Ninja build tool which runs the optimum number of parallel jobs automatically.
And I've just tested Ninja... boy that is fast!
Have you gotten a chance to do this comparison yet?
Also @ladislas I noticed that you figured out how to add custom target support in your repo. Would you mind if I merged that support back into the master copy here?
@multiplemonomials no I haven't investigated more, I had a lot of things on my plate. At the same time, we haven't encountered any issues since using mbed-cmake, so that's good news.
Also @ladislas I noticed that you figured out how to add custom target support in your repo. Would you mind if I merged that support back into the master copy here?
Yes, please do! Let me know if I can help.
I'll close for now and open again if needed in the future.
I've been playing with mbed-cmake and I really like what you are doing. It integrates well in my project and gives me a lot more flexibility.
One thing I just noticed: when compiling the same
main.cpp
with mbed-cmake and mbed-cli, forrelease profile
, mbed-cmake gives a smaller.bin
.I have not yet tried to run the program on my board, will do so tomorrow.
The program:
mbed-cmake output:
mbed-cli output: (program created with
mbed new prog
)How could you explain such a difference?
On a side note, would it be possible to have a more detailed size output with mbed-cmake?
On a second side note, compiling with mbed-cmake (on macOS), doesn't use the CPU as much. With mbed-cli, my macbook pro is quickly heating and the fans have to be turned on.
So if mbed-cmake saves space and battery, it's a big win!