I've attached an updated patch implementing this change, which doesn't
depend on gcc-for-host. I didn't realize that gcc-for-host was outdated.
>From 8df6beebe9f89f872799a66f5094d7982e369979 Mon Sep 17 00:00:00 2001
Message-Id: <8df6beebe9f89f872799a66f5094d7982e369979.1619305535.git.j...@joshtriplett.org>
From: Josh Triplett <j...@joshtriplett.org>
Date: Sat, 24 Apr 2021 15:13:39 -0700
Subject: [PATCH] Provide cross-compilation versions of musl-gcc

Move the specs file to musl-dev.

Move the musl-gcc wrapper to musl-dev, name it with a target prefix
(e.g. aarch64-linux-musl-gcc), and have it call the corresponding
cross-gcc (e.g. aarch64-linux-gnu-gcc).

Ship musl-gcc in musl-tools as a symlink to the musl-dev wrapper for the
native architecture.
---
 debian/control                      | 14 +++++++++-----
 debian/musl-dev.install             |  2 ++
 debian/musl-dev.lintian-overrides   |  2 ++
 debian/musl-tools.install           |  3 ---
 debian/musl-tools.links             |  1 +
 debian/musl-tools.lintian-overrides |  3 ---
 debian/rules                        | 19 ++++++++-----------
 7 files changed, 22 insertions(+), 22 deletions(-)
 delete mode 100755 debian/musl-tools.install
 delete mode 100644 debian/musl-tools.lintian-overrides

diff --git a/debian/control b/debian/control
index 4b67bb3..b85d87e 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: musl
 Section: libs
 Priority: optional
 Maintainer: Reiner Herrmann <rei...@reiner-h.de>
-Build-Depends: debhelper-compat (= 13), dh-exec
+Build-Depends: debhelper-compat (= 13), dh-exec, gcc-aarch64-linux-gnu [arm64], gcc-arm-linux-gnueabi [armel], gcc-arm-linux-gnueabihf [armhf], gcc-i686-linux-gnu [i386], gcc-x86-64-linux-gnu [amd64], gcc-m68k-linux-gnu [m68k], gcc-mips-linux-gnu [mips], gcc-mipsel-linux-gnu [mipsel], gcc-mips64el-linux-gnuabi64 [mips64el], gcc-s390x-linux-gnu [s390x], gcc-sh4-linux-gnu [sh4], gcc-powerpc64le-linux-gnu [ppc64el], gcc-riscv64-linux-gnu [riscv64]
 Standards-Version: 4.5.1
 Homepage: https://musl.libc.org/
 Vcs-Git: https://salsa.debian.org/reiner/musl.git
@@ -25,7 +25,7 @@ Section: libdevel
 Architecture: arm64 musl-linux-arm64 armel armhf musl-linux-armhf i386 musl-linux-i386 amd64 musl-linux-amd64 m68k musl-linux-m68k mips musl-linux-mips mipsel musl-linux-mipsel mips64el musl-linux-mips64el s390x musl-linux-s390x sh4 musl-linux-sh4 ppc64el musl-linux-ppc64el riscv64 musl-linux-riscv64
 Multi-Arch: same
 Provides: ${libc-dev:Provides}
-Depends: ${misc:Depends}, musl (= ${binary:Version}), ${linux-libc-dev:Depends}
+Depends: ${misc:Depends}, musl (= ${binary:Version}), ${linux-libc-dev:Depends}, ${gcc:Depends}
 Recommends: ${linux-musl-dev:Recommends}
 Description: standard C library development files
  musl is lightweight, fast, simple, free and strives
@@ -34,11 +34,15 @@ Description: standard C library development files
  .
  This package contains the static linked libraries
  and the include files.
+ .
+ This package also contains the specs file and gcc
+ wrapper script for cross-compilation. For the native
+ musl-gcc script, install the musl-tools package.
 
 Package: musl-tools
 Section: devel
 Architecture: arm64 armel armhf i386 amd64 m68k mips mipsel mips64el s390x sh4 ppc64el riscv64
-Depends: ${misc:Depends}, musl-dev (= ${binary:Version}), gcc
+Depends: ${misc:Depends}, musl-dev (= ${binary:Version})
 Replaces: musl (<< 1.1.15-1)
 Breaks: musl (<< 1.1.15-1)
 Description: standard C library tools
@@ -46,6 +50,6 @@ Description: standard C library tools
  to be correct in the sense of standards-conformance
  and safety.
  .
- This package contains the gcc spec file and the
- musl-gcc wrapper script to make easy-to-deploy static
+ This package contains the musl-gcc wrapper script for
+ the native architecture, to make easy-to-deploy static
  and minimal dynamically linked programs.
