Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Homebrew avr-gdb build broken on macOS #343

Open
second-string opened this issue Sep 5, 2024 · 6 comments
Open

Homebrew avr-gdb build broken on macOS #343

second-string opened this issue Sep 5, 2024 · 6 comments

Comments

@second-string
Copy link

On macOS Sonoma 14.6.1, M1 MacBook Pro, I cannot build/install avr-gdb from home-brew.

I have successfully installed the main toolchain with brew install avr-gcc. When executing brew install avr-gdb, all of the home-brew dependencies download and update correctly, but I get an error in the final make call of the build.

[2726] <name>@<name>-mbp /opt/.../avr-gcc@9/9.4.0_1 (stable) $ brew install avr-gdb
==> Fetching dependencies for osx-cross/avr/avr-gdb: python@3.9 and texinfo
==> Fetching python@3.9
==> Downloading https://ghcr.io/v2/homebrew/core/python/3.9/manifests/3.9.19_1
Already downloaded: /Users/<name>/Library/Caches/Homebrew/downloads/7d5ecae27ba7a9eff93afb08c5f49da947202b856cdabac33980ebd081994385--python@3.9-3.9.19_1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/python/3.9/blobs/sha256:57f58fe8682f4dbcf39f5f4f1cedb0c7ce6f75275d7325fb1b314f9574d4842f
Already downloaded: /Users/<name>/Library/Caches/Homebrew/downloads/2c992d968f3e8100adf8ca65cf211112246e0370dcd6772453e1309620d23e07--python@3.9--3.9.19_1.arm64_sonoma.bottle.tar.gz
==> Fetching texinfo
==> Downloading https://ghcr.io/v2/homebrew/core/texinfo/manifests/7.1
Already downloaded: /Users/<name>/Library/Caches/Homebrew/downloads/a6ba99ebaacd398154745b25484544963ff1b229ee0e853ecb3e17f744c69f76--texinfo-7.1.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/texinfo/blobs/sha256:6ee1d5c2e64d80dcc8da4639d55d6c7a907550efd3ecfb4757f719f875e3df1b
Already downloaded: /Users/<name>/Library/Caches/Homebrew/downloads/2b03b8291213a3c1ceaef53f7e68a68b63b2657f298040e58423d760b6400f9d--texinfo--7.1.arm64_sonoma.bottle.tar.gz
==> Fetching osx-cross/avr/avr-gdb
==> Downloading https://raw.githubusercontent.com/osx-cross/homebrew-avr/18d50ba2a168a3b90a25c96e4bc4c053df77d7dc/Patch/avr-binutils-elf-bfd-gdb-fix.patch
######################################################################################################################################################################################################################################################### 100.0%
==> Downloading https://ftp.gnu.org/gnu/gdb/gdb-10.1.tar.xz
Already downloaded: /Users/<name>/Library/Caches/Homebrew/downloads/d6dfd55ca620ab89b3209b96be8cac6a9b85c636faf527f4c5e4bc7e7ff07cee--gdb-10.1.tar.xz
==> Installing avr-gdb from osx-cross/avr
==> Installing dependencies for osx-cross/avr/avr-gdb: python@3.9 and texinfo
==> Installing osx-cross/avr/avr-gdb dependency: python@3.9
==> Downloading https://ghcr.io/v2/homebrew/core/python/3.9/manifests/3.9.19_1
Already downloaded: /Users/<name>/Library/Caches/Homebrew/downloads/7d5ecae27ba7a9eff93afb08c5f49da947202b856cdabac33980ebd081994385--python@3.9-3.9.19_1.bottle_manifest.json
==> Pouring python@3.9--3.9.19_1.arm64_sonoma.bottle.tar.gz
==> /opt/homebrew/Cellar/python@3.9/3.9.19_1/bin/python3.9 -Im ensurepip
==> /opt/homebrew/Cellar/python@3.9/3.9.19_1/bin/python3.9 -Im pip install -v --no-index --upgrade --isolated --target=/opt/homebrew/lib/python3.9/site-packages /opt/homebrew/Cellar/python@3.9/3.9.19_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ensurepip/_bun
🍺  /opt/homebrew/Cellar/python@3.9/3.9.19_1: 3,068 files, 56.7MB
==> Installing osx-cross/avr/avr-gdb dependency: texinfo
==> Downloading https://ghcr.io/v2/homebrew/core/texinfo/manifests/7.1
Already downloaded: /Users/<name>/Library/Caches/Homebrew/downloads/a6ba99ebaacd398154745b25484544963ff1b229ee0e853ecb3e17f744c69f76--texinfo-7.1.bottle_manifest.json
==> Pouring texinfo--7.1.arm64_sonoma.bottle.tar.gz
🍺  /opt/homebrew/Cellar/texinfo/7.1: 494 files, 9.1MB
==> Installing osx-cross/avr/avr-gdb
==> Patching
==> Applying avr-binutils-elf-bfd-gdb-fix.patch
patching file 'bfd/elf-bfd.h'
==> ../configure --target=avr --prefix=/opt/homebrew/Cellar/avr-gdb/10.1 --disable-debug --disable-dependency-tracking --disable-binutils --disable-nls --disable-libssp --disable-install-libbfd --disable-install-libiberty --with-python=/opt/homebrew/opt/python@3.9/bin/py
==> make
Last 15 lines from /Users/<name>/Library/Logs/Homebrew/avr-gdb/02.make:
4 errors generated.
make[2]: *** [ada-exp.o] Error 1
3 errors generated.
make[2]: *** [ada-tasks.o] Error 1
In file included from ../../gdb/addrmap.c:20:
In file included from ../../gdb/defs.h:65:
../../gdb/../gdbsupport/enum-flags.h:85:52: error: integer value -1 is outside the valid range of values [0, 15] for this enumeration type [-Wenum-constexpr-conversion]
    integer_for_size<sizeof (T), static_cast<bool>(T (-1) < T (0))>::type
                                                   ^
