summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-08-14 09:25:38 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-08-16 14:31:53 +0000
commit9ac501477bd7539a2bf0fa0cf8c541ef1e505e17 (patch)
tree94121b4458d6a881e983ded9475b54ea90b2ab32
parent3be8a5567f606f621689fd0af1331442aa5ed325 (diff)
downloadeglibc2-baserock/richardmaw/S8564/ro-staging-area.tar.gz
stage2-eglibc: install fixed specs during stage2baserock/richardmaw/S8564/ro-staging-area
Stage 2 needs altered specs to use the libraries in the sysroot. Previously we would install a script to fix those specs, but we can't write to the staging area any more, except by adding new chunks. So now we install the specs and a symlink to it. The symlink is there so that after we no longer need the specs, we can point the symlink to a path that doesn't exist, since gcc behaves differently when it has specs it would generate, to no specs. Changing this symlink works by the fact that later symlinks overwrite earlier ones.
-rw-r--r--stage2-eglibc-fix-specs18
-rw-r--r--stage2-eglibc.morph2
-rw-r--r--stage2-reset-specs.morph21
3 files changed, 37 insertions, 4 deletions
diff --git a/stage2-eglibc-fix-specs b/stage2-eglibc-fix-specs
index 82e292036..fec0d08d0 100644
--- a/stage2-eglibc-fix-specs
+++ b/stage2-eglibc-fix-specs
@@ -16,11 +16,23 @@
set -eu
+sysroot="$(dirname "$(pwd)")"
specs_dir="$(dirname $($TARGET_STAGE1-gcc --print-libgcc-file-name))"
-mkdir -p "$specs_dir"
+target_specs_dir="$DESTDIR/${specs_dir#$sysroot}"
+mkdir -p "$target_specs_dir"
-$TARGET_STAGE1-gcc -dumpspecs | \
+$TARGET_STAGE1-gcc -dumpspecs |
sed -e "s@[gMS]\?crt[1in].o%s@%:getenv(STAGE2_SYSROOT $PREFIX/lib/&)@g" \
-e "s@/lib\(64\)\?/ld@$PREFIX/lib/ld@g" \
- > "$specs_dir/specs"
+ > "$target_specs_dir/specs-for-sysroot"
+# NASTY HACK #
+# We create a symlink to the actual specs here, so that later the
+# symlink can be replaced with a dangling link.
+#
+# This is necessary as we need to have gcc use its internal specs,
+# which can differ to the specs generated by `gcc -dumpspecs`.
+#
+# The dangling symlink will not make it onto the final system, just
+# like all other bootstrap only components.
+ln -s specs-for-sysroot "$target_specs_dir/specs"
diff --git a/stage2-eglibc.morph b/stage2-eglibc.morph
index 85b448533..8041821a0 100644
--- a/stage2-eglibc.morph
+++ b/stage2-eglibc.morph
@@ -31,7 +31,7 @@ build-commands:
install-commands:
- cd o && make install_root="$DESTDIR" localtime=UTC install
- - install -m 755 stage2-eglibc-fix-specs $DESTDIR$PREFIX/bin
+ - sh stage2-eglibc-fix-specs
# Install a symlink for the program interpreter (ld.so) so that binaries
# built in stage 3 before the stage 3 eglibc is built can use it.
diff --git a/stage2-reset-specs.morph b/stage2-reset-specs.morph
new file mode 100644
index 000000000..387ef835d
--- /dev/null
+++ b/stage2-reset-specs.morph
@@ -0,0 +1,21 @@
+name: stage2-reset-specs
+kind: chunk
+
+# Nasty hack to get around being unable to reliably add configuration to gcc,
+# hence the gcc specs are modified, combined with Baserock's rootfs protection
+# preventing specs being modified before builds.
+# The limitation is overcome by installing files as part of a chunk, which
+# overwrites previous files.
+# New specs were added for the bootstrap builds, but after stage2 we start
+# having chrooted builds, so the old specs need to be replaced.
+# Unfortunately we can't just replace the specs with the ones gcc produces,
+# since gcc behaves differently without specs to with specs it produces!
+# So we use a **NASTY HACK** to replace the specs symlink with one that
+# points to a file that doesn't exist.
+install-commands:
+ - |
+ STAGE2_SYSROOT="$(dirname "$(pwd)")"
+ specs_dir="$(dirname $($TARGET_STAGE1-gcc -print-libgcc-file-name))"
+ target_specs_dir="$DESTDIR/${specs_dir#$STAGE2_SYSROOT}"
+ mkdir -p "$target_specs_dir"
+ ln -s "temporary specs removed by baserock bootstrap" "$target_specs_dir/specs"