libgcc: IA64: don't compile glibc-based unwinder without libc headers

Message ID 20220407161221.4139013-1-slyich@gmail.com
State New
Headers
Series libgcc: IA64: don't compile glibc-based unwinder without libc headers |

Commit Message

Sergei Trofimovich April 7, 2022, 4:12 p.m. UTC
  From: Sergei Trofimovich <siarheit@google.com>

In --without-headers mode gcc fails to bootstrap on libgcc as:

    /build/build/./gcc/xgcc -B/build/build/./gcc/ ... -Dinhibit_libc -c fde-glibc.c
    ../../../gcc-12-20220403/libgcc/config/ia64/fde-glibc.c:33:10:
        fatal error: stdlib.h: No such file or directory

Most other linux targets are able to build the --without-headers
compiler without additional effort. This change adds IA64 to the fold.

The change drops part of the code that relies on DYNAMIC glibc
section traversal for backtraces.

Tested bootstrap of ia64-unknown-linux-gnu with and without libc
headers present.

libgcc/
	* config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode.
---
 libgcc/config/ia64/fde-glibc.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Richard Biener April 8, 2022, 6:26 a.m. UTC | #1
On Thu, Apr 7, 2022 at 6:13 PM Sergei Trofimovich via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> From: Sergei Trofimovich <siarheit@google.com>
>
> In --without-headers mode gcc fails to bootstrap on libgcc as:
>
>     /build/build/./gcc/xgcc -B/build/build/./gcc/ ... -Dinhibit_libc -c fde-glibc.c
>     ../../../gcc-12-20220403/libgcc/config/ia64/fde-glibc.c:33:10:
>         fatal error: stdlib.h: No such file or directory
>
> Most other linux targets are able to build the --without-headers
> compiler without additional effort. This change adds IA64 to the fold.
>
> The change drops part of the code that relies on DYNAMIC glibc
> section traversal for backtraces.
>
> Tested bootstrap of ia64-unknown-linux-gnu with and without libc
> headers present.

OK.

Thanks,
Richard.

> libgcc/
>         * config/ia64/fde-glibc.c: Make a no-op in inhibit_libc mode.
> ---
>  libgcc/config/ia64/fde-glibc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/libgcc/config/ia64/fde-glibc.c b/libgcc/config/ia64/fde-glibc.c
> index 9caac2bca24..bd74847fa85 100644
> --- a/libgcc/config/ia64/fde-glibc.c
> +++ b/libgcc/config/ia64/fde-glibc.c
> @@ -22,20 +22,21 @@
>     see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>     <http://www.gnu.org/licenses/>.  */
>
>  /* Locate the FDE entry for a given address, using glibc ld.so routines
>     to avoid register/deregister calls at DSO load/unload.  */
>
>  #ifndef _GNU_SOURCE
>  #define _GNU_SOURCE 1
>  #endif
>  #include "config.h"
> +#ifndef inhibit_libc
>  #include <stddef.h>
>  #include <stdlib.h>
>  #include <link.h>
>  #include "unwind-ia64.h"
>
>  #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) \
>      || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && !defined(DT_CONFIG))
>  # error You need GLIBC 2.2.4 or later on IA-64 Linux
>  #endif
>
> @@ -152,10 +153,11 @@ _Unwind_FindTableEntry (void *pc, unw_word *segment_base, unw_word *gp,
>    data.pc = (Elf64_Addr) pc;
>    data.segment_base = segment_base;
>    data.gp = gp;
>    data.ret = NULL;
>
>    if (dl_iterate_phdr (_Unwind_IteratePhdrCallback, &data) < 0)
>      return NULL;
>
>    return data.ret;
>  }
> +#endif
> --
> 2.35.1
>
  

Patch

diff --git a/libgcc/config/ia64/fde-glibc.c b/libgcc/config/ia64/fde-glibc.c
index 9caac2bca24..bd74847fa85 100644
--- a/libgcc/config/ia64/fde-glibc.c
+++ b/libgcc/config/ia64/fde-glibc.c
@@ -22,20 +22,21 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
 /* Locate the FDE entry for a given address, using glibc ld.so routines
    to avoid register/deregister calls at DSO load/unload.  */
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
 #include "config.h"
+#ifndef inhibit_libc
 #include <stddef.h>
 #include <stdlib.h>
 #include <link.h>
 #include "unwind-ia64.h"
 
 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2) \
     || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && !defined(DT_CONFIG))
 # error You need GLIBC 2.2.4 or later on IA-64 Linux
 #endif
 
@@ -152,10 +153,11 @@  _Unwind_FindTableEntry (void *pc, unw_word *segment_base, unw_word *gp,
   data.pc = (Elf64_Addr) pc;
   data.segment_base = segment_base;
   data.gp = gp;
   data.ret = NULL;
 
   if (dl_iterate_phdr (_Unwind_IteratePhdrCallback, &data) < 0)
     return NULL;
 
   return data.ret;
 }
+#endif