PlatformIO Compilation Process (pio run -v issue)

I’ve been trying to trace down a PIO build issue and I’ve run across something that I don’t understand. If I manually run the PIO’s compile command I come up with a different result than if PIO runs the compile itself. In other words, say I touch a single cpp file and run pio run -v it’ll compile that file and link it together and output the commands used. But if I compare the cpp object file that PIO generated with the one that I get from running pio run -v compile command manually I get a different object file. By different I mean the size might vary and/or the symbol table of the object file is different. This is very consistent.

Is PIO modifying the object file once it’s compiled? Or is is the pio run -v not displaying the correct compile command.

I have some evidence for the latter. Several times the output of pio run -v appears corrupted in that two of the compile flags are combined. For instance, -mcpu=cortex-m7 -mthumb comes out as -mcpu=cortex-m7-mthumb. When this problem occurs it’s always the same problem — combining compiler flags. Obviously, this isn’t the command that is being used internally since you’d get a compiler error.

I wish I could provide a simple test case but I haven’t been able to generate one yet. But I’ve been seeing this behavior off and on for several weeks now. In particular I would like to know why PIO generators different object files than if I run the commands manually. Any advice on how to debug this further?

Did you resolve this issue? Could you provide a simple project to reproduce this issue?

No I haven’t resolved this issue. And, unfortunately, I don’t have a simple project to show this.

But, perhaps, someone can answer the following.

  1. Are object files (.o) modified after they are created by the compiler that isn’t exposed by the pio run -v command? In other words, is there some magic happening in the background that isn’t shown by the pio run -v.

  2. Is there a way to see the build process in addition detail other than pio run -v?


Maybe, dumping build environment will help?

pio run -t envdump