Splux Linux

source-based Linux using SPS

SPS · log · files · refs · tags · releases · people · languages · GitHub · commit

5e01e14


mkiso: copy glibc startfiles so the live gcc can link

Date
Commit5e01e1451244f3233980ddabe6361edeed1e43ba
GitHubmirror

Parents

Stat

 bin/mkiso              | 21 +++++++++++++++++++++
 lib/setup/partition.sh |  4 ++++
 tests/test_mkiso.sh    |  4 ++++
 tests/test_setup.sh    |  3 +++
 4 files changed, 32 insertions(+)

Diff

diff --git a/bin/mkiso b/bin/mkiso
index d92ee69..ac7fedd 100755
--- a/bin/mkiso
+++ b/bin/mkiso
@@ -812,7 +812,28 @@ if [ "$mkiso_copy_seed" -eq 1 ] && [ -f "$mkiso_libdir/seed-bins" ]; then
 	# Compiler support files.
 	mkiso_copy_path /usr/libexec/gcc
 	mkiso_copy_path /usr/lib64/gcc
+	mkiso_copy_path /usr/lib/gcc
 	mkiso_copy_path /usr/include
+	# gcc and ld without glibc startfiles fail the first autoconf check
+	# with "C compiler cannot create executables". Runtime libc.so.6 is
+	# not enough; the linker needs crt1.o and the libc.so script.
+	printf '%s: copying glibc startfiles for the seed compiler\n' \
+		"$sps_prog" >&2
+	for mkiso_crt in /usr/lib64/crt1.o /usr/lib64/crti.o /usr/lib64/crtn.o \
+		/usr/lib64/Scrt1.o /usr/lib64/gcrt1.o /usr/lib64/Mcrt1.o \
+		/lib64/crt1.o /lib64/crti.o /lib64/crtn.o \
+		/usr/lib64/libc.so /usr/lib64/libm.so /usr/lib64/libmvec.so \
+		/usr/lib64/libpthread.so /usr/lib64/libdl.so \
+		/usr/lib64/librt.so /usr/lib64/libutil.so \
+		/usr/lib64/libresolv.so /usr/lib64/libanl.so \
+		/usr/lib64/libthread_db.so /usr/lib64/libgcc_s.so \
+		/usr/lib64/libstdc++.so /usr/lib64/libc_nonshared.a \
+		/usr/lib64/libpthread_nonshared.a \
+		/usr/lib64/libmvec_nonshared.a
+	do
+		[ -e "$mkiso_crt" ] || [ -L "$mkiso_crt" ] || continue
+		mkiso_copy_path "$mkiso_crt"
+	done
 	mkiso_copy_path /usr/lib64/python3.12
 	mkiso_copy_path /usr/share/terminfo
 	mkiso_copy_path /usr/share/zoneinfo
diff --git a/lib/setup/partition.sh b/lib/setup/partition.sh
index e139fdf..2b392e8 100644
--- a/lib/setup/partition.sh
+++ b/lib/setup/partition.sh
@@ -151,6 +151,8 @@ setup_mount_prepared()
 	[ -n "$setup_part_root" ] || return 1
 	mkdir -p "$setup_tgt" || return 1
 	mount "$setup_part_root" "$setup_tgt" || return 1
+	# autoconf links and runs conftest in $SPS_BUILD on this mount.
+	mount -o remount,rw,exec,suid,dev "$setup_tgt" 2>/dev/null || :
 	if [ -n "$setup_part_efi" ]; then
 		mkdir -p "$setup_tgt/boot/efi"
 		mount "$setup_part_efi" "$setup_tgt/boot/efi" || return 1
@@ -183,6 +185,8 @@ setup_format_and_mount()
 	fi
 
 	mount "$setup_part_root" "$setup_tgt" || return 1
+	# autoconf links and runs conftest in $SPS_BUILD on this mount.
+	mount -o remount,rw,exec,suid,dev "$setup_tgt" 2>/dev/null || :
 	if [ -n "$setup_part_efi" ]; then
 		mkdir -p "$setup_tgt/boot/efi"
 		mount "$setup_part_efi" "$setup_tgt/boot/efi" || return 1
diff --git a/tests/test_mkiso.sh b/tests/test_mkiso.sh
index 0a44c80..6541f44 100755
--- a/tests/test_mkiso.sh
+++ b/tests/test_mkiso.sh
@@ -163,6 +163,10 @@ if command -v lsblk >/dev/null 2>&1; then
 		fail 'lsblk missing from live layout (setup disk menu needs it)'
 	fi
 fi
+grep -q 'copying glibc startfiles' "$mkiso" ||
+	fail 'seeded ISO must copy glibc crt1.o for gcc'
+grep -q crt1.o "$mkiso" ||
+	fail 'mkiso must copy crt1.o with the seed compiler'
 grep -q 'copying disk tools for setup' "$mkiso" ||
 	fail 'mkiso must copy partition tools by command name'
 grep -q grub-install "$mkiso" ||
diff --git a/tests/test_setup.sh b/tests/test_setup.sh
index 9348e03..56c9a67 100755
--- a/tests/test_setup.sh
+++ b/tests/test_setup.sh
@@ -261,6 +261,9 @@ set -e
 [ "$st" -eq 2 ] || fail "guided without --format yes returned $st"
 contains "$(cat "$tmp/err")" '--format yes'
 
+grep -q 'remount,rw,exec' "$project_dir/lib/setup/partition.sh" ||
+	fail 'setup must remount the target exec so autoconf can run conftest'
+
 plan=$("$setup" --plan --target /mnt --profile plasma-desktop --init systemd \
 	--disable qol-cli --disable power --disable firmware)
 contains "$plan" 'Init:       systemd'