[Git][ghc/ghc][wip/symbolizer] rts: remove libbfd logic
Cheng Shao pushed to branch wip/symbolizer at Glasgow Haskell Compiler / GHC Commits: 237b7508 by Cheng Shao at 2025-07-04T21:04:36+00:00 rts: remove libbfd logic - - - - - 9 changed files: - configure.ac - hadrian/cfg/system.config.in - hadrian/src/Oracles/Flag.hs - hadrian/src/Settings/Packages.hs - − m4/fp_bfd_support.m4 - rts/Printer.c - rts/configure.ac - rts/include/rts/Config.h - rts/rts.cabal Changes: ===================================== configure.ac ===================================== @@ -868,9 +868,6 @@ AC_SUBST([UseLibm]) TargetHasLibm=$UseLibm AC_SUBST(TargetHasLibm) -FP_BFD_FLAG -AC_SUBST([UseLibbfd]) - dnl ################################################################ dnl Check for libraries dnl ################################################################ ===================================== hadrian/cfg/system.config.in ===================================== @@ -120,7 +120,6 @@ use-lib-numa = @UseLibNuma@ use-lib-m = @UseLibm@ use-lib-rt = @UseLibrt@ use-lib-dl = @UseLibdl@ -use-lib-bfd = @UseLibbfd@ use-lib-pthread = @UseLibpthread@ need-libatomic = @NeedLibatomic@ ===================================== hadrian/src/Oracles/Flag.hs ===================================== @@ -37,7 +37,6 @@ data Flag = CrossCompiling | UseLibm | UseLibrt | UseLibdl - | UseLibbfd | UseLibpthread | NeedLibatomic | UseGhcToolchain @@ -61,7 +60,6 @@ flag f = do UseLibm -> "use-lib-m" UseLibrt -> "use-lib-rt" UseLibdl -> "use-lib-dl" - UseLibbfd -> "use-lib-bfd" UseLibpthread -> "use-lib-pthread" NeedLibatomic -> "need-libatomic" UseGhcToolchain -> "use-ghc-toolchain" ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -440,7 +440,6 @@ rtsPackageArgs = package rts ? do , useSystemFfi `cabalFlag` "use-system-libffi" , useLibffiForAdjustors `cabalFlag` "libffi-adjustors" , flag UseLibpthread `cabalFlag` "need-pthread" - , flag UseLibbfd `cabalFlag` "libbfd" , flag NeedLibatomic `cabalFlag` "need-atomic" , flag UseLibdw `cabalFlag` "libdw" , flag UseLibnuma `cabalFlag` "libnuma" ===================================== m4/fp_bfd_support.m4 deleted ===================================== @@ -1,59 +0,0 @@ -# FP_BFD_SUPPORT() -# ---------------------- -# Whether to use libbfd for debugging RTS -# -# Sets: -# UseLibbfd: [YES|NO] -AC_DEFUN([FP_BFD_FLAG], [ - UseLibbfd=NO - AC_ARG_ENABLE(bfd-debug, - [AS_HELP_STRING([--enable-bfd-debug], - [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])], - [UseLibbfd=YES], - [UseLibbfd=NO]) -]) - -# FP_WHEN_ENABLED_BFD -# ---------------------- -# Checks for libraries in the default way, which will define various -# `HAVE_*` macros. -AC_DEFUN([FP_WHEN_ENABLED_BFD], [ - # don't pollute general LIBS environment - save_LIBS="$LIBS" - AC_CHECK_HEADERS([bfd.h]) - dnl ** check whether this machine has BFD and libiberty installed (used for debugging) - dnl the order of these tests matters: bfd needs libiberty - AC_CHECK_LIB(iberty, xmalloc) - dnl 'bfd_init' is a rare non-macro in libbfd - AC_CHECK_LIB(bfd, bfd_init) - - AC_LINK_IFELSE( - [AC_LANG_PROGRAM( - [[#include <bfd.h>]], - [[ - /* mimic our rts/Printer.c */ - bfd* abfd; - const char * name; - char **matching; - - name = "some.executable"; - bfd_init(); - abfd = bfd_openr(name, "default"); - bfd_check_format_matches (abfd, bfd_object, &matching); - { - long storage_needed; - storage_needed = bfd_get_symtab_upper_bound (abfd); - } - { - asymbol **symbol_table; - long number_of_symbols; - symbol_info info; - - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - bfd_get_symbol_info(abfd,symbol_table[0],&info); - } - ]])], - [], dnl bfd seems to work - [AC_MSG_ERROR([can't use 'bfd' library])]) - LIBS="$save_LIBS" -]) ===================================== rts/Printer.c ===================================== @@ -872,110 +872,11 @@ const char *lookupGHCName( void *addr ) * Symbol table loading * ------------------------------------------------------------------------*/ -/* Causing linking trouble on Win32 plats, so I'm - disabling this for now. -*/ -#if defined(USING_LIBBFD) -# define PACKAGE 1 -# define PACKAGE_VERSION 1 -/* Those PACKAGE_* defines are workarounds for bfd: - * https://sourceware.org/bugzilla/show_bug.cgi?id=14243 - * ghc's build system filter PACKAGE_* values out specifically to avoid clashes - * with user's autoconf-based Cabal packages. - * It's a shame <bfd.h> checks for unrelated fields instead of actually used - * macros. - */ -# include <bfd.h> - -/* Fairly ad-hoc piece of code that seems to filter out a lot of - * rubbish like the obj-splitting symbols - */ - -static bool isReal( flagword flags STG_UNUSED, const char *name ) -{ -#if 0 - /* ToDo: make this work on BFD */ - int tp = type & N_TYPE; - if (tp == N_TEXT || tp == N_DATA) { - return (name[0] == '_' && name[1] != '_'); - } else { - return false; - } -#else - if (*name == '\0' || - (name[0] == 'g' && name[1] == 'c' && name[2] == 'c') || - (name[0] == 'c' && name[1] == 'c' && name[2] == '.')) { - return false; - } - return true; -#endif -} - -extern void DEBUG_LoadSymbols( const char *name ) -{ - bfd* abfd; - char **matching; - - bfd_init(); - abfd = bfd_openr(name, "default"); - if (abfd == NULL) { - barf("can't open executable %s to get symbol table", name); - } - if (!bfd_check_format_matches (abfd, bfd_object, &matching)) { - barf("mismatch"); - } - - { - long storage_needed; - asymbol **symbol_table; - long number_of_symbols; - long num_real_syms = 0; - long i; - - storage_needed = bfd_get_symtab_upper_bound (abfd); - - if (storage_needed < 0) { - barf("can't read symbol table"); - } - symbol_table = (asymbol **) stgMallocBytes(storage_needed,"DEBUG_LoadSymbols"); - - number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table); - - if (number_of_symbols < 0) { - barf("can't canonicalise symbol table"); - } - - if (add_to_fname_table == NULL) - add_to_fname_table = allocHashTable(); - - for( i = 0; i != number_of_symbols; ++i ) { - symbol_info info; - bfd_get_symbol_info(abfd,symbol_table[i],&info); - if (isReal(info.type, info.name)) { - insertHashTable(add_to_fname_table, - info.value, (void*)info.name); - num_real_syms += 1; - } - } - - IF_DEBUG(interpreter, - debugBelch("Loaded %ld symbols. Of which %ld are real symbols\n", - number_of_symbols, num_real_syms) - ); - - stgFree(symbol_table); - } -} - -#else /* USING_LIBBFD */ - extern void DEBUG_LoadSymbols( const char *name STG_UNUSED ) { /* nothing, yet */ } -#endif /* USING_LIBBFD */ - void findPtr(P_ p, int); /* keep gcc -Wall happy */ int searched = 0; ===================================== rts/configure.ac ===================================== @@ -171,8 +171,6 @@ AS_IF( [test "$CABAL_FLAG_libm" = 1], [AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])]) -AS_IF([test "$CABAL_FLAG_libbfd" = 1], [FP_WHEN_ENABLED_BFD]) - dnl ################################################################ dnl Check for libraries dnl ################################################################ ===================================== rts/include/rts/Config.h ===================================== @@ -19,13 +19,6 @@ #error TICKY_TICKY is incompatible with THREADED_RTS #endif -/* - * Whether the runtime system will use libbfd for debugging purposes. - */ -#if defined(DEBUG) && defined(HAVE_BFD_H) && defined(HAVE_LIBBFD) && !defined(_WIN32) -#define USING_LIBBFD 1 -#endif - /* * We previously only offer the eventlog in a subset of RTS ways; we now * enable it unconditionally to simplify packaging. See #18948. @@ -101,4 +94,3 @@ code. #else #define CACHELINE_SIZE 64 #endif - ===================================== rts/rts.cabal ===================================== @@ -46,9 +46,6 @@ flag libffi-adjustors flag need-pthread default: False manual: True -flag libbfd - default: False - manual: True flag need-atomic default: False manual: True @@ -250,9 +247,6 @@ library if flag(need-atomic) -- for sub-word-sized atomic operations (#19119) extra-libraries: atomic - if flag(libbfd) - -- for debugging - extra-libraries: bfd iberty if flag(libdw) -- for backtraces extra-libraries: elf dw View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/237b750831434016450e320ff6e2462c... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/237b750831434016450e320ff6e2462c... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Cheng Shao (@TerrorJack)