Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/proj/prefix:master commit in: scripts/
Date: Thu, 31 Dec 2020 15:13:32
Message-Id: 1609427333.2d2c64938644a41bf199a8d73abc97f1b0bdbd55.grobian@gentoo
1 commit: 2d2c64938644a41bf199a8d73abc97f1b0bdbd55
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 31 15:08:53 2020 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Thu Dec 31 15:08:53 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=2d2c6493
7
8 scripts/bootstrap-prefix: add some darwin-related changes
9
10 - bootstrap cmake (stage1) on a Darwin profile without GCC, such that we
11 can bootstrap llvm without having to get cmake which has too many
12 (problematic) deps
13 - use native-cctool to avoid bootstrapping binutils-apple, which is
14 difficult to get given its (compiler) dependencies
15
16 (this make a bunch of things unnecessary from
17 https://github.com/gentoo/prefix/pull/1)
18
19 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
20
21 scripts/bootstrap-prefix.sh | 91 +++++++++++++++++++++++++++++++--------------
22 1 file changed, 63 insertions(+), 28 deletions(-)
23
24 diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh
25 index 2f0fdb6fdf..1943a3929b 100755
26 --- a/scripts/bootstrap-prefix.sh
27 +++ b/scripts/bootstrap-prefix.sh
28 @@ -185,26 +185,29 @@ configure_toolchain() {
29 compiler_stage1+=" sys-apps/darwin-miscutils sys-libs/csu"
30 local ccvers="$( (unset CHOST; gcc --version 2>/dev/null) )"
31 case "${ccvers}" in
32 + *"(Gentoo "*)
33 + # probably the result of a bootstrap in progress
34 + [[ ${DARWIN_USE_GCC} == 1 ]] \
35 + && linker=sys-devel/native-cctools \
36 + || linker=sys-devel/binutils-apple
37 + ;;
38 *"(GCC) 4.2.1 "*)
39 linker=sys-devel/binutils-apple
40 ;;
41 *"(GCC) 4.0.1 "*)
42 - linker="=sys-devel/binutils-apple-3.2"
43 + linker="=sys-devel/binutils-apple-3.2.6"
44 # upgrade to 4.2.1 first
45 compiler_stage1+="
46 sys-devel/gcc-apple
47 sys-devel/binutils-apple"
48 ;;
49 - *"(Gentoo "*)
50 - # probably the result of a bootstrap in progress
51 - [[ ${DARWIN_USE_GCC} == 1 ]] \
52 - && linker=sys-devel/native-cctools \
53 - || linker=sys-devel/binutils-apple
54 - ;;
55 *"Apple clang version "*|*"Apple LLVM version "*)
56 # gcc cannot build (recent) binutils-apple due to
57 # missing blocks support, so use Xcode provided
58 # linker/assembler
59 + # UPDATE: binutils-8.2.1-r100 compiles, but the
60 + # assembler isn't able to deal with AVX instructions
61 + # (yet)
62 linker=sys-devel/native-cctools
63 ;;
64 *)
65 @@ -222,11 +225,7 @@ configure_toolchain() {
66 compiler_type="clang"
67 local ccvers="$( (unset CHOST; gcc --version 2>/dev/null) )"
68 local mycc=
69 - local llvm_deps="
70 - app-arch/libarchive
71 - app-crypt/rhash
72 - dev-util/cmake
73 - dev-util/ninja"
74 + local llvm_deps="dev-util/ninja"
75 case "${ccvers}" in
76 *"Apple clang version "*)
77 vers=${ccvers#*Apple clang version }
78 @@ -241,7 +240,11 @@ configure_toolchain() {
79 sys-libs/libcxx"
80 CC=clang
81 CXX=clang++
82 - linker=sys-devel/binutils-apple
83 + # avoid going through hoops and deps for
84 + # binutils-apple, rely on the host-installed ld to
85 + # build a compiler, we'll pull in binutils-apple
86 + # from system set
87 + linker=sys-devel/native-cctools
88 ;;
89 *"Apple LLVM version "*)
90 vers=${ccvers#*Apple LLVM version }
91 @@ -267,21 +270,8 @@ configure_toolchain() {
92 esac
93 CC=clang
94 CXX=clang++
95 - linker=sys-devel/binutils-apple
96 - ;;
97 - *"(GCC) 4.2.1 "*)
98 - linker=sys-devel/binutils-apple
99 - mycc=gcc
100 - ;;
101 - *"(GCC) 4.0.1 "*)
102 - # need gcc-4.2.1 to compile llvm
103 - linker="=sys-devel/binutils-apple-3.2"
104 - compiler_stage1+="
105 - ${gcc_deps}
106 - sys-devel/gcc-config
107 - sys-devel/gcc-apple
108 - sys-devel/binutils-apple"
109 - mycc=gcc
110 + # see above for reasoning
111 + linker=sys-devel/native-cctools
112 ;;
113 *)
114 eerror "unknown compiler"
115 @@ -557,6 +547,14 @@ bootstrap_setup() {
116 sys-devel/binutils -cxx
117 EOF
118
119 + # On Darwin we might need this to bootstrap the compiler, since
120 + # bootstrapping the linker (binutils-apple) requires a c++11
121 + # compiler amongst other things
122 + cat >> "${ROOT}"/etc/portage/make.profile/package.unmask <<-EOF
123 + # For Darwin bootstraps
124 + sys-devel/native-cctools
125 + EOF
126 +
127 # Strange enough, -cxx causes wrong libtool config on Cygwin,
128 # but we require a C++ compiler there anyway - so just use it.
129 [[ ${CHOST} == *-cygwin* ]] ||
130 @@ -1197,6 +1195,34 @@ bootstrap_python() {
131 einfo "${A%-*} bootstrapped"
132 }
133
134 +bootstrap_cmake() {
135 + PV=${1:-3.13.4}
136 + A=cmake-${PV}.tar.gz
137 +
138 + einfo "Bootstrapping ${A%-*}"
139 +
140 + efetch https://github.com/Kitware/CMake/releases/download/v${PV}/${A} \
141 + || return 1
142 +
143 + einfo "Unpacking ${A%%-*}"
144 + export S="${PORTAGE_TMPDIR}/cmake-${PV}"
145 + rm -rf "${S}"
146 + mkdir -p "${S}"
147 + cd "${S}"
148 + gzip -dc "${DISTDIR}"/${A} | tar -xf - || return 1
149 + S="${S}"/cmake-${PV}
150 + cd "${S}"
151 +
152 + einfo "Compiling ${A%-*}"
153 + ./bootstrap --prefix="${ROOT}"/tmp/usr || return 1
154 + $MAKE ${MAKEOPTS} || return 1
155 +
156 + einfo "Installing ${A%-*}"
157 + $MAKE ${MAKEOPTS} install || return 1
158 +
159 + einfo "${A%-*} bootstrapped"
160 +}
161 +
162 bootstrap_zlib_core() {
163 # use 1.2.8 by default, current bootstrap guides
164 PV="${1:-1.2.8}"
165 @@ -1567,6 +1593,15 @@ bootstrap_stage1() {
166 # too vital to rely on a host-provided one
167 [[ -x ${ROOT}/tmp/usr/bin/python ]] || (bootstrap_python) || return 1
168
169 + if [[ ! -e ${ROOT}/tmp/usr/bin/cmake ]] && [[ ${CHOST} == *-darwin* ]]
170 + then
171 + # TODO: make DARWIN_USE_GCC path also activated on ppc-macos,
172 + # since it effectively is so
173 + if [[ ${DARWIN_USE_GCC} != 1 && ${CHOST} != powerpc* ]] ; then
174 + (bootstrap_cmake) || return 1
175 + fi
176 + fi
177 +
178 # checks itself if things need to be done still
179 (bootstrap_tree) || return 1