Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Jan 2025 10:42:25 -0800
From:      Steve Kargl <sgk@troutmask.apl.washington.edu>
To:        Dimitry Andric <dim@freebsd.org>
Cc:        Konstantin Belousov <kostikbel@gmail.com>, freebsd-hackers@freebsd.org
Subject:   Re: gcc14 static linking ends with segfault
Message-ID:  <Z5fTkXmqr1MZKk8d@troutmask.apl.washington.edu>
In-Reply-To: <C09215C1-ABF0-4248-A69A-F0137BBC7E2B@FreeBSD.org>
References:  <Z5aYNdVQdGdVImBG@troutmask.apl.washington.edu> <Z5cRe8tivqpgme1I@kib.kiev.ua> <Z5cnYyWxcT5pk1Wf@troutmask.apl.washington.edu> <C09215C1-ABF0-4248-A69A-F0137BBC7E2B@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

On Mon, Jan 27, 2025 at 04:34:22PM +0100, Dimitry Andric wrote:
>     /usr/lib/crt1.o \
>     /usr/lib/crti.o \
>     /usr/lib/crtbeginT.o \
(...)
>     /usr/local/lib/gcc13/gcc/x86_64-portbld-freebsd15.0/13.3.0/crtend.o \
>     /usr/lib/crtn.o
> 


> 
> Summarizing, I think that it is weird that gcc doesn't use its own
> crtbegin object, at least for static linking. There may be some
> historical reason for it, but it should then also not use its own crtend
> object!

Not sure about a historical reason, but gcc14 seems to not 
supply crt1.o, crt1.o, crtbeginT.o, ot crtn.o.  Thus, the
linker is picking up those files from /usr/lib.

% find /usr/local/lib/gcc14/ -name crt\*.o
/usr/local/lib/gcc14/gcc/x86_64-portbld-freebsd15.0/14.2.0/crtbegin.o
/usr/local/lib/gcc14/gcc/x86_64-portbld-freebsd15.0/14.2.0/crtend.o
/usr/local/lib/gcc14/gcc/x86_64-portbld-freebsd15.0/14.2.0/crtbeginS.o
/usr/local/lib/gcc14/gcc/x86_64-portbld-freebsd15.0/14.2.0/crtendS.o

If I move gcc14/.../crtend.o out of the way, then the segfault goes away
as the linker shows

 -V -Bstatic -o z
 /usr/lib/crt1.o
 /usr/lib/crti.o
 /usr/lib/crtbeginT.o
...
 /usr/lib/crtend.o
 /usr/lib/crtn.o

-- 
Steve


help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Z5fTkXmqr1MZKk8d>