summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <jjardon@gnome.org>2015-04-03 18:35:43 +0100
committerBaserock Gerrit <gerrit@baserock.org>2015-04-07 09:43:00 +0000
commitadebf15d27ed0281e9ecab52e984e7f6911df483 (patch)
tree6627e9dd29246e1a9f915b7cedee0ab06dd74dbc
parentc0815dcce13b32390a7b63ad32010c1b76d59c1f (diff)
downloaddefinitions-adebf15d27ed0281e9ecab52e984e7f6911df483.tar.gz
stage2-glibc.morph: inline stage2-glibc-fix-specs script
Change-Id: I55bf8764a105308d965947c3721a193abf7502ac
-rw-r--r--strata/build-essential/stage2-glibc.morph36
1 files changed, 35 insertions, 1 deletions
diff --git a/strata/build-essential/stage2-glibc.morph b/strata/build-essential/stage2-glibc.morph
index 7346cd3b..9e5e745b 100644
--- a/strata/build-essential/stage2-glibc.morph
+++ b/strata/build-essential/stage2-glibc.morph
@@ -41,7 +41,41 @@ install-commands:
include /etc/ld.so.conf.d/*.conf
EOF
- install -m 644 -o root -g root ld.so.conf "$DESTDIR/etc/ld.so.conf"
-- sh stage2-glibc-fix-specs
+- |
+ # Fix up GCC to handle the sysroot containing glibc being in a different
+ # location for each chunk build.
+ #
+ # For headers, it's enough to pass -B in the CPPFLAGS. This would work for
+ # the startup files (crt*.o) as well, except where libtool is involved (in
+ # which case it strips -B out of your LDFLAGS before calling GCC). We get
+ # around this by making GCC locate them relative to the environment variable
+ # STAGE2_SYSROOT, which we can then set along with CPPFLAGS in each stage 2
+ # chunk build.
+ #
+ # We also force the use of the program loader at PREFIX/lib/ld.so instead
+ # of its usual home in /lib or /lib64, which is necessary for the output of
+ # stage 2 to work as a chroot when building stage 3.
+
+ sysroot="$(dirname "$(pwd)")"
+ specs_dir="$(dirname $($TARGET_STAGE1-gcc --print-libgcc-file-name))"
+ target_specs_dir="$DESTDIR/${specs_dir#$sysroot}"
+ mkdir -p "$target_specs_dir"
+
+ $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" \
+ > "$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"
# Install a symlink for the program interpreter (ld.so) so that binaries
# built in stage 3 before the stage 3 glibc is built can use it.