Merge pull request #194 from doraskayo/musl-dynamic-linking

musl dynamic linking support
This commit is contained in:
Andrius Štikonas 2022-09-15 21:53:24 +01:00 committed by GitHub
commit a16440f7c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 630 additions and 26 deletions

View File

@ -9,6 +9,6 @@ Source: https://github.com/fosslinux/live-bootstrap
# Copyright: $YEAR $NAME <$CONTACT> # Copyright: $YEAR $NAME <$CONTACT>
# License: ... # License: ...
Files: sys*/SHA256SUMS.sources sysa/pre-sha.sha256sums sysa/*/*.checksums sysa/SHA256SUMS.pkgs Files: sys*/SHA256SUMS.sources sysa/pre-sha.sha256sums sysa/*/*.checksums sysa/SHA256SUMS.pkgs sysc/musl-1.2.3/ld-musl-i386.path
Copyright: none Copyright: none
License: MIT License: MIT

View File

@ -792,6 +792,12 @@ This version of binutils provides a more comprehensive set of programming tools
creating and managing binary programs. It also includes modern versions of the ``ld`` creating and managing binary programs. It also includes modern versions of the ``ld``
linker, the ``as`` assembler and the ``ar`` program. linker, the ``as`` assembler and the ``ar`` program.
musl 1.2.3
==========
With GCC and binutils supporting a musl-based toolchain natively, musl itself is rebuilt
with support for dynamic linking.
gperf 3.1 gperf 3.1
========= =========

View File

@ -26,7 +26,7 @@ b2eab85c4a22060cc18945f6cb24cdf928fee370fff3fe12482e866a1cace586 automake-1.6.3
42fe9a42c457193e7bebf31b71eb28bc71e179ed9f2c78be242a5f6b03bbbbfe automake-1.9.6_0.tar.bz2 42fe9a42c457193e7bebf31b71eb28bc71e179ed9f2c78be242a5f6b03bbbbfe automake-1.9.6_0.tar.bz2
e180c61e3922b0546a6a3ee498abeba6dfdd404215ca850628a5277e5ede26e7 bash-5.1_0.tar.bz2 e180c61e3922b0546a6a3ee498abeba6dfdd404215ca850628a5277e5ede26e7 bash-5.1_0.tar.bz2
a6190872c4daf1b55a1ad1f2fd2e34bd251f3808f750bb4a7920b66d672497a8 binutils-2.14_0.tar.bz2 a6190872c4daf1b55a1ad1f2fd2e34bd251f3808f750bb4a7920b66d672497a8 binutils-2.14_0.tar.bz2
7c7c66ed51b89748eb4762eef4f946e8382973118b7bc0339afa527611ba1d80 binutils-2.38_0.x86.xbps 6f8387ec292b5b57f3722828094630714e117d99e9924ffd4bee40600a74b69f binutils-2.38_0.x86.xbps
f566a5cb99adc8f572659ebf4a778ff23acf62d90b13a9983f56488a493b15b2 bison-2.3_0.tar.bz2 f566a5cb99adc8f572659ebf4a778ff23acf62d90b13a9983f56488a493b15b2 bison-2.3_0.tar.bz2
87dae598915deabe95a4ee75ec6cfed3a6e6da1a655c3ad90ee60ec07a7d87fa bison-3.4.1_0.tar.bz2 87dae598915deabe95a4ee75ec6cfed3a6e6da1a655c3ad90ee60ec07a7d87fa bison-3.4.1_0.tar.bz2
ae452f08ad9f7ab01f2a9bd882170e71ee6200a06f044f4aadb446cc68700016 bison-3.4.1_1.tar.bz2 ae452f08ad9f7ab01f2a9bd882170e71ee6200a06f044f4aadb446cc68700016 bison-3.4.1_1.tar.bz2
@ -48,25 +48,25 @@ f55c11b091361536774b436abe86b17f759cd7a66522cd20c7a2190da92db67a findutils-4.2.
33afd1c66c864b486df290e682883556787c61751b8c851deb2737f0b777ffd6 flex-2.5.33_0.tar.bz2 33afd1c66c864b486df290e682883556787c61751b8c851deb2737f0b777ffd6 flex-2.5.33_0.tar.bz2
000147c1a33feff5c5b4cb10c2cf6c2b2f4ef92a90c9e659b25f1766a83d4afc flex-2.6.4_0.tar.bz2 000147c1a33feff5c5b4cb10c2cf6c2b2f4ef92a90c9e659b25f1766a83d4afc flex-2.6.4_0.tar.bz2
92fe0ffd0971a40fd98c70b075d5bb12f2d8093ef8fb3333aac2b532bd53a591 gawk-3.0.4_0.tar.bz2 92fe0ffd0971a40fd98c70b075d5bb12f2d8093ef8fb3333aac2b532bd53a591 gawk-3.0.4_0.tar.bz2
d25f1957e10458fe16065899cab818d97665459f7b5d13b7f2ef4225079b7800 gc-8.0.4_0.x86.xbps 0a8d7c32e8a32c7db713cf9d4b75f6ea186771197a425f20334b80072710d896 gc-8.0.4_0.x86.xbps
07715a0c8bc13b80fc10ede20573f92e933b8d3dc6a5c8700f4289965ea8ec74 gcc-4.0.4_0.tar.bz2 07715a0c8bc13b80fc10ede20573f92e933b8d3dc6a5c8700f4289965ea8ec74 gcc-4.0.4_0.tar.bz2
e7c678c71c51cd6e8ce6eae029503a661169e6994ba0f988ac15634254d1fadb gcc-4.0.4_1.tar.bz2 e7c678c71c51cd6e8ce6eae029503a661169e6994ba0f988ac15634254d1fadb gcc-4.0.4_1.tar.bz2
53b03122b399b1c5c2427aa735e42d661157d9369c3023a3fe45e87001e2a973 gcc-4.7.4_0.x86.xbps edbe2c9ad51858feffe869aae25aec9de99d85fc0566ec883354ddd9e9b5060c gcc-4.7.4_0.x86.xbps
b5f6fe07a696751d2fc1d9cc3d96f09d89d6a637e1d8d0b250105b650e831600 gettext-0.21_0.x86.xbps b5f6fe07a696751d2fc1d9cc3d96f09d89d6a637e1d8d0b250105b650e831600 gettext-0.21_0.x86.xbps
fe16fb6021f1f4650c98f77261145f37732be0aee06e957b0bdb3b01beb593a8 gmp-6.2.1_0.tar.bz2 fe16fb6021f1f4650c98f77261145f37732be0aee06e957b0bdb3b01beb593a8 gmp-6.2.1_0.tar.bz2
0038451c2dd38d7864be245f71af20ca1067cd2911d5612aedd4928d9e1d0f7d gperf-3.1_0.x86.xbps 73742c85954e9899ef76385698b791664a542ab0b580ae2d789445c683af509b gperf-3.1_0.x86.xbps
390840f2bc9c2a3196c28e06f8650f408e33b5d4ffe5539e174682ed13960bc9 grep-2.4_0.tar.bz2 390840f2bc9c2a3196c28e06f8650f408e33b5d4ffe5539e174682ed13960bc9 grep-2.4_0.tar.bz2
1ba9c0639d6d1d326c17b6311c88762879ef4c5374b7c1ecd0761b5a3124c86f guile-3.0.7_0.x86.xbps d10b24962b9d0a580f9db4816a44f31877048c7c9e4b2d5e3d99609e39a8c028 guile-3.0.7_0.x86.xbps
ec6b32cba3f49f860a3d9b97cea57931869c5849d8ca5ad0ea01dad45b9edb91 help2man-1.36.4_0.tar.bz2 ec6b32cba3f49f860a3d9b97cea57931869c5849d8ca5ad0ea01dad45b9edb91 help2man-1.36.4_0.tar.bz2
2ef01fe7252be680382bee5df890ad3f6dae26744104ccdaa2d1236bc19ab44a kbd-1.15_0.tar.bz2 2ef01fe7252be680382bee5df890ad3f6dae26744104ccdaa2d1236bc19ab44a kbd-1.15_0.tar.bz2
68c272b50a99e4d53cab57552337e7660020a47c06a0341efcdfa4f2441db187 kexec-tools-2.0.22_0.tar.bz2 68c272b50a99e4d53cab57552337e7660020a47c06a0341efcdfa4f2441db187 kexec-tools-2.0.22_0.tar.bz2
4c0cc86a9855122a4b5c12bff6f6bbf524495910ec718ef339fbfe7076824950 libarchive-3.5.2_0.tar.bz2 4c0cc86a9855122a4b5c12bff6f6bbf524495910ec718ef339fbfe7076824950 libarchive-3.5.2_0.tar.bz2
e0600d72b7fb12653d39cf0b690d45fc7f30131d78342a371d4af327d8999812 libatomic_ops-7.6.10_0.x86.xbps c185d9cc55029fb2fd4f4897b6581c22f0957b57a4fff8f68591c068a4e16daa libatomic_ops-7.6.10_0.x86.xbps
d8986237271dfa591334c9a671d1946749bbcee84ff7c2cc1c15ae21f111ffa0 libffi-3.3_0.x86.xbps bd17cec1e4d5eabaa474bbe671cc33af71dce8155206221a310a98bdc5f52fd3 libffi-3.3_0.x86.xbps
5001f8fdbba0db0ecf60263bfea97ed4b9174d06a447e98bee220548f973756a libtool-1.4_0.tar.bz2 5001f8fdbba0db0ecf60263bfea97ed4b9174d06a447e98bee220548f973756a libtool-1.4_0.tar.bz2
94d0f9d2f8fbc2b00fe4c0f479e5590fa70b7d856f0a643ad006787d963f99ee libtool-2.2.4_0.tar.bz2 94d0f9d2f8fbc2b00fe4c0f479e5590fa70b7d856f0a643ad006787d963f99ee libtool-2.2.4_0.tar.bz2
374214711d42681d030d6faceba3198243ec22301d94212f7162bd4873b7ba27 libtool-2.4.7_0.tar.bz2 374214711d42681d030d6faceba3198243ec22301d94212f7162bd4873b7ba27 libtool-2.4.7_0.tar.bz2
58c18a039b614e6d56611d198d3c3e93b71eed5741af95a3ceef17d607fcb33a libunistring-0.9.10_0.x86.xbps f4018015c72f4ed1e172a34db41e9547c389ed7caeeb7f379a081e0bf9ccac88 libunistring-0.9.10_0.x86.xbps
1d07aaf7049be45853fd409340cdb52bb3a1b6dfa4dbc8b69358c1ee966cd67f linux-4.9.10_0.tar.bz2 1d07aaf7049be45853fd409340cdb52bb3a1b6dfa4dbc8b69358c1ee966cd67f linux-4.9.10_0.tar.bz2
61507b58074a3742191b606f9415f79406e5daa693ab4ba4a4543897696628ea linux-headers-5.10.41_0.tar.bz2 61507b58074a3742191b606f9415f79406e5daa693ab4ba4a4543897696628ea linux-headers-5.10.41_0.tar.bz2
5cda10550198e613c426e45c5fffe0f7e8761296e7339e9e9a1f9da995b4865a m4-1.4.7_0.tar.bz2 5cda10550198e613c426e45c5fffe0f7e8761296e7339e9e9a1f9da995b4865a m4-1.4.7_0.tar.bz2
@ -78,6 +78,7 @@ ffeadd2b9d9e72edb5b15750b50a6c0c47bb90a1cb14ba66732aa733e0209e50 mpfr-4.1.0_0.t
7f3251ee05aaa38e9803db41104acbfa399873a31591411c3580d181a6461d0c musl-1.1.24_1.tar.bz2 7f3251ee05aaa38e9803db41104acbfa399873a31591411c3580d181a6461d0c musl-1.1.24_1.tar.bz2
9f3d2b47634860cfd5f03fa3346ef9a60a6dab57164ee974578dbb7f4a45e16b musl-1.1.24_2.tar.bz2 9f3d2b47634860cfd5f03fa3346ef9a60a6dab57164ee974578dbb7f4a45e16b musl-1.1.24_2.tar.bz2
af949ecc98bdc3b94d0f74e5d38a3c3710712a029ddb6cf9b801390e1d626b3c musl-1.2.3_0.tar.bz2 af949ecc98bdc3b94d0f74e5d38a3c3710712a029ddb6cf9b801390e1d626b3c musl-1.2.3_0.tar.bz2
b41fc4618bef304ec05e3350ea04a7b7698765ce1654692b66e367afc4d45ffc musl-1.2.3_1.x86.xbps
df12820e27abfe07c4c27bb2f9abf2e0758b797d5d3036e29d6c57cfb5aa12d6 openssl-1.1.1l_0.tar.bz2 df12820e27abfe07c4c27bb2f9abf2e0758b797d5d3036e29d6c57cfb5aa12d6 openssl-1.1.1l_0.tar.bz2
189443aecea6e8435d1243071c2e46d7e4bb8f79f2929ae6a6c96eea40394a35 patch-2.7.6_0.x86.xbps 189443aecea6e8435d1243071c2e46d7e4bb8f79f2929ae6a6c96eea40394a35 patch-2.7.6_0.x86.xbps
75fffc4bb14f14281bc1853455888d1d818b7027efc1e4014af1a755771a64e8 perl-5.000_0.tar.bz2 75fffc4bb14f14281bc1853455888d1d818b7027efc1e4014af1a755771a64e8 perl-5.000_0.tar.bz2

View File

@ -189,6 +189,9 @@ class SysC(SysGeneral):
# binutils 2.38 # binutils 2.38
self.get_file("https://mirrors.kernel.org/gnu/binutils/binutils-2.38.tar.xz") self.get_file("https://mirrors.kernel.org/gnu/binutils/binutils-2.38.tar.xz")
# musl 1.2.3
self.get_file("https://musl.libc.org/releases/musl-1.2.3.tar.gz")
# gperf 3.1 # gperf 3.1
self.get_file("https://mirrors.kernel.org/gnu/gperf/gperf-3.1.tar.gz") self.get_file("https://mirrors.kernel.org/gnu/gperf/gperf-3.1.tar.gz")

View File

@ -37,6 +37,7 @@ eb8fb2c3e4b6e2d336608377050892b54c3c983b646c561836550863003c05d7 libunistring-0
e40b8f018c1da64edd1cc9a6fce5fa63b2e707e404e20cad91fbae337c98a5b7 make-4.2.1.tar.gz e40b8f018c1da64edd1cc9a6fce5fa63b2e707e404e20cad91fbae337c98a5b7 make-4.2.1.tar.gz
17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459 mpc-1.2.1.tar.gz 17503d2c395dfcf106b622dc142683c1199431d095367c6aacba6eec30340459 mpc-1.2.1.tar.gz
0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f mpfr-4.1.0.tar.xz 0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f mpfr-4.1.0.tar.xz
7d5b0b6062521e4627e099e4c9dc8248d32a30285e959b7eecaa780cf8cfd4a4 musl-1.2.3.tar.gz
f455f341e787c1167328e80a84f77b9a557d595066dda6486a1874d72da68800 nss-3.78.tar.gz f455f341e787c1167328e80a84f77b9a557d595066dda6486a1874d72da68800 nss-3.78.tar.gz
0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1 openssl-1.1.1l.tar.gz 0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1 openssl-1.1.1l.tar.gz
ac610bda97abe0d9f6b7c963255a11dcb196c25e337c61f94e4778d632f1d8fd patch-2.7.6.tar.xz ac610bda97abe0d9f6b7c963255a11dcb196c25e337c61f94e4778d632f1d8fd patch-2.7.6.tar.xz

View File

@ -0,0 +1,58 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Gregor Richards <gregor.richards@uwaterloo.ca>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit 96ce40cbce449cb5f434425d148a9bcf02270c96
libitm fixes for musl support
2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
* config/arm/hwcap.cc: Use fcntl.h instead of sys/fcntl.h.
* config/linux/x86/tls.h: Only use __GLIBC_PREREQ if defined.
From-SVN: r222325
--- libitm/config/arm/hwcap.cc
+++ libitm/config/arm/hwcap.cc
@@ -40,7 +40,7 @@ int GTM_hwcap HIDDEN = 0
#ifdef __linux__
#include <unistd.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <elf.h>
static void __attribute__((constructor))
--- libitm/config/linux/x86/tls.h
+++ libitm/config/linux/x86/tls.h
@@ -25,16 +25,19 @@
#ifndef LIBITM_X86_TLS_H
#define LIBITM_X86_TLS_H 1
-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
+#if defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 10)
/* Use slots in the TCB head rather than __thread lookups.
GLIBC has reserved words 10 through 13 for TM. */
#define HAVE_ARCH_GTM_THREAD 1
#define HAVE_ARCH_GTM_THREAD_DISP 1
#endif
+#endif
#include "config/generic/tls.h"
-#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 10)
+#if defined(__GLIBC_PREREQ)
+#if __GLIBC_PREREQ(2, 10)
namespace GTM HIDDEN {
#ifdef __x86_64__
@@ -101,5 +104,6 @@ static inline void set_abi_disp(struct abi_dispatch *x)
} // namespace GTM
#endif /* >= GLIBC 2.10 */
+#endif
#endif // LIBITM_X86_TLS_H

