New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: fix races without ninja #11821
Conversation
Thanks for digging into this, I'll take a closer look. In the past there were a number of other issues with dependencies when chains of custom command generated files are involved. I'll review again. |
b1a323b
to
91a88d9
Compare
This fixes build races which happened if "Unix Makefiles" instead of ninja-build was used as the cmake backend. For any dependencies of commands on files we need to create a target. Otherwise, if "Unix Makefiles" are used as the generator the commands are run in parallel on the different files which often can lead to races or redundancies in our build. A nice write-up can be found here: https://samthursfield.wordpress.com/2015/11/21/ cmake-dependencies-between-targets-and-files-and-custom-commands/# custom-commands-and-parallel-make
This should prevent future regressions when compiling with "Unix Makefiles" or others instead of ninja as the generator behind cmake.
91a88d9
to
cc3e74a
Compare
@Tony3dr could you build and flash this without ninja as follows and test please? Thanks!
I suggest to check |
@dagar the builds are still different but I think that's probably expected:
|
It's definitely not expected. As a start we can use bloaty to compare the binaries. |
@julianoes in addition to the Jenkins compile pipeline fmu-v2 and fmu-v5 are built in the default top level Jenkinsfile (https://github.com/PX4/Firmware/blob/master/Jenkinsfile) for bloaty comparisons. How about we just change those to use the Makefile generator? If possible I'd prefer to keep Jenkinsfile-compile to a single build per board because it serves as an archive for binaries. |
export NO_NINJA_BUILD=1 https://github.com/PX4/Firmware/blob/b6120f39f3cc27ce2ec1f3159d393e70db3f5ca5/Makefile#L72-L79 |
@dagar ok, I'll move it to |
Tested on pixhawk 4 v5Modes Tested:
Pre-flight Procedure:
Flight Test:
Notes: https://review.px4.io/plot_app?log=bbcc1b2e-ce65-43f4-89d3-6372bf7d4144 |
Tested on Pixhawk Pro v4Modes Tested
Pre-flight Procedure:
Flight Test:
Notes: https://review.px4.io/plot_app?log=b6ae5bba-0e22-4177-a3c8-18533dc92534 |
Tested on Pixhawk Cube v3Modes Tested
Pre-flight Procedure:
Flight Test:
Notes: https://review.px4.io/plot_app?log=17cb4f32-642d-4cba-bbc1-eed3a7372305 Tested on PixRacer v4:Modes Tested
Pre-flight Procedure:
Flight Test:
Notes: https://review.px4.io/plot_app?log=17cb4f32-642d-4cba-bbc1-eed3a7372305 |
Great, thanks a lot for testing and the write-up! |
@davids5 and I spent some time looking into differences between the Makefile and the ninja build and can confidently say that the binaries produced are the same except from the build time. One caveat is that the paths included in the binary using
@dagar if you have an idea how to prevent this that would be good. We replaced
We used the following to do comparisons: Build with ninja:
Extract strings:
And compare them using
Once it was all matching we could also compare the binary in hex:
And then compare that:
We also tried to compare the output of
Here is a comparison:
And ninja:
|
We can gradually eliminate our use of |
This fixes build races which happened if "Unix Makefiles" instead of ninja-build was used as the cmake backend.
For any dependencies of commands on files we need to create a target.
Otherwise, if "Unix Makefiles" are used as the generator the commands are run in parallel on the different files which often can lead to races or redundancies in our build.
A nice write-up can be found here:
https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/#custom-commands-and-parallel-make
Fixes #11003.