Trick-17 / clang-build

Clang-based cross platform build system written in Python
https://clang-build.readthedocs.io
MIT License
8 stars 3 forks source link

Link-Command: distinguish between C and C++ #94

Closed NOhs closed 4 years ago

NOhs commented 5 years ago

In single_source.py the file extension will decide which compiler to use. For the linker, there is no such thing (see target.py), but I am not sure if the clangpp and clang linker are different.

GPMueller commented 5 years ago

From what I understand about binaries, there should not be different linkers, because object files should be independent of the original language. You could link together object files from C, C++ and Objective-C/C++ into a single binary. I am also not aware of any language-specific link flags. Therefore, I think we should only address this issue if we find a hint that we should make a distinction.

Also, instead of using different compiler frontends, it might be better to always set language flags, e.g. -x c -std=c11 or -x c++ -std=c++17.

NOhs commented 5 years ago

I'm not sure. This would make the output more verbose, which is against clang-builds "it just works, and looks reasonable" approach.

GPMueller commented 5 years ago

Only if the output is on debug level, at which point it makes sense that this information be included. Compared to include directories etc. it would take up very little space, but the user could be sure of the language and language version that is being used.

GPMueller commented 4 years ago

To address the original question, there is actually a difference: https://stackoverflow.com/a/8441942/4069571 clangpp apparently links the C++ standard library, meaning we should actually not necessarily be using it (though it probably only hurts binary size or something like that). To definitely figure out what we should be doing, some more research is needed.

GPMueller commented 4 years ago

After discussions based on https://stackoverflow.com/a/173007/2305545 we decided to use clangpp for any target containing C++ sources until there is a good reason not to.