View File

@ -0,0 +1,27 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Gregor Richards <gregor.richards@uwaterloo.ca>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit 218213dfd01e22b7c9f1be3119e32d970fa348bf
fixincludes update for musl support
2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
* mkfixinc.sh: Add *-musl* with no fixes.
From-SVN: r222327
--- fixincludes/mkfixinc.sh
+++ fixincludes/mkfixinc.sh
@@ -20,7 +20,8 @@ case $machine in
powerpc-*-eabi* | \
powerpc-*-rtems* | \
powerpcle-*-eabisim* | \
- powerpcle-*-eabi* )
+ powerpcle-*-eabi* | \
+ *-musl* )
# IF there is no include fixing,
# THEN create a no-op fixer and exit
(echo "#! /bin/sh" ; echo "exit 0" ) > ${target}

View File

@ -0,0 +1,35 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Gregor Richards <gregor.richards@uwaterloo.ca>
SPDX-FileCopyrightText: 2015 Szabolcs Nagy <szabolcs.nagy@arm.com>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit 15aa7b447218e45da835472bbf4740ae00db9982
unwind fix for musl
2015-04-22 Gregor Richards <gregor.richards@uwaterloo.ca>
Szabolcs Nagy <szabolcs.nagy@arm.com>
* unwind-dw2-fde-dip.c (USE_PT_GNU_EH_FRAME): Define it on
Linux if target provides dl_iterate_phdr.
Co-Authored-By: Szabolcs Nagy <szabolcs.nagy@arm.com>
From-SVN: r222328
--- libgcc/unwind-dw2-fde-dip.c
+++ libgcc/unwind-dw2-fde-dip.c
@@ -53,6 +53,12 @@
# define USE_PT_GNU_EH_FRAME
#endif
+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
+ && defined(TARGET_DL_ITERATE_PHDR) \
+ && defined(__linux__)
+# define USE_PT_GNU_EH_FRAME
+#endif
+
#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \
&& defined(__FreeBSD__) && __FreeBSD__ >= 7
# define ElfW __ElfN