1 error generated.
make[2]: *** [addrmap.o] Error 1
4 errors generated.
make[2]: *** [ada-lang.o] Error 1
make[1]: *** [all-gdb] Error 2
make: *** [all] Error 2

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/osx-cross/homebrew-avr/issues
@second-string
Copy link
Author

...I'm not downloading a random file and compiling something from a bitly link. Given the fact that you posted this 1 minute after me I'm assuming this is bot spam

@WalderlanSena
Copy link

Same problem !

@jeffdech
Copy link

jeffdech commented Sep 15, 2024

I get the same issue with slightly different errors. This is on a 2023 MacBook Pro M3 Max, Sonoma 14.6.1

❯ brew install avr-gdb (base)
==> Fetching osx-cross/avr/avr-gdb
==> Downloading https://raw.githubusercontent.com/osx-cross/homebrew-avr/18d50ba2a168a3b90a25c96e4bc4c053df77d7dc/Patch/av
Already downloaded: /Users/jefferydech/Library/Caches/Homebrew/downloads/0ca5d8e65886bc674f0ba0ec9f98e4b657920f87f9784a16f9fca756681475b3--avr-binutils-elf-bfd-gdb-fix.patch
==> Downloading https://ftp.gnu.org/gnu/gdb/gdb-10.1.tar.xz
Already downloaded: /Users/jefferydech/Library/Caches/Homebrew/downloads/d6dfd55ca620ab89b3209b96be8cac6a9b85c636faf527f4c5e4bc7e7ff07cee--gdb-10.1.tar.xz
==> Installing avr-gdb from osx-cross/avr
==> Patching
==> Applying avr-binutils-elf-bfd-gdb-fix.patch
patching file 'bfd/elf-bfd.h'
==> ../configure --target=avr --prefix=/opt/homebrew/Cellar/avr-gdb/10.1 --disable-debug --disable-dependency-tracking --d
==> make
Last 15 lines from /Users/jefferydech/Library/Logs/Homebrew/avr-gdb/02.make:
make[2]: *** [arch-utils.o] Error 1
3 errors generated.
4 errors generated.
make[2]: *** [ada-tasks.o] Error 1
make[2]: *** [ada-exp.o] Error 1
3 errors generated.
make[2]: *** [annotate.o] Error 1
3 errors generated.
make[2]: *** [auto-load.o] Error 1
3 errors generated.
make[2]: *** [auxv.o] Error 1
4 errors generated.
make[2]: *** [ada-lang.o] Error 1
make[1]: *** [all-gdb] Error 2
make: *** [all] Error 2

If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
https://github.com/osx-cross/homebrew-avr/issues

These open issues may also help:
Homebrew avr-gdb build broken on macOS #343

@jeffdech
Copy link

Looks like this is a known issue with gdb that was patched for gdb 13.2. Also see mention of a workaround by ignoring -Wenum-constexpr-conversion.

