Skip to content

Commit

Permalink
Merge pull request #490 from fosslinux/musl-fixup
Browse files Browse the repository at this point in the history
Musl fixes
  • Loading branch information
fosslinux authored Feb 4, 2025
2 parents c5175b4 + 19b205a commit d652494
Show file tree
Hide file tree
Showing 24 changed files with 223 additions and 128 deletions.
34 changes: 22 additions & 12 deletions parts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ patch 2.5.9
``patch`` is a very useful tool at this stage, allowing us to make
significantly more complex edits, including just changes to lines.

gzip 1.2.4
gzip 1.2.5
==========

``gzip`` is the most common compression format used for software source
Expand Down Expand Up @@ -399,6 +399,9 @@ from building many newer or more complex programs.
``tcc`` has slight problems when building and linking ``musl``, so we
apply a few patches.

We also get rid of a few functions from ``musl``, as they rely on pregenerated
files we are unable to generate at this stage.

We do not use any of ``/usr/lib/mes`` or ``/usr/include/mes`` any longer, rather
using ``/usr/lib`` and ``/usr/include`` like normal.

Expand All @@ -422,6 +425,19 @@ tcc 0.9.27 (musl v2)
Now that we have a ‘fixed’ ``musl``, we now recompile ``tcc`` as ``tcc``
uses floats extensively.

grep 2.4
========

GNU ``grep`` is a pattern matching utility. ``grep`` is needed to rebuild some
generated header files in ``musl``.

musl 1.1.24 (v3)
================

We are now able to regenerate those header files that we couldn't regenerate
earlier. We unlock the full range of ``musl`` support, required for a
number of applications (e.g. ``flex``) before the next ``musl`` rebuild.

sed 4.0.9
=========

Expand Down Expand Up @@ -485,12 +501,6 @@ a 3 stage process:

Finally we have a fully functional ``bison`` executable.

grep 2.4
========

GNU ``grep`` is a pattern matching utility. Is is not immediately needed
but will be useful later for autotools.

diffutils 2.7
=============

Expand Down Expand Up @@ -692,10 +702,10 @@ In particular we can now use full featured ``ar`` instead of ``tcc -ar``,
the GNU linker ``ld``, which allows us building shared libraries,
and the GNU assembler ``as``.

musl 1.1.24 (v3)
musl 1.1.24 (v4)
================

We rebuild musl for the third time. This time we can use GNU as to build assembly source files,
We rebuild musl for the fourth time. This time we can use GNU as to build assembly source files,
so those assembly files that tcc failed to compile no longer have to be patched.

tcc 0.9.27 (musl v3)
Expand All @@ -722,7 +732,7 @@ findutils 4.2.33
GNU Find Utilities can be used to search for files. We are mainly interested
in ``find`` and ``xargs`` that are often used in scripts.

musl 1.2.4
musl 1.2.5
==========

GCC can build the latest as of the time of writing musl version.
Expand Down Expand Up @@ -879,7 +889,7 @@ swap
If enabled in ``bootstrap.cfg``, creates and activates a swap file under the
name ``/swapfile``.

musl 1.2.4
musl 1.2.5
==========