View File

@ -0,0 +1,41 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Szabolcs Nagy <szabolcs.nagy@arm.com>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit 85da5c3024f731e719c4093314da8edcd1056527
libstdc++ gthr workaround for musl
[libstdc++-v3/]
2015-04-22 Szabolcs Nagy <szabolcs.nagy@arm.com>
* config/os/generic/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK): Define.
* configure.host (os_include_dir): Set to "os/generic" for linux-musl*.
From-SVN: r222329
--- libstdc++-v3/config/os/generic/os_defines.h
+++ libstdc++-v3/config/os/generic/os_defines.h
@@ -33,4 +33,9 @@
// System-specific #define, typedefs, corrections, etc, go here. This
// file will come before all others.
+// Disable the weak reference logic in gthr.h for os/generic because it
+// is broken on every platform unless there is implementation specific
+// workaround in gthr-posix.h and at link-time for static linking.
+#define _GLIBCXX_GTHREAD_USE_WEAK 0
+
#endif
--- libstdc++-v3/configure.host
+++ libstdc++-v3/configure.host
@@ -242,6 +242,9 @@ case "${host_os}" in
freebsd*)
os_include_dir="os/bsd/freebsd"
;;
+ linux-musl*)
+ os_include_dir="os/generic"
+ ;;
gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
if [ "$uclibc" = "yes" ]; then
os_include_dir="os/uclibc"