Unfortunately, I'm not savvy enough with this stuff to modify the Makefile to do the ignore and test it. Happy to help any way I can though.

@reillylm
Copy link
Contributor

Using the link from @jeffdech, I tried manually downloading GDB 10.1 (the version we currently have in our avr-gdb formula) and applying the two patches outlined in the issue (manually, not with git apply, since the patches had been generated from newer versions of the files than the ones we have in 10.1).

Building and running seemed to work fine; I was able to step thru a simple program built by avr-gcc, with GDB in target remote mode pointing to simavr.

So hypothetically we could add these patches to our formula. However, I also tried the latest GDB 15.2, and that worked for me too. So I wonder if we should just upgrade our formula to the newer version and match the upstream gdb formula on homebrew-core? Or do like we have for avr-gcc and have separate version-locked formulae? I can volunteer to open a PR either way.

@ladislas
Copy link
Member

If it works I think it makes sense to use the latest version. Sticking to what brew/core is doing is usually the simplest way to go

I'll review your or as soon as you make it 🙂

reillylm added a commit to reillylm/homebrew-avr that referenced this issue Nov 1, 2024
This makes our formula match these other cross-built GDBs in homebrew-core:

- [riscv64-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/riscv64-elf-gdb.rb)
- [arm-none-eabi-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/a/arm-none-eabi-gdb.rb)
- [x86_64-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/x/x86_64-elf-gdb.rb)
- [i386-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/i/i386-elf-gdb.rb)

Changes from our previous formula:

