Why does clang still need libgcc.a to compile my code?

前端 未结 3 1978
情书的邮戳
情书的邮戳 2021-02-07 12:21
int main(int argc, char **argv)
{
    return 0;
}

I cross compile (host= linux x86_64, target= linux aarch64)

/path/to/clang --target=aar

3条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-07 13:01

    You must compile with the option -nodefaultlib or -nostdlibs.

    Here a quote from GCC documentation (clang interface is just the same):

    One of the standard libraries bypassed by -nostdlib and -nodefaultlibs is libgcc.a, a library of internal subroutines which GCC uses to overcome shortcomings of particular machines, or special needs for some languages.

    You may have to execute c++ static initialization routines and/or use what is provided by the object files crt.o in the lib directory. These files are part of libc and provides executable entry point.

提交回复
热议问题