diff --git a/debian/musl-dev.install b/debian/musl-dev.install
index 78736e1..46eed94 100755
--- a/debian/musl-dev.install
+++ b/debian/musl-dev.install
@@ -1,4 +1,6 @@
 #! /usr/bin/dh-exec
+usr/bin/musl-gcc => usr/bin/${MUSL_TRIPLE}-gcc
 usr/lib/${MUSL_TRIPLE}/*.a
 usr/lib/${MUSL_TRIPLE}/*.o
+usr/lib/${MUSL_TRIPLE}/*.specs
 usr/include/${MUSL_TRIPLE}/*
diff --git a/debian/musl-dev.lintian-overrides b/debian/musl-dev.lintian-overrides
index a138afd..0220ab3 100644
--- a/debian/musl-dev.lintian-overrides
+++ b/debian/musl-dev.lintian-overrides
@@ -3,3 +3,5 @@
 musl-dev binary: triplet-dir-and-architecture-mismatch
 # musl needs to use its own namespace to not conflict with other libcs
 musl-dev binary: arch-dependent-file-not-in-arch-specific-directory
+# manpage for musl-gcc lives in musl-tools
+musl-dev binary: no-manual-page
diff --git a/debian/musl-tools.install b/debian/musl-tools.install
deleted file mode 100755
index 6c20dd1..0000000
--- a/debian/musl-tools.install
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /usr/bin/dh-exec
-usr/bin/*
-usr/lib/${MUSL_TRIPLE}/*.specs
diff --git a/debian/musl-tools.links b/debian/musl-tools.links
index 67cde40..dc602c9 100755
--- a/debian/musl-tools.links
+++ b/debian/musl-tools.links
@@ -1,2 +1,3 @@
 #! /usr/bin/dh-exec
+/usr/bin/${MUSL_TRIPLE}-gcc /usr/bin/musl-gcc
 /lib/${MUSL_TRIPLE}/libc.so /usr/bin/musl-ldd
diff --git a/debian/musl-tools.lintian-overrides b/debian/musl-tools.lintian-overrides
deleted file mode 100644
index 6c7ca79..0000000
--- a/debian/musl-tools.lintian-overrides
+++ /dev/null
@@ -1,3 +0,0 @@
-# musl needs to use its own namespace to not conflict with other libcs
-# The installed files are the same for CPU architecture
-musl-tools binary: triplet-dir-and-architecture-mismatch
diff --git a/debian/rules b/debian/rules
index c308bc6..1c46455 100755
--- a/debian/rules
+++ b/debian/rules
@@ -7,6 +7,9 @@ DEB_HOST_GNU_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
 DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_GNU_CPU)
 DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
 
+# Handle x86_64 -> x86-64
+HOST_GNU_TYPE_PKG=$(subst _,-,$(DEB_HOST_GNU_TYPE))
+
 # Calculating musl based architecture
 MUSL_ARCH=$(DEB_HOST_GNU_CPU)
 MUSL_TRIPLE=$(DEB_HOST_GNU_CPU)-linux-musl
@@ -38,24 +41,18 @@ endif
 export MUSL_ARCH
 export MUSL_TRIPLE
 
-# Cross build support
-ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
-  CC ?= cc
-else
-  CC=$(DEB_HOST_GNU_TYPE)-gcc
-  CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
-  export CROSS_COMPILE
-endif
-export CC
+CC=$(DEB_HOST_GNU_TYPE)-gcc
+CROSS_COMPILE=$(DEB_HOST_GNU_TYPE)-
+export CROSS_COMPILE
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 
 # Substitue control file variables debending on the debian libc type
 # If musl is the native libc, we can provide libc and depend on linux-libc-dev
 ifneq (,$(findstring musl-linux-,$(DEB_HOST_ARCH)))
-  GENCTRL_OPTIONS = -Vlibc-dev:Provides=libc-dev -Vlinux-libc-dev:Depends=linux-libc-dev
+  GENCTRL_OPTIONS = -Vlibc-dev:Provides=libc-dev -Vlinux-libc-dev:Depends=linux-libc-dev -Vgcc:Depends=gcc-$(HOST_GNU_TYPE_PKG)
 else
-  GENCTRL_OPTIONS = -Vlinux-musl-dev:Recommends=linux-musl-dev
+  GENCTRL_OPTIONS = -Vlinux-musl-dev:Recommends=linux-musl-dev -Vgcc:Depends=gcc-$(HOST_GNU_TYPE_PKG)
 endif
 
 %:
-- 
2.31.1

Reply via email to