diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-02-01 20:37:29 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-02-03 19:48:45 +0900 |
commit | d85382e41efbe3f3f9012a08851f93bb4919de65 (patch) | |
tree | bdcdac1cd8463f6847b2b30a6b643e715144372d /build-essential/stage2-glibc.bst | |
parent | 7d6dc7242598361009ab492db2367e545fc53189 (diff) | |
download | definitions-d85382e41efbe3f3f9012a08851f93bb4919de65.tar.gz |
Manual conversion of Baserock's build-essential stratum
This huge commit is a manual conversion, notes on what was
needed:
o project.conf defines the arch specific stuff which was
previously hardcoded into YBD, so the stage1 target and target
etc are all defined by the build-essential project.conf
o Direct and easy changes for git source representation
o Added stage1.bst & stage2.bst "stacks", everything built in
stage2 build-depends on stage1.bst, and the final build-essential
products build-depend on stage2.bst (note build-depend means
to depend _only_ for building, not propagated forward).
o Instead of using host tools we build on the GNOME flatpak
sdk/platform bundles
o Some build-essential morph files use $(dirname $(pwd)) for a sysroot,
which is weird, it means the morph files rely on building at one directory
below the slash sysroot - in buildstream we build in /buildstream/build
which is two - had to replace these with $(dirname $(dirname $(pwd))) instead
o Remove the devices sections from the fhs-dirs elements, not allowed
to create static device nodes in buildstream.
Diffstat (limited to 'build-essential/stage2-glibc.bst')
-rw-r--r-- | build-essential/stage2-glibc.bst | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/build-essential/stage2-glibc.bst b/build-essential/stage2-glibc.bst new file mode 100644 index 00000000..0f0bace5 --- /dev/null +++ b/build-essential/stage2-glibc.bst @@ -0,0 +1,120 @@ +kind: manual + +sources: +- kind: git + url: upstream:glibc + track: release/2.22/master + ref: b995d95a5943785be3ab862b2d3276f3b4a22481 + +depends: +- filename: build-essential/stage1.bst + type: build +- build-essential/stage2-linux-api-headers.bst + +variables: + prefix: /tools + +environment: + PATH: /tools/bin:/usr/bin:/bin:/usr/sbin:/sbin + +config: + + configure-commands: + - mkdir o + + # Configure flag notes: + # 1. Avoid installing to PREFIX/lib64 on x86_64. + # 2. Location of linux-api-headers. + # 3. Normal flags. See glibc.morph. + # 4. Force configuration values of certain things that can't be detected + # in a cross-compile. + - | + case "%{bst-arch}" in + armv7*) + ARCH_FLAGS="--without-fp" ;; + esac + + export CFLAGS="-O2 $CFLAGS"; export CXX=false; \ + cd o && ../configure \ + $ARCH_FLAGS \ + --build=$(../scripts/config.guess) --host=%{target-stage1} \ + --prefix="%{prefix}" \ + `# [1]` --libdir="%{prefix}/lib" \ + `# [2]` --with-headers="%{prefix}/include" \ + `# [3]` --disable-profile --enable-kernel=2.6.25 \ + `# [4]` libc_cv_c_cleanup=yes libc_cv_ctors_header=yes \ + libc_cv_forced_unwind=yes libc_cv_ssp=no + + build-commands: + - cd o && make localtime=UTC + + install-commands: + - cd o && make install_root="%{install-root}" localtime=UTC install + - mkdir -p "%{install-root}/etc" + - mkdir -p "%{install-root}/etc/ld.so.conf.d" + - | + cat <<EOF > ld.so.conf + /lib + /usr/lib + /usr/local/lib + include /etc/ld.so.conf.d/*.conf + EOF + - install -m 644 -o root -g root ld.so.conf "%{install-root}/etc/ld.so.conf" + - | + # 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 $(dirname $(pwd)))" + specs_dir="$(dirname $(%{target-stage1}-gcc --print-libgcc-file-name))" + target_specs_dir="%{install-root}/${specs_dir#$sysroot}" + mkdir -p "$target_specs_dir" + + %{target-stage1}-gcc -dumpspecs | + sed -e "s@[gMS]\?crt[1in].o%s@%:getenv(STAGE2_SYSROOT %{libdir}/&)@g" \ + -e "s@/lib\(64\)\?/ld@%{libdir}/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. + # FIXME: get a better way of finding the name of the loader. The lib64 + # path is hardcoded into glibc in the file + # sysdeps/unix/sysv/linux/configure. + - install -d %{install-root}/lib + - | + case "%{bst-arch}" in + x86_64) + install -d "%{install-root}/lib64" + ln -s "%{prefix}/lib/ld-linux-x86-64.so.2" \ + "%{install-root}/lib64/ld-linux-x86-64.so.2" ;; + ppc64) + install -d "%{install-root}/lib64" + ln -s "%{prefix}/lib/ld64.so.1" \ + "%{install-root}/lib64/ld64.so.1" ;; + *) + loader=$(basename $(ls "%{install-root}%{prefix}"/lib/ld-linux*)) + [ -z $loader ] && loader=$(basename $(ls "%{install-root}%{prefix}"/lib/ld.so*)) + [ -z $loader ] && ( echo "Bug in stage2-glibc ld.so symlinks" ; exit 1 ) + ln -s "%{prefix}/lib/$loader" "%{install-root}/lib/$loader" + esac |