This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [testsuite, i386] Require -static support in gcc.dg/pie-static-[12].c (PR testsuite/81793)
Hi Iain,
>> All this begs the question why on earth would darwin.h (STARTFILE_SPEC)
>> accept -static and try to link libcrt0.o it the latter doesn't exist.
>>
>> However, I've just found that the bundled clang on Darwin 11 does the
>> same (and fails in the same way: "ld: library not found for -lcrt0.o”).
>
> I think it’s because when one is bringing up the system, then one does (or
> at least used to) have a static libc/crt set.
> Thus the compiler did/does need to support it for that case. I’ve not done
> a kernel bootstrap since ≈ Darwin9 era, so things might have changed and
> this could be history leaking through.
I've now found the following statement:
https://developer.apple.com/library/content/qa/qa1118/_index.html
effectively declaring statically linked binaries unsupported (same as
newer Solaris versions do, btw.).
I've now checked clang from Darwin 17 (Xcode 9 Beta) and it behaves the
same. I've found the following in clang sources
} else {
if (Args.hasArg(options::OPT_static) ||
Args.hasArg(options::OPT_object) ||
Args.hasArg(options::OPT_preload)) {
CmdArgs.push_back("-lcrt0.o");
in lib/Driver/ToolChains/Darwin.cpp (Darwin::addStartObjectFileArgs).
Several comments seem to indicate that most of this is just a
straightforward translation of GCC's Darwin specs to C++ ;-)
Overall, mostly a historical artifact these days, it seems.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University