How does the Uv4.exe determine in what order source files are built? I have a project that I build on my local PC, and the same project being built on a build machine. The source files get compiled in a different order on the two machines, and the .hex file we end up with is different between the two machines. They are using the same version of uVision, compiling the same project files, and running the same command-line arguments.
We need to be able to reliably reproduce the .hex file generated on the build machine. I can build twice on my machine and get the same result, but what gets built on the build machine differs from my own. How can I force the project to be more consistent in how it builds the file?
I've always been under the impression that the build order is directly based upon the order source files appear in the project tree.
Like you, I needed to be able to produce 100% identical images from PC to PC or build to build, but have never had problems - so long as I leave the project tree alone.
One gotcha for me (and maybe you) is that I use the 'feedback' feature that eliminates unused functions from the final code image. I use the term 'feedback' here unsure of the exact phrase, because I don't have access to a PC.
With this feature, it is necessary to carry out at least three builds to ensure all unused functions. Prior builds might contain unused code and would therefore have a different image.
There's the "Use Cross-Module Optimization" setting, which I currently don't have checked. Is that what you mean by 'feedback'?
I've built three times consecutively on my own PC just now and it compiled some files in a different order each time. I wonder if there are multi-threaded processes and race conditions that are causing the order to change.
No. It's not cross module optimisation that I enable. For the one I mean, you must specify a -feedback parameter (I think) in both the compile and link.
But since your rebuilding 3 times, I suspect it's not that.
What your describing is not something I see. Maybe someone else can suggest something.
Order of compilation should be irrelevant. What counts is the link order, i.e. the sequence of files presented to the linker.
If you see unexpected differences in the hex files, the next thing to check is the map file. That's where you'll find how the linker was invoked, and what it placed where.
But yes, feedback will change the reault. So: do you run the same number of builds from scratch on your build server as you do locally?
Yes, you're right about that (and I should have mentioned it) but what I stated effectively does the same thing; with the order of files fed to the linker having a direct correlation to the build order.
I haven't seen uVision link in a different order than the project file, with the exception of special instructions given in the scatter file. So I normally change order of files in the project file to adjust the order of the code or variables in the output file - normally a lazy way of controlling how much of code or data that gets poured into separate memory regions without having to explicitly specify regions in the source code or explicitly adding the individual source files listed in the scatter file.