From a4d8c1a9d80a37a26377ee5b68183c4841b30328 Mon Sep 17 00:00:00 2001 From: Noah Pendleton <2538614+noahp@users.noreply.github.com> Date: Wed, 6 Dec 2023 14:11:50 -0500 Subject: [PATCH] gdb multi-arch v13.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I took the opportunity to rename the output binaries to have the `multi-arch-` prefix, because it's really confusing to me to have `gdb` not be native `gdb` when in a conda environment with this package installed. No longer need our ARM backtrace patch, it's now fixed in GDB upstream. Refreshed the `conda_build_config.yaml` to use the latest conda-build feedstock version at time of writing: ```bash ❯ curl -sSL https://github.com/conda-forge/conda-forge-pinning-feedstock/raw/main/recipe/conda_build_config.yaml > gdb-multi-arch/conda_build_config.yaml ``` Which is https://github.com/conda-forge/conda-forge-pinning-feedstock/blob/41ef3139dd637914a18f9609bf3d33a2f4780376/recipe/conda_build_config.yaml . This changes the supported + built python targets to: - 3.8 - 3.9 - 3.10 - 3.11 And include `readelf` in the package (`multi-arch-readelf`), since it can be pretty handy. Finally, `shfmt` the build script too since I'm in here. --- .github/workflows/build.yml | 4 +- README.md | 4 +- gdb-multi-arch/build.sh | 90 ++++++++------ gdb-multi-arch/conda_build_config.yaml | 115 +++++++++++------- gdb-multi-arch/fix-disassemble-segfault.patch | 25 ---- gdb-multi-arch/gdb-13.2.patch | 60 +++++++++ gdb-multi-arch/meta.yaml | 17 +-- 7 files changed, 197 insertions(+), 118 deletions(-) delete mode 100644 gdb-multi-arch/fix-disassemble-segfault.patch create mode 100644 gdb-multi-arch/gdb-13.2.patch diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 44b3164..96f0513 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,9 @@ jobs: name: 🛠️ build on ${{ matrix.platform }} strategy: - fail-fast: true + # let all jobs run to completion. the linux one may succeed when the mac + # fails (taking a completely random example scenario 😑) + fail-fast: false matrix: platform: [ubuntu-20.04, macos-11, macos-13-xlarge] # windows-2022] windows is a bit sad :'( runs-on: ${{ matrix.platform }} diff --git a/README.md b/README.md index 45e7c68..f5d2c96 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ To build any of the following packages (macOS and Linux Ubuntu 18.04 tested): ```bash # Create build environment -$ conda create -n build conda-build anaconda-client +$ conda create --name build --file environment.yml $ conda activate build # Build specific recipe @@ -116,7 +116,7 @@ and download the "packages" artifact. Unzip the packages.zip and then run: ```shell -PACKAGE= anaconda upload **/$PACKAGE*.tar.bz2 --user memfault +PACKAGE=; anaconda upload **/$PACKAGE*.conda --user memfault ``` > Note: [Github actions cannot be run on Apple ARM VMs](https://github.com/actions/virtual-environments/issues/2187) diff --git a/gdb-multi-arch/build.sh b/gdb-multi-arch/build.sh index 4fc780d..a050f2a 100644 --- a/gdb-multi-arch/build.sh +++ b/gdb-multi-arch/build.sh @@ -12,7 +12,7 @@ export REAL_TARGET_PREFIX="${PREFIX}/${REAL_TARGET}" export CPPFLAGS="$CPPFLAGS -fcommon -I$PREFIX/include -Wno-constant-logical-operand" export CFLAGS="$CFLAGS -Wno-constant-logical-operand -Wno-format-nonliteral -Wno-self-assign" -if [ `uname` == Darwin ]; then +if [ $(uname) == Darwin ]; then EXTRA_CONFIGURE_FLAGS="" else EXTRA_CONFIGURE_FLAGS="--with-debuginfod" @@ -21,27 +21,27 @@ fi # Setting /usr/lib/debug as debug dir makes it possible to debug the system's # python on most Linux distributions ./configure \ - --prefix="$FAKE_TARGET_PREFIX" \ - --target="$FAKE_TARGET" \ - --enable-targets=all \ - --with-separate-debug-dir="${FAKE_TARGET_PREFIX}/lib/debug:/usr/lib/debug" \ - --with-lzma \ - --with-expat \ - --with-libexpat-prefix="$PREFIX" \ - --with-libiconv-prefix="$PREFIX" \ - --without-guile \ - --without-libunwind-ia64 \ - --with-zlib \ - --without-babeltrace \ - --with-python="$PREFIX" \ - $EXTRA_CONFIGURE_FLAGS \ - --disable-ld \ - --disable-gprof \ - --disable-gas \ - --disable-sim \ - --disable-gold \ - --enable-64-bit-bfd -make + --prefix="$FAKE_TARGET_PREFIX" \ + --target="$FAKE_TARGET" \ + --enable-targets=all \ + --with-separate-debug-dir="${FAKE_TARGET_PREFIX}/lib/debug:/usr/lib/debug" \ + --with-lzma \ + --with-expat \ + --with-libexpat-prefix="$PREFIX" \ + --with-libiconv-prefix="$PREFIX" \ + --without-guile \ + --without-libunwind-ia64 \ + --with-zlib \ + --without-babeltrace \ + --with-python="$PREFIX" \ + $EXTRA_CONFIGURE_FLAGS \ + --disable-ld \ + --disable-gprof \ + --disable-gas \ + --disable-sim \ + --disable-gold \ + --enable-64-bit-bfd +make -j${CPU_COUNT} make install # Move from the fake to real directory @@ -50,26 +50,38 @@ mv "${FAKE_TARGET_PREFIX}" "${REAL_TARGET_PREFIX}" # Enable matching with ! (not) bash operator shopt -s extglob -# Delete every binary except addr2line, gdb, gdb-add-index, objcopy, objdump, and size. +# Delete most of the generated binaries like ld etc. Save gdb and its +# dependencies, and a few other very useful ones. pushd "${REAL_TARGET_PREFIX}"/bin/ - rm !(arm-elf-linux-addr2line|arm-elf-linux-gdb|arm-elf-linux-gdb-add-index|arm-elf-linux-objdump|arm-elf-linux-objcopy|arm-elf-linux-size|arm-elf-linux-strings) - mv arm-elf-linux-addr2line addr2line - mv arm-elf-linux-gdb gdb - mv arm-elf-linux-gdb-add-index gdb-add-index - mv arm-elf-linux-objcopy objcopy - mv arm-elf-linux-objdump objdump - mv arm-elf-linux-size size - mv arm-elf-linux-strings strings - strip addr2line - strip gdb - strip objdump - strip objcopy - strip size - strip strings -popd +# array +bins_to_keep=( + "addr2line" + "gdb" + "gdb-add-index" + "objcopy" + "objdump" + "readelf" + "size" + "strings" +) +# prefix with the original target name prefix +prefix_bins_to_keep="${bins_to_keep[*]/#/${FAKE_TARGET}-}" +# get all non-matching globs (thanks to extglob), for deletion +antiglob="!(${prefix_bins_to_keep// /|})" +rm ${antiglob} + +# Rename the binaries to the real target name prefix +for _x in "${bins_to_keep[@]}"; do + mv "${FAKE_TARGET}-${_x}" "${REAL_TARGET}-${_x}" + # don't strip "gdb-add-index", it's a shell script + if [[ ! "${REAL_TARGET}-${_x}" =~ "gdb-add-index" ]]; then + strip "${REAL_TARGET}-${_x}" + fi +done +popd # Symlink every binary from the build into /bin pushd "${PREFIX}"/bin - ln -s "${REAL_TARGET_PREFIX}"/bin/* ./ +ln -s "${REAL_TARGET_PREFIX}"/bin/* ./ popd diff --git a/gdb-multi-arch/conda_build_config.yaml b/gdb-multi-arch/conda_build_config.yaml index 1ce3b94..4135efc 100644 --- a/gdb-multi-arch/conda_build_config.yaml +++ b/gdb-multi-arch/conda_build_config.yaml @@ -1,3 +1,6 @@ +CONDA_BUILD_SYSROOT: + - /opt/MacOSX10.10.sdk # [osx and x86_64] + - /opt/MacOSX11.3.sdk # [osx and arm64] c_compiler: - gcc # [linux] - clang # [osx] @@ -152,6 +155,7 @@ zip_keys: - - arrow_cpp - libarrow + - libarrow_all # as of 4.23.x, libprotobuf requires patch-level run-exports; # we couple it with grpc (which very roughly releases in sync) # to reduce the migration pain for these two libs a bit. @@ -217,7 +221,7 @@ blas_impl: abseil_cpp: - '20220623.0' alsa_lib: - - 1.2.9 + - 1.2.10 antic: - 0.2 aom: @@ -225,23 +229,23 @@ aom: arb: - '2.23' arpack: - - 3.7 + - '3.8' # keep in sync with libarrow arrow_cpp: + - 14 # does not exist; switch to libarrow - 13 - 12 - 11.0.0 - - 10.0.1 assimp: - - 5.2.5 + - 5.3.1 attr: - 2.5 aws_c_auth: - - 0.7.4 + - 0.7.8 aws_c_cal: - - 0.6.2 + - 0.6.9 aws_c_common: - - 0.9.3 + - 0.9.10 aws_c_compression: - 0.2.17 # coupled to aws_c_common version bump, see @@ -249,27 +253,29 @@ aws_c_compression: aws_c_event_stream: - 0.3.2 aws_c_http: - - 0.7.13 + - 0.7.14 # the builds got coupled because 0.2.4 landed before the this migrator finished aws_c_io: - - 0.13.32 + - 0.13.36 # the builds got coupled because 0.2.4 landed before the io migrator aws_c_mqtt: - - 0.9.6 + - 0.9.10 aws_c_s3: - - 0.3.17 + - 0.4.3 aws_c_sdkutils: - 0.1.12 aws_checksums: - 0.1.17 aws_crt_cpp: - - 0.24.2 + - 0.24.9 aws_sdk_cpp: - - 1.11.156 + - 1.11.210 boost: - 1.78.0 boost_cpp: - 1.78.0 +bullet_cpp: + - 3.25 bzip2: - 1 c_ares: @@ -281,7 +287,7 @@ capnproto: ccr: - 1.3 cfitsio: - - 4.2.0 + - 4.3.0 coin_or_cbc: - 2.10 coincbc: @@ -339,7 +345,7 @@ gf2x: gdk_pixbuf: - 2 gnuradio_core: - - 3.10.7 + - 3.10.8 gnutls: - 3.7 gsl: @@ -380,7 +386,7 @@ google_cloud_cpp_common: googleapis_cpp: - '0.10' graphviz: - - '8' + - '9' # this has been renamed to libgrpc as of 1.49; dropped as of 1.52. # IOW, this version is unavailable; makes the renaming more obvious grpc_cpp: @@ -392,11 +398,11 @@ hdf4: hdf5: - 1.14.2 icu: - - '72' + - '73' imath: - 3.1.9 ipopt: - - 3.14.12 + - 3.14.13 isl: - '0.25' jasper: @@ -419,6 +425,8 @@ kealib: - '1.5' krb5: - '1.20' +ldas_tools_framecpp: + - '2.9' libabseil: - '20230802' libabseil_static: @@ -430,10 +438,16 @@ libarchive: # keep in sync with arrow_cpp (libarrow exists only from 10.x, # but make sure we have same length for zip as arrow_cpp) libarrow: + - 14 + - 13 + - 12 + - 11.0.0 +# only exists as of arrow v14, but needs to have same length as libarrow +libarrow_all: + - 14 - 13 - 12 - 11.0.0 - - 10.0.1 libavif: - '1.0.1' libblitz: @@ -460,6 +474,8 @@ libflatsurf: - 3 libflint: - '2.9' +libframel: + - '8.41' libgdal: - '3.7' libgit2: @@ -468,7 +484,7 @@ libgit2: libgoogle_cloud: - '2.12' libgrpc: - - '1.57' + - '1.58' libhugetlbfs: - 2 libhwy: @@ -484,13 +500,15 @@ libkml: libiio: - 0 libmatio: - - 1.5.23 + - 1.5.24 libmicrohttpd: - 0.9 libnetcdf: - 4.9.2 libopencv: - - 4.8.0 + - 4.8.1 +libopentelemetry_cpp: + - 1.12 libosqp: - 0.6.3 libpcap: @@ -498,9 +516,9 @@ libpcap: libpng: - 1.6 libprotobuf: - - 4.23.4 + - 4.24.3 libpq: - - 15 + - '16' libraw: - '0.21' librdkafka: @@ -524,6 +542,10 @@ libsvm: # keep libsqlite in sync with sqlite libsqlite: - 3 +libtensorflow: + - 2.14 +libtensorflow_cc: + - 2.14 libthrift: - 0.18.1 libtiff: @@ -559,7 +581,7 @@ metis: mimalloc: - 2.1.2 mkl: - - 2022 + - '2023' mkl_devel: - 2022 mpg123: @@ -587,8 +609,8 @@ netcdf_fortran: nettle: - '3.8' nodejs: + - '20' - '18' - - '16' nss: - 3 nspr: @@ -612,17 +634,15 @@ openblas: openexr: - '3.2' openh264: - - '2.3.1' + - 2.4.0 openjpeg: - '2' openmpi: - 4 openssl: - '3' -openturns: - - '1.20' orc: - - 1.9.0 + - 1.9.2 pango: - 1.50 pari: @@ -632,13 +652,15 @@ pcl: perl: - 5.32.1 petsc: - - '3.18' + - '3.20' petsc4py: - - '3.18' + - '3.20' +pugixml: + - '1.13' slepc: - - '3.18' + - '3.20' slepc4py: - - '3.18' + - '3.20' svt_av1: - 1.7.0 p11_kit: @@ -654,11 +676,11 @@ poco: poppler: - '23.07' postgresql: - - 15 + - '16' postgresql_plpython: - - 15 + - '16' proj: - - 9.2.1 + - 9.3.0 pulseaudio: - '16.1' pulseaudio_client: @@ -695,26 +717,29 @@ qt6_main: - '6.5' qtkeychain: - '0.14' +rdma_core: + - '48.0' re2: - - 2023.03.02 + - 2023.06.02 readline: - "8" rocksdb: - - '7.9' + - '8.0' root_base: - - 6.28.4 + - 6.28.10 ruby: - 2.5 - 2.6 r_base: - 4.1 # [win] - 4.2 # [not win] + - 4.3 # [not win] scotch: - 6.0.9 ptscotch: - 6.0.9 s2n: - - 1.3.54 + - 1.3.56 sdl2: - '2' sdl2_image: @@ -750,6 +775,8 @@ tbb: - '2021' tbb_devel: - '2021' +tensorflow: + - '2.14' thrift_cpp: - 0.18.1 tinyxml2: @@ -761,7 +788,7 @@ tiledb: ucx: - '1.15.0' uhd: - - 4.5.0 + - 4.6.0 urdfdom: - 3.1 vc: # [win] @@ -771,7 +798,7 @@ vlfeat: volk: - '3.0' vtk: - - 9.2.5 + - 9.2.6 wcslib: - '8' wxwidgets: @@ -787,7 +814,7 @@ xrootd: xz: - 5 zeromq: - - 4.3.4 + - '4.3.5' zfp: - 1.0 zlib: diff --git a/gdb-multi-arch/fix-disassemble-segfault.patch b/gdb-multi-arch/fix-disassemble-segfault.patch deleted file mode 100644 index 6be1475..0000000 --- a/gdb-multi-arch/fix-disassemble-segfault.patch +++ /dev/null @@ -1,25 +0,0 @@ -From f4d2522f60022dca9922193d960ff72c0ed4a7d4 Mon Sep 17 00:00:00 2001 -From: Tyler Hoffman -Date: Fri, 22 Jul 2022 14:38:56 -0700 -Subject: [PATCH] Fix disassemble segfault - check symtab size - ---- - opcodes/arm-dis.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c -index 92cd098d6c..c0789c4e1b 100644 ---- a/opcodes/arm-dis.c -+++ b/opcodes/arm-dis.c -@@ -11846,7 +11846,7 @@ mapping_symbol_for_insn (bfd_vma pc, struct disassemble_info *info, - type = MAP_ARM; - struct arm_private_data *private_data; - -- if (info->private_data == NULL -+ if (info->private_data == NULL || info->symtab_size == 0 - || bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour) - return false; - --- -2.36.0 - diff --git a/gdb-multi-arch/gdb-13.2.patch b/gdb-multi-arch/gdb-13.2.patch new file mode 100644 index 0000000..bd4e73f --- /dev/null +++ b/gdb-multi-arch/gdb-13.2.patch @@ -0,0 +1,60 @@ +From 8c8c33795685e1a66ee17b0e232dbc85c8f236b6 Mon Sep 17 00:00:00 2001 +From: Noah Pendleton <2538614+noahp@users.noreply.github.com> +Date: Wed, 6 Dec 2023 14:10:40 -0500 +Subject: [PATCH] Compilation unit sets multiple DW_AT_language + +GDB will try to set a fallback language if the DW_AT_language field is +missing from the DWARF CU, but will crash if it's already been set to a +different value for this CU :/ Not super ideal. This only occurs on +pathalogical ELFs but does occur in real life, so replace the crash with +a warning and continue processing. + +A second change is to disable warnings added in this change: + +https://github.com/bminor/binutils-gdb/commit/834eaf9201c18efc5b888f3cd116dd7856bec759 + +They are inserted into the backtrace, for example: + +``` + #2 0x01018bf0 in memfault_fault_handling_assert (pc=0x101885b , lr=warning: (Internal error: pc 0x0 in read in CU, but not in symtab.) +warning: (Error: pc 0x0 in address map, but not in symtab.) +``` + +Which is not desirable. +--- + gdb/dwarf2/read.h | 5 +++++ + gdb/symtab.c | 2 +- + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h +index 9dfc435e861..f75cfc52dfd 100644 +--- a/gdb/dwarf2/read.h ++++ b/gdb/dwarf2/read.h +@@ -369,6 +369,11 @@ struct dwarf2_per_cu_data + nope = lang; + if (m_lang.compare_exchange_strong (nope, lang)) + return; ++ /* unfortunately the below warning is captured in the output for gdb.execute, so leave it off*/ ++ /* log a warning, including the expected nope vs desired lang*/ ++ /* warning(_("DWARF error: conflicting language information in compilation unit header: %d/%d"), ++ nope, lang); */ ++ return; + gdb_assert_not_reached (); + } + +diff --git a/gdb/symtab.c b/gdb/symtab.c +index e9bc7b2c933..46219035569 100644 +--- a/gdb/symtab.c ++++ b/gdb/symtab.c +@@ -2930,7 +2930,7 @@ find_pc_sect_compunit_symtab (CORE_ADDR pc, struct obj_section *section) + for (objfile *objf : current_program_space->objfiles ()) + { + struct compunit_symtab *result +- = objf->find_pc_sect_compunit_symtab (msymbol, pc, section, 1); ++ = objf->find_pc_sect_compunit_symtab (msymbol, pc, section, /* memfault changed from 1 */ 0); + if (result != NULL) + return result; + } +-- +2.40.1 + diff --git a/gdb-multi-arch/meta.yaml b/gdb-multi-arch/meta.yaml index 9fa5acb..08f6600 100644 --- a/gdb-multi-arch/meta.yaml +++ b/gdb-multi-arch/meta.yaml @@ -1,21 +1,24 @@ {% set name = "multi-arch-gdb" %} -{% set version = "12.1" %} -{% set sha256 = "417718b5348fe026f3e4d9c36bf4c6645083e58cb6ac2b8ffc467030be2d6b88" %} +{% set version = "13.2" %} +{% set sha256 = "14f3ebf8fe6ce0156b217dc62de0ce373d7b42520c647befdab48f377de31e31" %} package: name: {{ name }} - version: {{ version }}.memfault1 + version: {{ version }}.memfault0 source: - url: https://github.com/bminor/binutils-gdb/archive/gdb-{{ version }}-release.tar.gz sha256: {{ sha256 }} patches: - - fix-disassemble-segfault.patch # mac doesn't build without this patch - mac-build-fix.patch # [osx] + # work around some changes from gdb 12.1 -> 13.2 that cause undesirable + # output + - gdb-13.2.patch + build: - number: '3' + number: '0' skip: True # [win] requirements: @@ -24,7 +27,7 @@ requirements: - {{ compiler('c') }} # [linux] - {{ compiler('cxx') }} # [linux] - make - - bison # [linux] + - bison host: - python {{ python }} - texinfo @@ -51,7 +54,7 @@ requirements: test: commands: - - gdb -ex "print 1" --batch + - multi-arch-gdb -ex "print 1" --batch about: home: https://www.gnu.org/software/gdb/