[PATCH] support: Use unwinder in links-dso-program-c only with libgcc_s
Frank Scheiner
frank.scheiner@web.de
Wed Mar 26 16:33:43 GMT 2025
Dear Florian,
On 26.03.25 16:36, Florian Weimer wrote:
> Do not build links-dso-program-c with exception (unwinding) support
> if libgcc_s is not available. In this case, the unwinder may be
> part of libgcc.a or libgcc_eh.a, depending on how GCC was built.
> If the unwinder is in libgcc_eh.a only, linking links-dso-program-c
> failed before this change. After this change, the exception
> handling landing pad is only generated if libgcc_s available,
> avoiding an undefined _Unwind_Resume (or equivalent) symbol
> reference in the non-libgcc_s case.
>
> Fixes commit ffd36cc27407003a6f9efcb9c16370e3435c5b1d ("support: Use
> unwinder in links-dso-program-c only with libgcc_s") and
> commit 5dfbc3c43ecc1bcfc760a032c91bb002660051bc ("support: Link
> links-dso-program-c with libgcc_s only if available").
This seems to break our cross-builds for ia64 with T2 and IIUC also any
cross builds in T2 for other architectures, starting with
ffd36cc27407003a6f9efcb9c16370e3435c5b1d, where two extra lines were
added to support/Makefile:
```
+CFLAGS-links-dso-program-c.c += -fexceptions
+LDLIBS-links-dso-program-c = -lgcc -lgcc_s $(libunwind)
```
Removing both lines after the changes made with
5dfbc3c43ecc1bcfc760a032c91bb002660051bc plus some extra
adapation (IIUC a different compiler is used during the configure
step than during the make step, requiring to inactivate:
```
ifeq ($(have-libgcc_s),yes)
LDLIBS-links-dso-program-c += -lgcc_s $(libunwind)
endif
```
..., too) makes it work again, the main issue
being the `-lgcc` and `-fexceptions` for the links-dso-program-c I
assume.
> Regarding testing:
>
> I verified that it works in our peculiar build environment, for a subset
> of build-many-glibcs.py targets (including arm-linux-gnueabi), and also
> for regular builds on RHEL 9 using system GCC 11. It seems the right
> thing to do as well.
Looking into CLFS ([1]), this (1) seems to first build a static cross
GCC, (2) then glibc with the static GCC and (3) only afterwards build a
full GCC that "will then be able to build executables that link against
the libraries" ([2]).
[1]: https://clfs.org/view/sysvinit/sparc64-64/cross-tools/chapter.html
[2]: https://clfs.org/view/sysvinit/sparc64-64/cross-tools/gcc-static.html
Is `-lgcc` supposed to work with a static (cross) compiler?
Cheers,
Frank
More information about the Libc-alpha
mailing list