Question

I am using gnu gcc and armcc to compile a few C files. How can I get the information about which compiler compiled which file?

Ex: test.cpp is being compiled by armcc or gnu gcc.

The makefile is very complicated and I am looking out for a command by which I can check which compiler compiled which file.

Any ideas?

Was it helpful?

Solution

Sometimes you can look at the file with a hex editor and tell if the compiler wrote its name into the file.

OTHER TIPS

I'm not sure if there's an easier way, but you can find it embedded in the binary with gcc (at least on my platform):

$ hexdump -C foo | grep -A2 GCC

00001030  00 00 00 00 00 00 00 00  47 43 43 3a 20 28 55 62  |........GCC: (Ub|
00001040  75 6e 74 75 2f 4c 69 6e  61 72 6f 20 34 2e 37 2e  |untu/Linaro 4.7.|
00001050  32 2d 32 32 75 62 75 6e  74 75 33 29 20 34 2e 37  |2-22ubuntu3) 4.7|

Some compiler embedd compiler name and version in to the binrary, but not all. We can also embedd whatever information we want into the binary.

gcc -DCOMPILER_DETAILS='"gcc 4.3.3"' temp.c

In temp.c use the macro COMPILER_DETAILS in any place, like just use it in printf. So that this string literal will be embedd in the generated binary file. Dont assign this string to unused variable, compiler will not embedd because of optimization.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top