Bug#1128289: musl-tools: musl-gcc wrapper incorrectly references x86_64 compiler on arm64

"Leslie, Gianni" <[email protected]>
Newsgroups gmane.linux.debian.ports.arm
Message-ID <DS0PR18MB5368D3418E05BD6D5001C87CB46DA__32946.0042690457$1771337020$gmane$org@DS0PR18MB5368.namprd18.prod.outlook.com>
Package: musl-tools
User: [email protected]
Usertags: arm64
X-Debbugs-Cc: [email protected]
Version: 1.2.5-3
Severity: normal

Dear Maintainer,

On arm64 hosts, the musl-gcc wrapper script incorrectly references the
x86_64 compiler instead of the arm64 compiler.

Environment:
- Docker image: public.ecr.aws/docker/library/rust:slim (arm64)
- Building Rust project with target aarch64-unknown-linux-musl
- RUSTFLAGS="-C linker=musl-gcc" CC="musl-gcc"

Steps to reproduce:
1. Run arm64 rust:slim container on native arm64 host
2. Install musl-tools: apt-get install musl-tools
3. Check /usr/bin/musl-gcc contents

Actual result:
The wrapper contains:
  exec "${REALGCC:-x86_64-linux-gnu-gcc}" "$@" -specs "/usr/lib/x86_64-linux-musl/musl-gcc.specs"

Expected result:
On arm64, it should contain:
  exec "${REALGCC:-aarch64-linux-gnu-gcc}" "$@" -specs "/usr/lib/aarch64-linux-musl/musl-gcc.specs"

This causes compilation failures with architecture-specific flags:
  cc1: error: bad value 'armv8.4-a+sha3' for '-march=' switch
  cc1: note: valid arguments are: nocona core2 ... x86-64 ...

Suggested fix:
The package should detect host architecture and create the appropriate
wrapper pointing to the correct compiler and specs file.

Workaround:
Manually recreate the wrapper after installation:
  echo '#!/bin/sh' > /usr/bin/musl-gcc
  echo 'exec "${REALGCC:-aarch64-linux-gnu-gcc}" "$@" -specs "/usr/lib/aarch64-linux-musl/musl-gcc.specs"' >> /usr/bin/musl-gcc <https://aka.ms/GetOutlookForMac>

-- System Information:
Debian Release: 13.3
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.247-247.992.amzn2int.x86_64 (SMP w/16 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages musl-tools depends on:
ii  musl-dev  1.2.5-3

musl-tools recommends no packages.

musl-tools suggests no packages.

-- no debconf information
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.