diff options
-rw-r--r-- | stage2-eglibc-fix-specs | 18 | ||||
-rw-r--r-- | stage2-eglibc.morph | 2 | ||||
-rw-r--r-- | stage2-reset-specs.morph | 21 |
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" |