From f3cea25b87c917c72680a1f9d433f238015019f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 3 Mar 2021 00:05:33 +0000 Subject: [PATCH 1/2] Rebuild musl with fewer patches. --- parts.rst | 7 +++++ sysa/helpers.sh | 2 +- sysa/musl-1.1.24/binutils-rebuild.sh | 26 +++++++++++++++++++ sysa/musl-1.1.24/checksums/pass3 | 14 ++++++++++ .../patches-pass3/set_thread_area.patch | 1 + .../patches-pass3/tcc_static.patch | 1 + sysa/musl-1.1.24/patches-pass3/va_list.patch | 1 + sysa/run.sh | 4 +++ 8 files changed, 55 insertions(+), 1 deletion(-) create mode 100755 sysa/musl-1.1.24/binutils-rebuild.sh create mode 100644 sysa/musl-1.1.24/checksums/pass3 create mode 120000 sysa/musl-1.1.24/patches-pass3/set_thread_area.patch create mode 120000 sysa/musl-1.1.24/patches-pass3/tcc_static.patch create mode 120000 sysa/musl-1.1.24/patches-pass3/va_list.patch diff --git a/parts.rst b/parts.rst index 0f492f5..e229ebf 100644 --- a/parts.rst +++ b/parts.rst @@ -407,3 +407,10 @@ managing binary programs, object files, libraries, profile data, and assembly so 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 +=========== + +We rebuild musl for the third time. This time we use GNU ar rather than ``tcc -ar``, +so we can drop weak symbols patch. Also, 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. diff --git a/sysa/helpers.sh b/sysa/helpers.sh index d1f3526..e652358 100755 --- a/sysa/helpers.sh +++ b/sysa/helpers.sh @@ -22,7 +22,7 @@ build () { cd "$pkg" || (echo "Cannot cd into ${pkg}!"; kill $$) echo "${pkg}: beginning build using script ${script_name}" base_dir="${PWD}" - patch_dir="${base_dir}/patches" + patch_dir="${base_dir}/${4:-patches}" mk_dir="${base_dir}/mk" files_dir="${base_dir}/files" diff --git a/sysa/musl-1.1.24/binutils-rebuild.sh b/sysa/musl-1.1.24/binutils-rebuild.sh new file mode 100755 index 0000000..f465148 --- /dev/null +++ b/sysa/musl-1.1.24/binutils-rebuild.sh @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2021 Andrius Štikonas +# +# SPDX-License-Identifier: GPL-3.0-or-later + +src_prepare() { + default_src_prepare + + # tcc does not support complex types + rm -rf src/complex +} + +src_configure() { + CC=tcc ./configure \ + --host=i386 \ + --disable-shared \ + --prefix=/after \ + --libdir=/after/lib/musl/ \ + --includedir=/after/include/musl + + # configure script creates this file + test -f /dev/null && rm /dev/null +} + +src_compile() { + make CROSS_COMPILE= CFLAGS="-DSYSCALL_NO_TLS" AS_CMD='as -o $@ $<' +} diff --git a/sysa/musl-1.1.24/checksums/pass3 b/sysa/musl-1.1.24/checksums/pass3 new file mode 100644 index 0000000..54122d5 --- /dev/null +++ b/sysa/musl-1.1.24/checksums/pass3 @@ -0,0 +1,14 @@ +a50500329680bed4dcc5ec3891fd50f65af9cae7de0b8e8fe925c37f1c6bb16b /after/lib/musl/Scrt1.o +457fff81b3188b82621f3ae49847ebc60128017fcbdba012245169af76cf122a /after/lib/musl/crt1.o +73f64b61e6e9ae83726ab4cc909a7b549b06b6df2b087aedddbcd39cb7146f69 /after/lib/musl/crti.o +f5e325819d86fb381574692b8f9ea24f88f44f185a75adfe461705ecf2619c6e /after/lib/musl/crtn.o +a18d576a501a596ffe67df13eeededeca0d61da42100b9b5687be3d479379641 /after/lib/musl/libc.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/libcrypt.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/libdl.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/libm.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/libpthread.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/libresolv.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/librt.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/libutil.a +f0a17a43c74d2fe5474fa2fd29c8f14799e777d7d75a2cc4d11c20a6e7b161c5 /after/lib/musl/libxnet.a +b60b59a94f10f039977cea2cea6f15b55b402b25df2e1b2a4e83fa84ccf2fd43 /after/lib/musl/rcrt1.o diff --git a/sysa/musl-1.1.24/patches-pass3/set_thread_area.patch b/sysa/musl-1.1.24/patches-pass3/set_thread_area.patch new file mode 120000 index 0000000..e1389ab --- /dev/null +++ b/sysa/musl-1.1.24/patches-pass3/set_thread_area.patch @@ -0,0 +1 @@ +../patches/set_thread_area.patch \ No newline at end of file diff --git a/sysa/musl-1.1.24/patches-pass3/tcc_static.patch b/sysa/musl-1.1.24/patches-pass3/tcc_static.patch new file mode 120000 index 0000000..be8c7ac --- /dev/null +++ b/sysa/musl-1.1.24/patches-pass3/tcc_static.patch @@ -0,0 +1 @@ +../patches/tcc_static.patch \ No newline at end of file diff --git a/sysa/musl-1.1.24/patches-pass3/va_list.patch b/sysa/musl-1.1.24/patches-pass3/va_list.patch new file mode 120000 index 0000000..d71877f --- /dev/null +++ b/sysa/musl-1.1.24/patches-pass3/va_list.patch @@ -0,0 +1 @@ +../patches/va_list.patch \ No newline at end of file diff --git a/sysa/run.sh b/sysa/run.sh index 309cf15..35ed13c 100755 --- a/sysa/run.sh +++ b/sysa/run.sh @@ -84,4 +84,8 @@ build autoconf-2.12 build binutils-2.14 +# Build musl with fewer patches +build musl-1.1.24 binutils-rebuild.sh checksums/pass3 patches-pass3 +populate_device_nodes + echo "Bootstrapping completed." From 7a4ca8e634fad3b36e7e97525c29f9a2eb0836ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Wed, 3 Mar 2021 00:54:17 +0000 Subject: [PATCH 2/2] Rebuild tcc against new musl. --- parts.rst | 9 ++++- sysa/run.sh | 3 ++ sysa/tcc-0.9.27/checksums/tcc-musl-pass3 | 2 + sysa/tcc-0.9.27/tcc-musl-pass2.sh | 4 +- sysa/tcc-0.9.27/tcc-musl-pass3.sh | 47 ++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 sysa/tcc-0.9.27/checksums/tcc-musl-pass3 create mode 100755 sysa/tcc-0.9.27/tcc-musl-pass3.sh diff --git a/parts.rst b/parts.rst index e229ebf..b07d4b3 100644 --- a/parts.rst +++ b/parts.rst @@ -408,9 +408,14 @@ 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 -=========== +musl 1.1.24 (v3) +================ We rebuild musl for the third time. This time we use GNU ar rather than ``tcc -ar``, so we can drop weak symbols patch. Also, 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) +==================== + +We rebuild tcc against new musl and without a patch to ignore duplicate symbols. diff --git a/sysa/run.sh b/sysa/run.sh index 35ed13c..43976d3 100755 --- a/sysa/run.sh +++ b/sysa/run.sh @@ -88,4 +88,7 @@ build binutils-2.14 build musl-1.1.24 binutils-rebuild.sh checksums/pass3 patches-pass3 populate_device_nodes +# Rebuild tcc-musl using new musl +build tcc-0.9.27 tcc-musl-pass3.sh checksums/tcc-musl-pass3 + echo "Bootstrapping completed." diff --git a/sysa/tcc-0.9.27/checksums/tcc-musl-pass3 b/sysa/tcc-0.9.27/checksums/tcc-musl-pass3 new file mode 100644 index 0000000..cfb0091 --- /dev/null +++ b/sysa/tcc-0.9.27/checksums/tcc-musl-pass3 @@ -0,0 +1,2 @@ +f8023d637f64e1e739b5f381a000eafb0f2e500dc7967ebd90642d4a13c755f8 /after/bin/tcc-musl +a650b13efc65073fb851e9db89728089d8845c401f85faaa09801874ab058089 /after/lib/tcc/libtcc1.a diff --git a/sysa/tcc-0.9.27/tcc-musl-pass2.sh b/sysa/tcc-0.9.27/tcc-musl-pass2.sh index 3e96b0b..5e31dce 100755 --- a/sysa/tcc-0.9.27/tcc-musl-pass2.sh +++ b/sysa/tcc-0.9.27/tcc-musl-pass2.sh @@ -37,8 +37,8 @@ src_compile() { tcc.c # libtcc1.a - ${TCC} -c -D HAVE_CONFIG_H=1 lib/libtcc1.c - ${TCC} -ar cr libtcc1.a libtcc1.o + tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c + tcc-musl -ar cr libtcc1.a libtcc1.o } src_install() { diff --git a/sysa/tcc-0.9.27/tcc-musl-pass3.sh b/sysa/tcc-0.9.27/tcc-musl-pass3.sh new file mode 100755 index 0000000..07b2a2b --- /dev/null +++ b/sysa/tcc-0.9.27/tcc-musl-pass3.sh @@ -0,0 +1,47 @@ +# SPDX-FileCopyrightText: 2021 Andrius Štikonas +# SPDX-FileCopyrightText: 2021 fosslinux +# +# SPDX-License-Identifier: GPL-3.0-or-later + +src_unpack() { + cp -r ../src/tcc-0.9.27 . +} + +src_prepare() { + : +} + +src_compile() { + export prefix=/after + export libdir=${prefix}/lib/musl + export incdir=${prefix}/include/musl + export bindir=${prefix}/bin + + mkdir -p ${libdir}/tcc + + tcc-musl \ + -v \ + -static \ + -o tcc-musl \ + -D TCC_TARGET_I386=1 \ + -D CONFIG_TCCDIR=\"${libdir}/tcc\" \ + -D CONFIG_TCC_CRTPREFIX=\"${libdir}\" \ + -D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \ + -D CONFIG_TCC_LIBPATHS=\"${libdir}:${libdir}/tcc\" \ + -D CONFIG_TCC_SYSINCLUDEPATHS=\"${incdir}\" \ + -D TCC_LIBGCC=\"${libdir}/libc.a\" \ + -D CONFIG_TCC_STATIC=1 \ + -D CONFIG_USE_LIBGCC=1 \ + -D TCC_VERSION=\"0.9.27\" \ + -D ONE_SOURCE=1 \ + tcc.c + + # libtcc1.a + tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c + ar cr libtcc1.a libtcc1.o +} + +src_install() { + install tcc-musl ${bindir} + install -m 644 libtcc1.a ${libdir} +}