Bug 52990 - bootstrap ia64 cross-compiler gcc (static C-only) includes a broken libgcc.a due to libunwind dependencies
Summary: bootstrap ia64 cross-compiler gcc (static C-only) includes a broken libgcc.a ...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2012-04-14 22:31 UTC by Mike Frysinger
Modified: 2021-08-16 23:21 UTC (History)
2 users (show)

See Also:
Host:
Target: ia64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Frysinger 2012-04-14 22:31:38 UTC
when building up a cross-compiler for ia64, we do:
 - install binutils
 - install kernel/C-library headers
 - build a static C-only gcc compiler
 - install glibc
 - try to link a static ELF -> failure

this is due to libgcc on ia64 being dependent on libunwind symbols.  when shared libs are disabled, the libgcc.a ends up referring to __libunwind_xxx symbols which aren't provided in the non-shared case.

specifically, we have:
 - ia64 forces t-unwind in config.gcc which adds -DUSE_LIBUNWIND_EXCEPTIONS
 - gcc/unwind-compat.c has a bunch of extern __libunwind_xxx decls
 - libgcc/Makefile.in adds unwind-compat.o to libgcc.a when enable_shared!=yes
 - gcc/config/ia64/unwind-ia64.c defines __libunwind_xxx aliases when SHARED
 - unwind-ia64.o is only added to libunwind.{a,so} and never libgcc.a

so, the end libgcc.a gets unwind-compat.o which refers to __libunwind_xxx, but doesn't get unwind-ia64.o which could possibly define them, and even if it did, the aliases aren't enabled for static objects.

looks like we could fix this in the t-glibc-libunwind file, when enable_shared is disabled, add the ia64 unwind objects to libgcc.a.  additionally, have unwind-ia64.c key off of not just SHARED but also STATIC_ONLY for declaring the symbols, and have the t-glibc-unwind file build unwind-ia64.o with that.
Comment 1 Thierry Reding 2012-08-24 08:43:16 UTC
I've seen this problem when building glibc as well. It tries to build
a number of utilities and link them against libgcc with the missing
symbols that you mentioned.

In the scripts that I use to build the toolchains, I was able to solve
this by adding a configparms file to the build directory that sets
"build-programs = no".

After the final gcc is built, libunwind is properly installed and can
at least be used for dynamically linked executables. I've also tested
that the resulting gcc can link static executables, though I'm not
able to execute because I lack the hardware.
Comment 2 Mike Frysinger 2012-08-24 15:41:11 UTC
(In reply to comment #1)

yes, the "build-programs = no" hack is also what i do.  from my tests in the past, the cross-compiler produced usable executables.

note, there is an ia64 simulator that you can boot an ia64 kernel + userland in to do testing (if you really want).

http://ski.sourceforge.net/
http://www.gelato.unsw.edu.au/IA64wiki/SkiSimulator