On Sun, 28 Apr 2024, 11:24 Gerald Pfeifer, <ger...@pfeifer.com> wrote:

> Hi Jonathan,
>
> On Fri, 26 Apr 2024, Jonathan Wakely wrote:
> > How are you testing on FreeBSD?
> >
> > When I build GCC trunk on FreeBSD 14.0 and try to run the libstdc++
> > testsuite it fails due to lots of these errors:
> >
> > Excess errors:
> > /usr/local/bin/ld: /tmp//ccev946q.o: relocation R_X86_64_32 against
> > symbol `_ZTIN10__cxxabiv115__forced_unwindE@@CXXABI_1.3.2' can not be
> > used when making a PDE object; recompile with -fPIE
> > /usr/local/bin/ld: failed to set dynamic section sizes: bad value
>
> my first reaction was to recommend using binutils instead of /usr/bin/ld
> which is LLD 16.0.6 or similar (since a while ago FreeBSD switched to that
> toolchain as part of the base system).
>
> My nightly tester has been using GNU ld since
>
>   # 2012-03-11  Configure using --with-as=$localbase/bin/as and
>   #             --with-ld=$localbase/bin/ld on *.freebsd.org.
>
> in the script invoked by cron, even before FreeBSD made that switch.
>
> Seeing /usr/local/bin/ld in the error message it appears you are doing
> that already, though?
>

Yes, I'm using GNU ld.

On IRC Andreas suggested that also using GNU objdump would solve my issue,
but I haven't tried yet.



> > Which suggests that -fPIE is missing from the default test flags.
> >
> > Have you seen this? Do you do something locally to work around it?
>
> All I have in terms of adjustments to the FreeBSD systems I build on via
> that script are the following
>
>   CONFIGUREFLAGS="--with-gmp=$LOCALBASE --with-as=$LOCALBASE/bin/as
> $CONFIGUREFLAGS"
>   LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LOCALBASE/lib
>   PATH=$LOCALBASE/bin:$PATH
>
> where LOCALBASE looks like it would be /usr/local in your case. Nothing
> explicit around PIE there.
>
> Looking at the logs of a serialized build I triggered manually where I
> remove the --with-ld configure option, I see
>
>   checking linker PIE support with copy reloc... no
>   checking for -fno-PIE option... yes
>   checking for -no-pie option... yes
>
> and then build invocations like
>
>   c++ -std=c++11  -fno-PIE -c ...
>
> during all-stage1-target-libgcc which ultimately fails with - mystery?! -
>
>   ld: error: unable to find library -lc
>   collect2: error: ld returned 1 exit status
>   gmake[3]: *** [Makefile:1005: libgcc_s.so] Error 1
>
> (Disclaimer: all my tests on FreeBSD 13.2, not FreeBSD 14 as in your
> case.)
>
>
> Looking at the lang/gcc* ports that I maintained for two decades until
> Lorenzo (copied now) kindly took them over two years ago I see the
> following change among others for newer versions:
>
>   % git show b6a5871a0cf40
>   commit b6a5871a0cf40dfc194217704e2dc03e2e91fb62
>   Author: Lorenzo Salvadore <salvad...@freebsd.org>
>   Date:   Fri Feb 3 20:12:49 2023 +0100
>
>     lang/gcc10: Mark PIE_UNSAFE
>
>     Building the port with WITH_PIE fails if the BOOTSTRAP option is
>     enabled. Mark PIE_UNSAFE when this option is enabled until a better
>     solution is found.
>
>     PR:             268901
>
> where https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268901 is the PR
> referenced.
>
> PIE_UNSAFE=yes in a port's Makefile (the equivalent to a spec file in RPM
> land) is used as follows in ports/Mk/Features/pie.mk:
>
>   .  if !defined(PIE_UNSAFE)
>   PIE_CFLAGS?=    -fPIE -fPIC
>   CFLAGS+=        ${PIE_CFLAGS}
>   CXXFLAGS+=      ${PIE_CFLAGS}
>   LDFLAGS+=       -pie
>   STATIC_PIE_ARGS+=       -static-pie
>   .  endif
>
>
> You are not using the Ports Infrastructure, I believe, so the above does
> not directly apply, may provide some additional background, though?
>
>
> Hope this helps - and please chime in Lorenzo and Andreas!
>
> Gerald
>

Reply via email to