Hi Rainer,

> On 28 Aug 2017, at 16:33, Rainer Orth <r...@cebitec.uni-bielefeld.de> wrote:
> 
> Hi Mike,
> 
>> On Aug 12, 2017, at 9:03 AM, Rainer Orth <r...@cebitec.uni-bielefeld.de> 
>> wrote:
>>> 
>>> The new gcc.dg/pie-static-[12].c testcases FAIL on several systems:
>>> 
>>> * Solaris 11.4 has PIE support, but lacks static libc, libm
>>> 
>>> * Linux without the static libc, libm installed
>>> 
>>> The following patch fixes this by requiring both PIE and -static
>>> support.
>>> 
>>> Tested with the appropriate runtest invocations on i386-pc-solaris2.11
>>> and x86_64-pc-linux-gnu (where the tests come up as UNSUPPORTED; I don't
>>> have a Linux system with static libc/libm installed), installed on
>>> mainline.
>>> 
>>> The tests also FAIL on Darwin/x86_64, but the failure mode is different:
>>> for -static, the executable is linked with -lcrt0.o (done this way to
>>> locate crt0.o in the linker's search path, cf. config/darwin.h
>>> (STARTFILE_SPEC)), but neither on Darwin 11 nor on Darwin 17 could I
>>> find where crt0.o would come from, so I've left this part alone.
>> 
>> darwin isn't exactly like other systems.  There is no crt0.o and static is
>> more special than you can imagine.  There was once 1 program that did a
>> static link, but one was exceptionally special.
>> 
>> Indeed, one way to implement it would be as a request option, and then
>> ignore the parts that don't make sense for the platform.  In that case,
>> -static-libgcc and friends might be the end semantics.
> 
> 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.

Iain

Iain Sandoe
CodeSourcery / Mentor Embedded / Siemens



Reply via email to