i am developing a program for some board, which uses PowerPC Architechture. I just have made some changes to the repository, refactored a bit and moved and erased classes.
On my development machine (VM linux x64) the binaries build fine and are executable. When i build with the CorssCompile Toolchain, it runs through smoothly without any errors nor warnings. But on the target system i cannot get the program to run, it seems to be not even making it to the main entry point.
So my guess is, that i have somehow created a linkage problem in the project. I just don't know how to untangle that beast.
So my questions, how can i get to the bottom of errors that occur before the main entry point was reached. How can i find the possible circular dependencies existing.
And just for "fun": Why in gods name would it build and run on x86 but not on ppc.
Yes i know this is few information to really help out, but i am asking for directions, sort of. Since i will have to deal with these problems some times anyways.
Why in gods name would it build and run on x86 but not on ppc.
There are a million possible reasons, from broken cross-toolchain, to bugs in libc, to incorrect toolchain invocation.
i am asking for directions
You should start by compiling this source:
int main() { return 0; }
and verifying that it works (this verifies basic toolchain sanity). If it does, you then extend it to print something. Then compile it with exactly the flags that you use in your real project.
If all of that checks out, you can run your real project under strace
and/or GDB and see if you understand where the crash is happening. If you don't, edit your question with output from the tools, and someone may be able to guess better.
Update:
It seems the PPC toolchain or rather its compiler did not know how to handle static variables being declared after usage
If that were true, you would get a compilation error. You didn't, so this is false.
On Target: "gdb crashing/app" and then look at the frames, somewhere there is a "__static_initialization_and_destruction_0" frame, which should even point you to the file and line the yet undeclared static variable is used.
Your real problem is very likely this: order of construction of global (or class-static) variables in different translation units (i.e. different source files) is undefined (and usually is opposite between x86_64
and ppc
). If you have two such globals in different files (say A
and B
), and if B
s constructor depends on A
having been constructed already, then your program will work fine on platforms where A
is constructed before B
, but will crash on platforms where B
is attempted to be constructed before A
.