At this point, it is guaranteed that we are running on Linux with thread support,
Expand Down Expand Up @@ -1173,7 +1183,7 @@ We use the `gnu-autogen-bootstrapping <https://github.com/schierlm/gnu-autogen-b
project to rebuild those and create (slightly crippled) ``autogen`` that
is then able to build a full-featured version.

musl 1.2.4
musl 1.2.5
==========

With GCC and binutils supporting a musl-based toolchain natively, musl itself is rebuilt
Expand Down
179 changes: 90 additions & 89 deletions steps/SHA256SUMS.pkgs

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions steps/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ build: musl-1.1.24
build: tcc-0.9.27
build: musl-1.1.24
build: tcc-0.9.27
build: grep-2.4
build: musl-1.1.24
build: sed-4.0.9
build: bzip2-1.0.8
build: m4-1.4.7
Expand All @@ -74,7 +76,6 @@ uninstall: heirloom-devtools-070527
build: bison-3.4.1
build: bison-3.4.1
build: bison-3.4.1
build: grep-2.4
build: diffutils-2.7
build: coreutils-5.0
build: coreutils-6.10
Expand Down Expand Up @@ -111,7 +112,7 @@ build: tcc-0.9.27
improve: populate_device_nodes
build: gcc-4.0.4
build: findutils-4.2.33
build: musl-1.2.4
build: musl-1.2.5
build: linux-headers-4.14.341-openela
build: gcc-4.0.4
build: util-linux-2.19.1
Expand All @@ -135,7 +136,7 @@ improve: finalize_job_count
improve: finalize_fhs
improve: open_console ( CONSOLES == True )
improve: swap ( SWAP_SIZE != 0 )
build: musl-1.2.4
build: musl-1.2.5
build: curl-8.5.0
improve: get_network ( CHROOT == False )
build: bash-5.2.15
Expand Down Expand Up @@ -180,7 +181,7 @@ build: which-2.21
build: grep-3.7
build: sed-4.8
build: autogen-5.18.16
build: musl-1.2.4
build: musl-1.2.5
build: python-2.0.1
build: python-2.0.1
build: python-2.3.7
Expand Down
53 changes: 53 additions & 0 deletions steps/musl-1.1.24/files/disable_ctype_headers.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
SPDX-FileCopyrightText: 2024 fosslinux <[email protected]>

SPDX-License-Identifier: MIT

diff --color -ru include/wchar.h include/wchar.h
--- musl-chartable-tools-44d780e03e78efcb3168ceab068170206dc92e85/include/wchar.h 2024-12-21 11:29:46.207537390 +1100
+++ musl-chartable-tools-44d780e03e78efcb3168ceab068170206dc92e85/include/wchar.h 2024-12-21 12:03:00.494377416 +1100
@@ -175,10 +175,7 @@
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
int wcwidth (wchar_t);
int wcswidth (const wchar_t *, size_t);
-int iswalnum(wint_t);
-int iswalpha(wint_t);
int iswblank(wint_t);
-int iswcntrl(wint_t);
int iswdigit(wint_t);
int iswgraph(wint_t);
int iswlower(wint_t);
@@ -187,9 +184,6 @@
int iswspace(wint_t);
int iswupper(wint_t);
int iswxdigit(wint_t);
-int iswctype(wint_t, wctype_t);
-wint_t towlower(wint_t);
-wint_t towupper(wint_t);
wctype_t wctype(const char *);

#ifndef __cplusplus
diff --color -ru include/wctype.h include/wctype.h
--- musl-chartable-tools-44d780e03e78efcb3168ceab068170206dc92e85/include/wctype.h 2024-12-21 11:29:46.207537390 +1100
+++ musl-chartable-tools-44d780e03e78efcb3168ceab068170206dc92e85/include/wctype.h 2024-12-21 12:07:48.030354351 +1100
@@ -24,10 +24,7 @@

#undef iswdigit

-int iswalnum(wint_t);
-int iswalpha(wint_t);
int iswblank(wint_t);
-int iswcntrl(wint_t);
int iswdigit(wint_t);
int iswgraph(wint_t);
int iswlower(wint_t);
@@ -36,10 +33,6 @@
int iswspace(wint_t);
int iswupper(wint_t);
int iswxdigit(wint_t);
-int iswctype(wint_t, wctype_t);
-wint_t towctrans(wint_t, wctrans_t);
-wint_t towlower(wint_t);
-wint_t towupper(wint_t);
wctrans_t wctrans(const char *);
wctype_t wctype(const char *);

7 changes: 7 additions & 0 deletions steps/musl-1.1.24/pass1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
src_prepare() {
default

# meslibc is insufficient to regenerate src/ctype or src/iconv
# disable everything using a generated header
patch -Np1 -i ../../files/disable_ctype_headers.patch
rm src/ctype/iswalpha.c src/ctype/iswalnum.c src/ctype/iswctype.c \
src/ctype/towctrans.c
rm include/iconv.h src/locale/iconv.c src/locale/iconv_close.c

# tcc does not support complex types
rm -rf src/complex

Expand Down
11 changes: 5 additions & 6 deletions steps/musl-1.1.24/pass3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ src_prepare() {

# tcc does not support complex types
rm -rf src/complex

# Configure fails without this
mkdir -p /dev
}

src_configure() {
Expand All @@ -15,7 +18,7 @@ src_configure() {
--disable-shared \
--prefix="${PREFIX}" \
--libdir="${LIBDIR}" \
--includedir="${PREFIX}/include"
--includedir="${PREFIX}/include/"

# configure script creates this file
if test -f /dev/null; then
Expand All @@ -24,9 +27,5 @@ src_configure() {
}

src_compile() {
make "${MAKEJOBS}" PREFIX="${PREFIX}" CROSS_COMPILE= CFLAGS="-DSYSCALL_NO_TLS" AS_CMD='as -o $@ $<'
}

src_install() {
make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install
make "${MAKEJOBS}" CROSS_COMPILE= AR="tcc -ar" RANLIB=true CFLAGS="-DSYSCALL_NO_TLS"
}
32 changes: 32 additions & 0 deletions steps/musl-1.1.24/pass4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2021 Andrius Štikonas <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

src_prepare() {
default

# tcc does not support complex types
rm -rf src/complex
}

src_configure() {
CC=tcc ./configure \
--host=i386 \
--disable-shared \
--prefix="${PREFIX}" \
--libdir="${LIBDIR}" \
--includedir="${PREFIX}/include"

# configure script creates this file
if test -f /dev/null; then
rm /dev/null
fi
}

src_compile() {
make "${MAKEJOBS}" PREFIX="${PREFIX}" CROSS_COMPILE= CFLAGS="-DSYSCALL_NO_TLS" AS_CMD='as -o $@ $<'
}

src_install() {
make PREFIX="${PREFIX}" DESTDIR="${DESTDIR}" install
}
8 changes: 0 additions & 8 deletions steps/musl-1.2.4/files/__stack_chk_fail_local.c

This file was deleted.

1 change: 0 additions & 1 deletion steps/musl-1.2.4/sources

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SPDX-FileCopyrightText: 2023 Richard Masters <[email protected]>
# SPDX-License-Identifier: MIT
diff -r -u musl-1.2.3.orig/arch/i386/pthread_arch.h musl-1.2.3/arch/i386/pthread_arch.h
--- musl-1.2.4/arch/i386/pthread_arch.h 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.4/arch/i386/pthread_arch.h 2023-04-07 12:07:07.929132587 +0000
--- musl-1.2.5/arch/i386/pthread_arch.h 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.5/arch/i386/pthread_arch.h 2023-04-07 12:07:07.929132587 +0000
@@ -1,8 +1,7 @@
+extern uintptr_t g_pthread;
static inline uintptr_t __get_tp()
Expand All @@ -15,16 +15,16 @@ diff -r -u musl-1.2.3.orig/arch/i386/pthread_arch.h musl-1.2.3/arch/i386/pthread

#define MC_PC gregs[REG_EIP]
diff -r -u musl-1.2.3.orig/arch/i386/syscall_arch.h musl-1.2.3/arch/i386/syscall_arch.h
--- musl-1.2.4/arch/i386/syscall_arch.h 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.4/arch/i386/syscall_arch.h 2022-12-20 17:28:21.734839560 +0000
--- musl-1.2.5/arch/i386/syscall_arch.h 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.5/arch/i386/syscall_arch.h 2022-12-20 17:28:21.734839560 +0000
@@ -1,3 +1,4 @@
+#define SYSCALL_NO_TLS 1
#define __SYSCALL_LL_E(x) \
((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
((union { long long ll; long l[2]; }){ .ll = x }).l[1]
diff -r -u musl-1.2.3.orig/src/env/__init_tls.c musl-1.2.3/src/env/__init_tls.c
--- musl-1.2.4/src/env/__init_tls.c 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.4/src/env/__init_tls.c 2023-04-07 12:07:38.677133193 +0000
--- musl-1.2.5/src/env/__init_tls.c 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.5/src/env/__init_tls.c 2023-04-07 12:07:38.677133193 +0000
@@ -10,20 +10,19 @@
#include "syscall.h"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2023 Richard Masters <[email protected]>
# SPDX-License-Identifier: MIT
--- musl-1.2.4/src/process/posix_spawn.c 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.4/src/process/posix_spawn.c 2023-04-07 12:01:57.217126467 +0000
--- musl-1.2.5/src/process/posix_spawn.c 2022-04-07 17:12:40.000000000 +0000
+++ musl-1.2.5/src/process/posix_spawn.c 2023-04-07 12:01:57.217126467 +0000
@@ -190,8 +190,11 @@
goto fail;
}
Expand Down
1 change: 1 addition & 0 deletions steps/musl-1.2.5/sources
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://musl.libc.org/releases/musl-1.2.5.tar.gz a9a118bbe84d8764da0ea0d28b3ab3fae8477fc7e4085d90102b8596fc7c75e4

0 comments on commit d652494

Please sign in to comment.