commit:     2d2c64938644a41bf199a8d73abc97f1b0bdbd55
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 31 15:08:53 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 31 15:08:53 2020 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=2d2c6493

scripts/bootstrap-prefix: add some darwin-related changes

- bootstrap cmake (stage1) on a Darwin profile without GCC, such that we
  can bootstrap llvm without having to get cmake which has too many
  (problematic) deps
- use native-cctool to avoid bootstrapping binutils-apple, which is
  difficult to get given its (compiler) dependencies

(this make a bunch of things unnecessary from
https://github.com/gentoo/prefix/pull/1)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 scripts/bootstrap-prefix.sh | 91 +++++++++++++++++++++++++++++++--------------
 1 file changed, 63 insertions(+), 28 deletions(-)

diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
index 2f0fdb6fdf..1943a3929b 100755
--- a/scripts/bootstrap-prefix.sh
+++ b/scripts/bootstrap-prefix.sh
@@ -185,26 +185,29 @@ configure_toolchain() {
                        compiler_stage1+=" sys-apps/darwin-miscutils 
sys-libs/csu"
                        local ccvers="$( (unset CHOST; gcc --version 
2>/dev/null) )"
                        case "${ccvers}" in
+                               *"(Gentoo "*)
+                                       # probably the result of a bootstrap in 
progress
+                                       [[ ${DARWIN_USE_GCC} == 1 ]] \
+                                               && 
linker=sys-devel/native-cctools \
+                                               || 
linker=sys-devel/binutils-apple
+                                       ;;
                                *"(GCC) 4.2.1 "*)
                                        linker=sys-devel/binutils-apple
                                        ;;
                                *"(GCC) 4.0.1 "*)
-                                       linker="=sys-devel/binutils-apple-3.2"
+                                       linker="=sys-devel/binutils-apple-3.2.6"
                                        # upgrade to 4.2.1 first
                                        compiler_stage1+="
                                                sys-devel/gcc-apple
                                                sys-devel/binutils-apple"
                                        ;;
-                               *"(Gentoo "*)
-                                       # probably the result of a bootstrap in 
progress
-                                       [[ ${DARWIN_USE_GCC} == 1 ]] \
-                                               && 
linker=sys-devel/native-cctools \
-                                               || 
linker=sys-devel/binutils-apple
-                                       ;;
                                *"Apple clang version "*|*"Apple LLVM version 
"*)
                                        # gcc cannot build (recent) 
binutils-apple due to
                                        # missing blocks support, so use Xcode 
provided
                                        # linker/assembler
+                                       # UPDATE: binutils-8.2.1-r100 compiles, 
but the
+                                       # assembler isn't able to deal with AVX 
instructions
+                                       # (yet)
                                        linker=sys-devel/native-cctools
                                        ;;
                                *)
@@ -222,11 +225,7 @@ configure_toolchain() {
                        compiler_type="clang"
                        local ccvers="$( (unset CHOST; gcc --version 
2>/dev/null) )"
                        local mycc=
-                       local llvm_deps="
-                               app-arch/libarchive
-                               app-crypt/rhash
-                               dev-util/cmake
-                               dev-util/ninja"
+                       local llvm_deps="dev-util/ninja"
                        case "${ccvers}" in
                                *"Apple clang version "*)
                                        vers=${ccvers#*Apple clang version }
@@ -241,7 +240,11 @@ configure_toolchain() {
                                                sys-libs/libcxx"
                                        CC=clang
                                        CXX=clang++
-                                       linker=sys-devel/binutils-apple
+                                       # avoid going through hoops and deps for
+                                       # binutils-apple, rely on the 
host-installed ld to
+                                       # build a compiler, we'll pull in 
binutils-apple
+                                       # from system set
+                                       linker=sys-devel/native-cctools
                                        ;;
                                *"Apple LLVM version "*)
                                        vers=${ccvers#*Apple LLVM version }
@@ -267,21 +270,8 @@ configure_toolchain() {
                                        esac
                                        CC=clang
                                        CXX=clang++
-                                       linker=sys-devel/binutils-apple
-                                       ;;
-                               *"(GCC) 4.2.1 "*)
-                                       linker=sys-devel/binutils-apple
-                                       mycc=gcc
-                                       ;;
-                               *"(GCC) 4.0.1 "*)
-                                       # need gcc-4.2.1 to compile llvm
-                                       linker="=sys-devel/binutils-apple-3.2"
-                                       compiler_stage1+="
-                                               ${gcc_deps}
-                                               sys-devel/gcc-config
-                                               sys-devel/gcc-apple
-                                               sys-devel/binutils-apple"
-                                       mycc=gcc
+                                       # see above for reasoning
+                                       linker=sys-devel/native-cctools
                                        ;;
                                *)
                                        eerror "unknown compiler"
@@ -557,6 +547,14 @@ bootstrap_setup() {
        sys-devel/binutils -cxx
        EOF
 
+       # On Darwin we might need this to bootstrap the compiler, since
+       # bootstrapping the linker (binutils-apple) requires a c++11
+       # compiler amongst other things
+       cat >> "${ROOT}"/etc/portage/make.profile/package.unmask <<-EOF
+       # For Darwin bootstraps
+       sys-devel/native-cctools
+       EOF
+
        # Strange enough, -cxx causes wrong libtool config on Cygwin,
        # but we require a C++ compiler there anyway - so just use it.
        [[ ${CHOST} == *-cygwin* ]] ||
@@ -1197,6 +1195,34 @@ bootstrap_python() {
        einfo "${A%-*} bootstrapped"
 }
 
+bootstrap_cmake() {
+       PV=${1:-3.13.4}
+       A=cmake-${PV}.tar.gz
+
+       einfo "Bootstrapping ${A%-*}"
+
+       efetch https://github.com/Kitware/CMake/releases/download/v${PV}/${A} \
+               || return 1
+
+       einfo "Unpacking ${A%%-*}"
+       export S="${PORTAGE_TMPDIR}/cmake-${PV}"
+       rm -rf "${S}"
+       mkdir -p "${S}"
+       cd "${S}"
+       gzip -dc "${DISTDIR}"/${A} | tar -xf - || return 1
+       S="${S}"/cmake-${PV}
+       cd "${S}"
+
+       einfo "Compiling ${A%-*}"
+       ./bootstrap --prefix="${ROOT}"/tmp/usr || return 1
+       $MAKE ${MAKEOPTS} || return 1
+
+       einfo "Installing ${A%-*}"
+       $MAKE ${MAKEOPTS} install || return 1
+
+       einfo "${A%-*} bootstrapped"
+}
+
 bootstrap_zlib_core() {
        # use 1.2.8 by default, current bootstrap guides
        PV="${1:-1.2.8}"
@@ -1567,6 +1593,15 @@ bootstrap_stage1() {
        # too vital to rely on a host-provided one
        [[ -x ${ROOT}/tmp/usr/bin/python ]] || (bootstrap_python) || return 1
 
+       if [[ ! -e ${ROOT}/tmp/usr/bin/cmake ]] && [[ ${CHOST} == *-darwin* ]]
+       then
+               # TODO: make DARWIN_USE_GCC path also activated on ppc-macos,
+               # since it effectively is so
+               if [[ ${DARWIN_USE_GCC} != 1 && ${CHOST} != powerpc* ]] ; then
+                       (bootstrap_cmake) || return 1
+               fi
+       fi
+
        # checks itself if things need to be done still
        (bootstrap_tree) || return 1
 

Reply via email to