View File

@ -0,0 +1,281 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Gregor Richards <gregor.richards@uwaterloo.ca>
SPDX-FileCopyrightText: 2015 Szabolcs Nagy <szabolcs.nagy@arm.com>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit 755658a56b57beca14b5fb70afdf1e588a058f7f
musl libc config
2015-05-08 Gregor Richards <gregor.richards@uwaterloo.ca>
Szabolcs Nagy <szabolcs.nagy@arm.com>
* config.gcc (LIBC_MUSL): New tm_defines macro.
* config/linux.h (OPTION_MUSL): Define.
(MUSL_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER32,)
(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32,)
(INCLUDE_DEFAULTS_MUSL_GPP, INCLUDE_DEFAULTS_MUSL_LOCAL,)
(INCLUDE_DEFAULTS_MUSL_PREFIX, INCLUDE_DEFAULTS_MUSL_CROSS,)
(INCLUDE_DEFAULTS_MUSL_TOOL, INCLUDE_DEFAULTS_MUSL_NATIVE): Define.
* config/linux.opt (mmusl): New option.
* doc/invoke.texi (GNU/Linux Options): Document -mmusl.
* configure.ac (gcc_cv_libc_provides_ssp): Add *-*-musl*.
(gcc_cv_target_dl_iterate_phdr): Add *-linux-musl*.
* configure: Regenerate.
Co-Authored-By: Szabolcs Nagy <szabolcs.nagy@arm.com>
From-SVN: r222904
--- gcc/config.gcc
+++ gcc/config.gcc
@@ -522,7 +522,7 @@ case ${target} in
esac
# Common C libraries.
-tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
+tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3 LIBC_MUSL=4"
# Common parts for widely ported systems.
case ${target} in
@@ -625,6 +625,9 @@ case ${target} in
*-*-*uclibc*)
tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
;;
+ *-*-*musl*)
+ tm_defines="$tm_defines DEFAULT_LIBC=LIBC_MUSL"
+ ;;
*)
tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
;;
--- gcc/config/linux.h
+++ gcc/config/linux.h
@@ -33,10 +33,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
+#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
#else
#define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
+#define OPTION_MUSL (linux_libc == LIBC_MUSL)
#endif
#define GNU_USER_TARGET_OS_CPP_BUILTINS() \
@@ -51,21 +53,25 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
} while (0)
/* Determine which dynamic linker to use depending on whether GLIBC or
- uClibc or Bionic is the default C library and whether
- -muclibc or -mglibc or -mbionic has been passed to change the default. */
+ uClibc or Bionic or musl is the default C library and whether
+ -muclibc or -mglibc or -mbionic or -mmusl has been passed to change
+ the default. */
-#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LD1, LD2, LD3) \
- "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:" LD1 "}}"
+#define CHOOSE_DYNAMIC_LINKER1(LIBC1, LIBC2, LIBC3, LIBC4, LD1, LD2, LD3, LD4) \
+ "%{" LIBC2 ":" LD2 ";:%{" LIBC3 ":" LD3 ";:%{" LIBC4 ":" LD4 ";:" LD1 "}}}"
#if DEFAULT_LIBC == LIBC_GLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
- CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", G, U, B)
+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
+ CHOOSE_DYNAMIC_LINKER1 ("mglibc", "muclibc", "mbionic", "mmusl", G, U, B, M)
#elif DEFAULT_LIBC == LIBC_UCLIBC
-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
- CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", U, G, B)
+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
+ CHOOSE_DYNAMIC_LINKER1 ("muclibc", "mglibc", "mbionic", "mmusl", U, G, B, M)
#elif DEFAULT_LIBC == LIBC_BIONIC
-#define CHOOSE_DYNAMIC_LINKER(G, U, B) \
- CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", B, G, U)
+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
+ CHOOSE_DYNAMIC_LINKER1 ("mbionic", "mglibc", "muclibc", "mmusl", B, G, U, M)
+#elif DEFAULT_LIBC == LIBC_MUSL
+#define CHOOSE_DYNAMIC_LINKER(G, U, B, M) \
+ CHOOSE_DYNAMIC_LINKER1 ("mmusl", "mglibc", "muclibc", "mbionic", M, G, U, B)
#else
#error "Unsupported DEFAULT_LIBC"
#endif /* DEFAULT_LIBC */
@@ -82,19 +88,24 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
#define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
#define BIONIC_DYNAMIC_LINKERX32 "/system/bin/linkerx32"
+/* Should be redefined for each target that supports musl. */
+#define MUSL_DYNAMIC_LINKER "/dev/null"
+#define MUSL_DYNAMIC_LINKER32 "/dev/null"
+#define MUSL_DYNAMIC_LINKER64 "/dev/null"
+#define MUSL_DYNAMIC_LINKERX32 "/dev/null"
#define GNU_USER_DYNAMIC_LINKER \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER, \
- BIONIC_DYNAMIC_LINKER)
+ BIONIC_DYNAMIC_LINKER, MUSL_DYNAMIC_LINKER)
#define GNU_USER_DYNAMIC_LINKER32 \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER32, UCLIBC_DYNAMIC_LINKER32, \
- BIONIC_DYNAMIC_LINKER32)
+ BIONIC_DYNAMIC_LINKER32, MUSL_DYNAMIC_LINKER32)
#define GNU_USER_DYNAMIC_LINKER64 \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER64, UCLIBC_DYNAMIC_LINKER64, \
- BIONIC_DYNAMIC_LINKER64)
+ BIONIC_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKER64)
#define GNU_USER_DYNAMIC_LINKERX32 \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKERX32, UCLIBC_DYNAMIC_LINKERX32, \
- BIONIC_DYNAMIC_LINKERX32)
+ BIONIC_DYNAMIC_LINKERX32, MUSL_DYNAMIC_LINKERX32)
/* Determine whether the entire c99 runtime
is present in the runtime library. */
@@ -108,3 +119,74 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* Whether we have Bionic libc runtime */
#undef TARGET_HAS_BIONIC
#define TARGET_HAS_BIONIC (OPTION_BIONIC)
+
+/* musl avoids problematic includes by rearranging the include directories.
+ * Unfortunately, this is mostly duplicated from cppdefault.c */
+#if DEFAULT_LIBC == LIBC_MUSL
+#define INCLUDE_DEFAULTS_MUSL_GPP \
+ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
+ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
+ { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
+
+#ifdef LOCAL_INCLUDE_DIR
+#define INCLUDE_DEFAULTS_MUSL_LOCAL \
+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
+#else
+#define INCLUDE_DEFAULTS_MUSL_LOCAL
+#endif
+
+#ifdef PREFIX_INCLUDE_DIR
+#define INCLUDE_DEFAULTS_MUSL_PREFIX \
+ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
+#else
+#define INCLUDE_DEFAULTS_MUSL_PREFIX
+#endif
+
+#ifdef CROSS_INCLUDE_DIR
+#define INCLUDE_DEFAULTS_MUSL_CROSS \
+ { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
+#else
+#define INCLUDE_DEFAULTS_MUSL_CROSS
+#endif
+
+#ifdef TOOL_INCLUDE_DIR
+#define INCLUDE_DEFAULTS_MUSL_TOOL \
+ { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
+#else
+#define INCLUDE_DEFAULTS_MUSL_TOOL
+#endif
+
+#ifdef NATIVE_SYSTEM_HEADER_DIR
+#define INCLUDE_DEFAULTS_MUSL_NATIVE \
+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
+ { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
+#else
+#define INCLUDE_DEFAULTS_MUSL_NATIVE
+#endif
+
+#if defined (CROSS_DIRECTORY_STRUCTURE) && !defined (TARGET_SYSTEM_ROOT)
+# undef INCLUDE_DEFAULTS_MUSL_LOCAL
+# define INCLUDE_DEFAULTS_MUSL_LOCAL
+# undef INCLUDE_DEFAULTS_MUSL_NATIVE
+# define INCLUDE_DEFAULTS_MUSL_NATIVE
+#else
+# undef INCLUDE_DEFAULTS_MUSL_CROSS
+# define INCLUDE_DEFAULTS_MUSL_CROSS
+#endif
+
+#undef INCLUDE_DEFAULTS
+#define INCLUDE_DEFAULTS \
+ { \
+ INCLUDE_DEFAULTS_MUSL_GPP \
+ INCLUDE_DEFAULTS_MUSL_PREFIX \
+ INCLUDE_DEFAULTS_MUSL_CROSS \
+ INCLUDE_DEFAULTS_MUSL_TOOL \
+ INCLUDE_DEFAULTS_MUSL_NATIVE \
+ { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
+ { 0, 0, 0, 0, 0, 0 } \
+ }
+#endif
--- gcc/config/linux.opt
+++ gcc/config/linux.opt
@@ -28,5 +28,9 @@ Target Report RejectNegative Var(linux_libc,LIBC_GLIBC) Negative(muclibc)
Use GNU C library
muclibc
-Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mbionic)
+Target Report RejectNegative Var(linux_libc,LIBC_UCLIBC) Negative(mmusl)
Use uClibc C library
+
+mmusl
+Target Report RejectNegative Var(linux_libc,LIBC_MUSL) Negative(mbionic)
+Use musl C library
--- gcc/configure.ac
+++ gcc/configure.ac
@@ -4669,6 +4669,9 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
gcc_cv_libc_provides_ssp,
[gcc_cv_libc_provides_ssp=no
case "$target" in
+ *-*-musl*)
+ # All versions of musl provide stack protector
+ gcc_cv_libc_provides_ssp=yes;;
*-*-linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu)
[# glibc 2.4 and later provides __stack_chk_fail and
# either __stack_chk_guard, or TLS access to stack guard canary.
@@ -4702,6 +4705,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
# <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
# simply assert that glibc does provide this, which is true for all
# realistically usable GNU/Hurd configurations.
+ # All supported versions of musl provide it as well
gcc_cv_libc_provides_ssp=yes;;
*-*-darwin* | *-*-freebsd*)
AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
@@ -4767,6 +4771,9 @@ case "$target" in
gcc_cv_target_dl_iterate_phdr=no
fi
;;
+ *-linux-musl*)
+ gcc_cv_target_dl_iterate_phdr=yes
+ ;;
esac
GCC_TARGET_TEMPLATE([TARGET_DL_ITERATE_PHDR])
if test x$gcc_cv_target_dl_iterate_phdr = xyes; then
--- gcc/doc/invoke.texi
+++ gcc/doc/invoke.texi
@@ -595,7 +595,7 @@ Objective-C and Objective-C++ Dialects}.
-mcpu=@var{cpu}}
@emph{GNU/Linux Options}
-@gccoptlist{-mglibc -muclibc -mbionic -mandroid @gol
+@gccoptlist{-mglibc -muclibc -mmusl -mbionic -mandroid @gol
-tno-android-cc -tno-android-ld}
@emph{H8/300 Options}
@@ -12879,13 +12879,19 @@ These @samp{-m} options are defined for GNU/Linux targets:
@item -mglibc
@opindex mglibc
Use the GNU C library. This is the default except
-on @samp{*-*-linux-*uclibc*} and @samp{*-*-linux-*android*} targets.
+on @samp{*-*-linux-*uclibc*}, @samp{*-*-linux-*musl*} and
+@samp{*-*-linux-*android*} targets.
@item -muclibc
@opindex muclibc
Use uClibc C library. This is the default on
@samp{*-*-linux-*uclibc*} targets.
+@item -mmusl
+@opindex mmusl
+Use the musl C library. This is the default on
+@samp{*-*-linux-*musl*} targets.
+
@item -mbionic
@opindex mbionic
Use Bionic C library. This is the default on

View File

@ -0,0 +1,69 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Szabolcs Nagy <szabolcs.nagy@arm.com>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit 07ad804bfdbe0fa3406c5f2ff51d7c4c29a783c8
Add musl support to GCC
2015-05-08 Szabolcs Nagy <szabolcs.nagy@arm.com>
* config/glibc-stdint.h (OPTION_MUSL): Define.
(INT_FAST16_TYPE, INT_FAST32_TYPE, UINT_FAST16_TYPE, UINT_FAST32_TYPE):
Change the definition based on OPTION_MUSL for 64 bit targets.
* config/linux.h (OPTION_MUSL): Redefine.
* config/alpha/linux.h (OPTION_MUSL): Redefine.
* config/rs6000/linux.h (OPTION_MUSL): Redefine.
* config/rs6000/linux64.h (OPTION_MUSL): Redefine.
From-SVN: r222905
--- gcc/config/glibc-stdint.h
+++ gcc/config/glibc-stdint.h
@@ -22,6 +22,12 @@ a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
+/* Systems using musl libc should use this header and make sure
+ OPTION_MUSL is defined correctly before using the TYPE macros. */
+#ifndef OPTION_MUSL
+#define OPTION_MUSL 0
+#endif
+
#define SIG_ATOMIC_TYPE "int"
#define INT8_TYPE "signed char"
@@ -43,12 +49,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
#define INT_FAST8_TYPE "signed char"
-#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
-#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
+#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
+#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long int" : "int")
#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int")
#define UINT_FAST8_TYPE "unsigned char"
-#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
-#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int")
+#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
+#define UINT_FAST32_TYPE (LONG_TYPE_SIZE == 64 && !OPTION_MUSL ? "long unsigned int" : "unsigned int")
#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int")
#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int")
--- gcc/config/linux.h
+++ gcc/config/linux.h
@@ -33,11 +33,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define OPTION_GLIBC (DEFAULT_LIBC == LIBC_GLIBC)
#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
+#undef OPTION_MUSL
#define OPTION_MUSL (DEFAULT_LIBC == LIBC_MUSL)
#else
#define OPTION_GLIBC (linux_libc == LIBC_GLIBC)
#define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
#define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
+#undef OPTION_MUSL
#define OPTION_MUSL (linux_libc == LIBC_MUSL)
#endif

View File

@ -0,0 +1,39 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Gregor Richards <gregor.richards@uwaterloo.ca>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit cf57e99350d0b44876979c71986d8ca29c361f83
x86 musl support
2015-05-15 Gregor Richards <gregor.richards@uwaterloo.ca>
* config/i386/linux.h (MUSL_DYNAMIC_LINKER): Define.
* config/i386/linux64.h (MUSL_DYNAMIC_LINKER32): Define.
(MUSL_DYNAMIC_LINKER64, MUSL_DYNAMIC_LINKERX32): Define.
From-SVN: r223218
--- gcc/config/i386/linux.h
+++ gcc/config/i386/linux.h
@@ -22,3 +22,6 @@ along with GCC; see the file COPYING3. If not see
#define GNU_USER_LINK_EMULATION "elf_i386"
#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+#undef MUSL_DYNAMIC_LINKER
+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
--- gcc/config/i386/linux64.h
+++ gcc/config/i386/linux64.h
@@ -31,3 +31,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
+
+#undef MUSL_DYNAMIC_LINKER32
+#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
+#undef MUSL_DYNAMIC_LINKER64
+#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
+#undef MUSL_DYNAMIC_LINKERX32
+#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"

View File

@ -0,0 +1,21 @@
SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
SPDX-FileCopyrightText: 2015 Doug Evans <dje@google.com>
SPDX-License-Identifier: GPL-2.0-or-later
Backported from upstream commit 755658a56b57beca14b5fb70afdf1e588a058f7f
config/linux.h (INCLUDE_DEFAULTS): Add INCLUDE_DEFAULTS_MUSL_LOCAL.
From-SVN: r229392
--- gcc/config/linux.h
+++ gcc/config/linux.h
@@ -184,6 +184,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define INCLUDE_DEFAULTS \
{ \
INCLUDE_DEFAULTS_MUSL_GPP \
+ INCLUDE_DEFAULTS_MUSL_LOCAL \
INCLUDE_DEFAULTS_MUSL_PREFIX \
INCLUDE_DEFAULTS_MUSL_CROSS \
INCLUDE_DEFAULTS_MUSL_TOOL \

View File

@ -1,17 +0,0 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-License-Identifier: GPL-3.0-or-later
Add support for *-linux-musl triplet.
--- libstdc++-v3/configure.host 2021-07-07 10:00:23.934848223 +0100
+++ libstdc++-v3/configure.host 2021-07-07 10:00:36.295195348 +0100
@@ -242,6 +242,9 @@
freebsd*)
os_include_dir="os/bsd/freebsd"
;;
+ linux-musl*)
+ os_include_dir="os/generic"
+ ;;
gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
if [ "$uclibc" = "yes" ]; then
os_include_dir="os/uclibc"

