int main(int argc, char **argv)
{
return 0;
}
I cross compile (host= linux x86_64, target= linux aarch64)
/path/to/clang --target=aar
Clang does not come with a linker, it relies on ld
instead. And ld
depends on libgcc.a
and/or libgcc.so
on your system (regardless this is the LLVM linker ld.lld
or GNU ld). This is the reason why you have this error message.
So the answer is actually:
(a) the linker requires libgcc to do its own linking work
A lot more details on this are available here at omniprog.info:
If we want to get rid of GCC and use clang as our default compiler on the system, we may have to make some adjustments on some RPM-based systems. Clang does not provide a linker, but relies on the system's linker, typically ld, to link executables. This is the case even on FreeBSD and Mac OS X systems where Clang is the default compiler. We can see this using the -v option to clang++. Now, ld won't work without the following files:
libgcc.a
libgcc_s.so
[...]