Opened 2 years ago

Last modified 5 weeks ago

#68870 assigned defect

arm-none-eabi-gdb wants to build for x86_64 on Apple Silicon

Reported by: jmalcaide (Jose M. Alcaide) Owned by: judaew (Vadym-Valdis Yudaiev)
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: sonoma arm64 Cc: DanielO (Daniel O'Connor)
Port: arm-none-eabi-gdb

Description

It seems that the arm-none-eabi-gdb port is ignoring build_arch. This is what happens when trying to build that port on an Apple Silicon-based Mac (from Terminal.app):

% sudo port install arm-none-eabi-gdb
Error: Cannot install arm-none-eabi-gdb for the arch 'x86_64' because
Error: its dependency arm-none-eabi-gcc is only installed for the arch 'arm64'
Error: and does not have a universal variant.
Error: Unable to execute port: architecture mismatch

Here is my list of installed ports:

% port -v installed
The following ports are currently installed:
  arm-none-eabi-binutils @2.41_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T22:18:17+0100'
  arm-none-eabi-gcc @13.2.0_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T16:06:33+0100'
  db48 @4.8.30_5 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T14:26:03+0100'
  gdbm @1.23_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T14:26:26+0100'
  gettext @0.21.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T22:00:54+0100'
  gettext-runtime @0.21.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T21:56:30+0100'
  gettext-tools-libs @0.21.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T21:59:03+0100'
  gmp @6.3.0_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T13:25:26+0100'
  help2man @1.49.3_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T14:29:32+0100'
  isl @0.24_1 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T13:25:43+0100'
  libiconv @1.17_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T21:55:57+0100'
  libmpc @1.3.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T13:27:00+0100'
  libtextstyle @0.21.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T21:57:06+0100'
  lz4 @1.9.4_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T13:27:05+0100'
  mpfr @4.2.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T13:26:52+0100'
  ncurses @6.4_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T21:54:03+0100'
  nethack @3.6.7_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T21:54:31+0100'
  p5.34-locale-gettext @1.70.0_1 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T14:29:29+0100'
  perl5.34 @5.34.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T14:29:20+0100'
  readline @8.2.001_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T14:26:17+0100'
  texinfo @7.1_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T14:30:30+0100'
  unrar @6.2.12_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T21:53:16+0100'
  xz @5.4.5_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T13:25:59+0100'
  zlib @1.3_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-11-30T22:07:41+0100'
  zstd @1.5.5_0 (active) requested_variants='' platform='darwin 23' archs='arm64' date='2023-12-10T13:27:24+0100'

I am using the default macports.conf and I don't have a ~/.macports directory.

Attachments (1)

0001-GDB-runs-just-fine-on-AMD64-so-remove-the-unecessary.patch (1.1 KB) - added by DanielO (Daniel O'Connor) 5 months ago.
Patch to remove limitation to only build for Intel archs

Download all attachments as: .zip

Change History (9)

comment:1 in reply to:  description Changed 2 years ago by ryandesign (Ryan Carsten Schmidt)

Owner: set to judaew
Status: newassigned

Replying to jmalcaide:

It seems that the arm-none-eabi-gdb port is ignoring build_arch.

It isn't; this is working as intended. The arm-none-eabi-gdb portfile includes the crossgdb portgroup which contains the lines:

        # gdb is not supported on macOS ARM now
        # See https://inbox.sourceware.org/gdb/3185c3b8-8a91-4beb-a5d5-9db6afb93713@Spark
        supported_archs x86_64 i386

comment:2 Changed 2 years ago by jmalcaide (Jose M. Alcaide)

I think that the error message is very misleading. First, it says that arm-none-eabi-gdb was being installed for X86-64 (I never intended that). Secondly, it states that the reason for failing is that the dependency arm-none-eabi-gcc has been installed for arm64; however, the real reason is that arm-none-eabi-gdb does not support building for arm64, because it is not listed as a supported architecture by the crossdb portgroup.

Anyway, I don't understand why arm-none-eabi-gdb cannot be built for arm64. In my case, I intend to use this port for cross-debugging programs running on a BBC micro:bit microcontroller board connected to my Mac via USB, and using PyOCD for communication with the onboard debugger. These programs are being cross-compiled, cross-assembled and cross-linked using arm-none-eabi-gcc and arm-none-eabi-as. The executable so generated is converted using arm-none-eabi-objdump from ELF to bin formats. The architecture of the host computer (the Mac) is completely irrelevant for all this to work. In fact, I installed the complete toolchain (including arm-none-eabi-gdb) using Homebrew and it works perfectly.

Last edited 2 years ago by jmalcaide (Jose M. Alcaide) (previous) (diff)

comment:3 Changed 19 months ago by sectroyer

+1

comment:4 Changed 18 months ago by sectroyer

Here is repo with gdb compiled for arm64: https://github.com/SeanMollet/arm-none-eabi-gcc-aarch64-macosx It also has necessary patches and instructions so you can compile it yourself.

comment:5 Changed 5 months ago by DanielO (Daniel O'Connor)

I commented out the restriction in _resources/port1.0/group/crossgdb-1.0.tcl and built it. I don't know if the original restriction was made because it can't debug arm64 binaries on Apple hardware I want to use it for debugging ARM MCUs so the restriction is unnecessary.

I haven't tested it against a debugee yet but the built binary runs as expected.

Changed 5 months ago by DanielO (Daniel O'Connor)

Patch to remove limitation to only build for Intel archs

comment:6 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

Cc: DanielO added

Before we apply this patch, I'd like to see what the developers have to say about it. Have you run it by them? Please provide the URL of the discussion or bug report.

comment:7 Changed 5 months ago by DanielO (Daniel O'Connor)

Arm have a GCC/GDB toolchain available for download so I think it can be considered 'supported' - at least for the use case of building/debugging ARM MCUs (or any ARM bare metal, even up to very powerful systems).

I think it is worth differentiating between debugging a user land application on macOS (definitely a PITA with GDB, I just use LLDB) and debugging a bare metal MCU (works very well).

I would use the ARM toolchain but it lacks a Python interpreter so the MacPort ones is very useful for numerous quality of life features like svd-tool.

The thread mentioned in the comment about the line I removed does have a message that mentions this.

comment:8 Changed 5 weeks ago by DanielO (Daniel O'Connor)

Bump. I would very much like if this is committed as it makes debugging microcontrollers much easier.

Note: See TracTickets for help on using tickets.