- GDB now requires GMP (as of 11.1, [commit](https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=1b4ac058f7daeb9bac9ab0e63a7e73535208dfef)) and MPFR (as of 14, [commit](https://sourceware.org/git/?p=binutils-gdb.git;a=commit;f=configure.ac;h=991180627851801f1999d1ebbc0e569a17e47c74))

- remove `--prefix=#{prefix}` + `--disable-debug` + `--disable-dependency-tracking`. These have been added to a reusable `std_configure_args` (as documented here in the [Formula Cookbook](https://github.com/Homebrew/brew/blob/c81b2e43855f0a9bc86339bda73c3e073b061641/docs/Formula-Cookbook.md#std_configure_args)).

- remove `--disable-install-libbfd`. In the [bfd configure script](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/acinclude.m4;h=0ba7957760dfd13a9a97c2c4fbca30f231393c28;hb=HEAD#l62), this looks to be disabled if `host != target` (which is true for us).

- remove `--disable-install-libiberty`. In the [libiberty configure script](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=libiberty/configure.ac;h=c27e08e14288ed489e45e23b0c83e009721b47ba;hb=HEAD#l148), this looks to already be disabled by default.

I think we're also avoiding installing libiberty and libbfd by using `make install-gdb` instead of `make install`.

- remove `--disable-nls` + `--disable-libssp`. I think these flags got copied over from our GCC formulae, but they don't actaully apply to GDB (docs for [GCC configure options](https://gcc.gnu.org/install/configure.html) versus [GDB configure options](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Configure-Options.html)). Same goes for our `avr-binutils` formula dependency.

Addresses osx-cross#343, since the newer GDB version has addressed the Clang errors outlined in the issue.

I wanted to know if we actually needed to customize all those installation directories in the configure script flags, so I installed to a custom `DESTDIR` and checked out the files. Here's what I found (the [GNU Makefile Conventions docs](https://www.gnu.org/prep/standards/html_node/Directory-Variables.html) were helpful here):

GDB installs executables into `bindir`, headers into `includedir` (e.g. for GDB's [JIT interface](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Writing-JIT-Debug-Info-Readers.html#Writing-JIT-Debug-Info-Readers)), data files into `datadir` ([Python helper functions](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Python.html#Python), the [syscall name database](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Set-Catchpoints.html#Set-Catchpoints)), manpages in `mandir`, Info files in `infodir`, and locale files in `localedir`.

Some installed files have a disambiguating prefix of the target architecture (e.g. `avr-gdb`), but most files don't, so they would overwrite files from an existing installation of GDB. Therefore, we specify a disambiguating subdirectory for all the installation directories, _except_: `bindir` (the executables already have the appropriate prefix) and `libdir` (`install-gdb` doesn't install anything here).

`mandir` needs to be modified, not because the installed manpage files don't have the appropriate prefix (they do), or because they get installed to `#{prefix}/man` instead of `#{prefix}/share/man` (like the [Formula Cookbook cautions against](https://github.com/Homebrew/brew/blob/c81b2e43855f0a9bc86339bda73c3e073b061641/docs/Formula-Cookbook.md#manuals)), but because we're customizing `datarootdir`, which causes `make` to install the files to `#{prefix}/share/#{target}/man` instead of `#{prefix}/share/man` like they should go. So we need to "undo" the change we made to `datarootdir` here (as an alternative, I think we could have left `datarootdir` and `mandir` alone, and instead customized `datadir` / `includedir` / `localedir` / `infodir`).
reillylm added a commit to reillylm/homebrew-avr that referenced this issue Nov 1, 2024
This makes our formula match these other cross-built GDBs in homebrew-core:

- [riscv64-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/riscv64-elf-gdb.rb)
- [arm-none-eabi-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/a/arm-none-eabi-gdb.rb)
- [x86_64-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/x/x86_64-elf-gdb.rb)
- [i386-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/i/i386-elf-gdb.rb)

Changes from our previous formula:

- GDB now requires GMP (as of 11.1, [commit](https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=1b4ac058f7daeb9bac9ab0e63a7e73535208dfef)) and MPFR (as of 14, [commit](https://sourceware.org/git/?p=binutils-gdb.git;a=commit;f=configure.ac;h=991180627851801f1999d1ebbc0e569a17e47c74))

- remove `--prefix=#{prefix}` + `--disable-debug` + `--disable-dependency-tracking`. These have been added to a reusable `std_configure_args` (as documented here in the [Formula Cookbook](https://github.com/Homebrew/brew/blob/c81b2e43855f0a9bc86339bda73c3e073b061641/docs/Formula-Cookbook.md#std_configure_args)).

- remove `--disable-install-libbfd`. In the [bfd configure script](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/acinclude.m4;h=0ba7957760dfd13a9a97c2c4fbca30f231393c28;hb=HEAD#l62), this looks to be disabled if `host != target` (which is true for us).

- remove `--disable-install-libiberty`. In the [libiberty configure script](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=libiberty/configure.ac;h=c27e08e14288ed489e45e23b0c83e009721b47ba;hb=HEAD#l148), this looks to already be disabled by default.

I think we're also avoiding installing libiberty and libbfd by using `make install-gdb` instead of `make install`.

- remove `--disable-nls` + `--disable-libssp`. I think these flags got copied over from our GCC formulae, but they don't actaully apply to GDB (docs for [GCC configure options](https://gcc.gnu.org/install/configure.html) versus [GDB configure options](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Configure-Options.html)). Same goes for our `avr-binutils` formula dependency.

Addresses osx-cross#343, since the newer GDB version has addressed the Clang errors outlined in the issue.

**Side note about installation directories**

I wanted to know if we actually needed to customize all those installation directories in the configure script flags, so I installed to a custom `DESTDIR` and checked out the files. Here's what I found (the [GNU Makefile Conventions docs](https://www.gnu.org/prep/standards/html_node/Directory-Variables.html) were helpful here):

GDB installs executables into `bindir`, headers into `includedir` (e.g. for GDB's [JIT interface](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Writing-JIT-Debug-Info-Readers.html#Writing-JIT-Debug-Info-Readers)), data files into `datadir` ([Python helper functions](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Python.html#Python), the [syscall name database](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Set-Catchpoints.html#Set-Catchpoints)), manpages in `mandir`, Info files in `infodir`, and locale files in `localedir`.

Some installed files have a disambiguating prefix of the target architecture (e.g. `avr-gdb`), but most files don't, so they would overwrite files from an existing installation of GDB. Therefore, we specify a disambiguating subdirectory for all the installation directories, _except_: `bindir` (the executables already have the appropriate prefix) and `libdir` (`install-gdb` doesn't install anything here).

`mandir` needs to be modified, not because the installed manpage files don't have the appropriate prefix (they do), or because they get installed to `#{prefix}/man` instead of `#{prefix}/share/man` (like the [Formula Cookbook cautions against](https://github.com/Homebrew/brew/blob/c81b2e43855f0a9bc86339bda73c3e073b061641/docs/Formula-Cookbook.md#manuals)), but because we're customizing `datarootdir`, which causes `make` to install the files to `#{prefix}/share/#{target}/man` instead of `#{prefix}/share/man` like they should go. So we need to "undo" the change we made to `datarootdir` here (as an alternative, I think we could have left `datarootdir` and `mandir` alone, and instead customized `datadir` / `includedir` / `localedir` / `infodir`).
ladislas pushed a commit that referenced this issue Nov 1, 2024
This makes our formula match these other cross-built GDBs in homebrew-core:

- [riscv64-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/r/riscv64-elf-gdb.rb)
- [arm-none-eabi-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/a/arm-none-eabi-gdb.rb)
- [x86_64-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/x/x86_64-elf-gdb.rb)
- [i386-elf-gdb](https://github.com/Homebrew/homebrew-core/blob/master/Formula/i/i386-elf-gdb.rb)

Changes from our previous formula:

- GDB now requires GMP (as of 11.1, [commit](https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=1b4ac058f7daeb9bac9ab0e63a7e73535208dfef)) and MPFR (as of 14, [commit](https://sourceware.org/git/?p=binutils-gdb.git;a=commit;f=configure.ac;h=991180627851801f1999d1ebbc0e569a17e47c74))

- remove `--prefix=#{prefix}` + `--disable-debug` + `--disable-dependency-tracking`. These have been added to a reusable `std_configure_args` (as documented here in the [Formula Cookbook](https://github.com/Homebrew/brew/blob/c81b2e43855f0a9bc86339bda73c3e073b061641/docs/Formula-Cookbook.md#std_configure_args)).

- remove `--disable-install-libbfd`. In the [bfd configure script](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=bfd/acinclude.m4;h=0ba7957760dfd13a9a97c2c4fbca30f231393c28;hb=HEAD#l62), this looks to be disabled if `host != target` (which is true for us).

- remove `--disable-install-libiberty`. In the [libiberty configure script](https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=libiberty/configure.ac;h=c27e08e14288ed489e45e23b0c83e009721b47ba;hb=HEAD#l148), this looks to already be disabled by default.

I think we're also avoiding installing libiberty and libbfd by using `make install-gdb` instead of `make install`.

- remove `--disable-nls` + `--disable-libssp`. I think these flags got copied over from our GCC formulae, but they don't actaully apply to GDB (docs for [GCC configure options](https://gcc.gnu.org/install/configure.html) versus [GDB configure options](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Configure-Options.html)). Same goes for our `avr-binutils` formula dependency.

Addresses #343, since the newer GDB version has addressed the Clang errors outlined in the issue.

**Side note about installation directories**

I wanted to know if we actually needed to customize all those installation directories in the configure script flags, so I installed to a custom `DESTDIR` and checked out the files. Here's what I found (the [GNU Makefile Conventions docs](https://www.gnu.org/prep/standards/html_node/Directory-Variables.html) were helpful here):

GDB installs executables into `bindir`, headers into `includedir` (e.g. for GDB's [JIT interface](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Writing-JIT-Debug-Info-Readers.html#Writing-JIT-Debug-Info-Readers)), data files into `datadir` ([Python helper functions](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Python.html#Python), the [syscall name database](https://sourceware.org/gdb/download/onlinedocs/gdb.html/Set-Catchpoints.html#Set-Catchpoints)), manpages in `mandir`, Info files in `infodir`, and locale files in `localedir`.

Some installed files have a disambiguating prefix of the target architecture (e.g. `avr-gdb`), but most files don't, so they would overwrite files from an existing installation of GDB. Therefore, we specify a disambiguating subdirectory for all the installation directories, _except_: `bindir` (the executables already have the appropriate prefix) and `libdir` (`install-gdb` doesn't install anything here).

`mandir` needs to be modified, not because the installed manpage files don't have the appropriate prefix (they do), or because they get installed to `#{prefix}/man` instead of `#{prefix}/share/man` (like the [Formula Cookbook cautions against](https://github.com/Homebrew/brew/blob/c81b2e43855f0a9bc86339bda73c3e073b061641/docs/Formula-Cookbook.md#manuals)), but because we're customizing `datarootdir`, which causes `make` to install the files to `#{prefix}/share/#{target}/man` instead of `#{prefix}/share/man` like they should go. So we need to "undo" the change we made to `datarootdir` here (as an alternative, I think we could have left `datarootdir` and `mandir` alone, and instead customized `datadir` / `includedir` / `localedir` / `infodir`).

Closes #352.

Signed-off-by: osxCrossTestBot <osxCrossTestBot@leka.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@jeffdech @ladislas @second-string @WalderlanSena @reillylm and others