Reputation: 125
I know that one uses libstdc++ and other use msvc standard library but what difference does it make when i compile the following without linking
int add(int a, int b) {return a + b;}
is there is any difference in the object code produced or is it the same and what is the difference between other targets
the command will be clang -c test.c -target x86_64-pc-windows-msvc/gnu
thanks
Upvotes: 8
Views: 7286
Reputation: 181459
what is the difference between x86_64-pc-windows-msvc and x86_64-pc-windows-gnu targets in clang
The two build for different C language implementations, which in this context means standard libraries, header and library search paths, and tools (especially linker). The former builds for the Microsoft Visual C(++), and the latter for GNU C (as provided, I believe, by MinGW and compatible toolchains).
is there is any difference in the object code produced or is it the same
It is possible that you don't get any object code in the first place for either or both targets. Each one requires corresponding development components to be installed on the system, which are not provided by Clang,
If both targets are in fact viable then Clang will use not just the functions of the chosen target's standard library, but also its headers. Depending on the program, this could produce object code that differs in minor ways.
and what is the difference between other targets
To the best of my knowledge, GNU C on Windows uses the same ABI (function-call conventions, data type definitions, layout rules, ...) as MSVC, so there should be no difference between the two targets in those areas. The same is not true for most other targets. If you chose a 32-bit target or a Linux target (for example) then you could expect much larger differences, and the result might not work on the build machine.
Upvotes: 5