View File

@ -0,0 +1 @@
/usr/lib/musl

36
sysc/musl-1.2.3/musl-1.2.3.sh Executable file
View File

@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2022 Dor Askayo <dor.askayo@gmail.com>
# SPDX-FileCopyrightText: 2022 Andrius Štikonas <andrius@stikonas.eu>
#
# SPDX-License-Identifier: GPL-3.0-or-later
urls="https://musl.libc.org/releases/musl-1.2.3.tar.gz"
src_configure() {
./configure \
--host=i386-unknown-linux-musl \
--prefix="${PREFIX}" \
--libdir="${PREFIX}/lib/musl" \
--includedir="${PREFIX}/include/"
}
src_compile() {
make CROSS_COMPILE=
}
src_install() {
default
# Make dynamic linker symlink relative in ${PREFIX}/lib
rm "${DESTDIR}/lib/ld-musl-i386.so.1"
rmdir "${DESTDIR}/lib"
mkdir -p "${DESTDIR}${PREFIX}/lib"
ln -sr "${DESTDIR}${PREFIX}/lib/musl/libc.so" "${DESTDIR}${PREFIX}/lib/ld-musl-i386.so.1"
# Add symlink for ldd
mkdir -p "${DESTDIR}${PREFIX}/bin"
ln -s ../lib/ld-musl-i386.so.1 "${DESTDIR}${PREFIX}/bin/ldd"
# Add library search path configurtion
mkdir -p "${DESTDIR}/etc"
cp ../../ld-musl-i386.path "${DESTDIR}/etc"
}

View File

@ -84,6 +84,8 @@ build gcc-4.7.4
build binutils-2.38 build binutils-2.38
build musl-1.2.3
build gperf-3.1 build gperf-3.1
build libunistring-0.9.10 build libunistring-0.9.10