Skip to content

Commit

Permalink
gdb multi-arch v14.1
Browse files Browse the repository at this point in the history
Since it's now released! Can also drop our old patch for the segfault
issue on certain ARM backtraces 🙌

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.

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
.

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.
  • Loading branch information
noahp committed Dec 4, 2023
1 parent db39a2c commit ce4fd73
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 119 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -116,7 +116,7 @@ and download the "packages" artifact.
Unzip the packages.zip and then run:

```shell
PACKAGE=<package_name> anaconda upload **/$PACKAGE*.tar.bz2 --user memfault
PACKAGE=<package_name>; anaconda upload **/$PACKAGE*.tar.bz2 --user memfault
```

> Note: [Github actions cannot be run on Apple ARM VMs](https://github.com/actions/virtual-environments/issues/2187)
Expand Down
90 changes: 51 additions & 39 deletions gdb-multi-arch/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Loading

0 comments on commit ce4fd73

Please sign in to comment.