1 |
commit: 3e4147bc0c77d9ea192a8eb273bc5926def4c8ca |
2 |
Author: Benda Xu <heroxbd <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Jan 16 03:08:26 2018 +0000 |
4 |
Commit: Benda XU <heroxbd <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 16 03:27:06 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=3e4147bc |
7 |
|
8 |
bootstrap-prefix.sh: RAP: bootstrap binutils before gcc in stage3 |
9 |
|
10 |
The stage2 binutils searches the host by default, and should not be |
11 |
used to link stage3 gcc. Stage3 binutils is need by stage3 gcc. |
12 |
|
13 |
There were problems to bootstrap binutils before gcc, most notably |
14 |
that binutils needs to link to zlib. If that zlib is from stage2, |
15 |
or before glibc in stage3, it results in incompatible glibc symbols. |
16 |
If that zlib is from stage3 after glibc, rpath is needed because |
17 |
stage2 gcc does not have dynamic linker pointed to stage3 glibc. |
18 |
Adding rpath to LDFLAGS triggers glibc runtime failure. |
19 |
|
20 |
In this commit: |
21 |
|
22 |
1. filter-ldflags has been added to glibc ebuild to filter out |
23 |
rpath. This has been committed to gentoo (a8ba9d20964964e7). |
24 |
|
25 |
2. after stage3 binutils is boostrapped, stage2 ld is renamed so |
26 |
that stage2 gcc can use stage3 ld. |
27 |
|
28 |
By doing so, we achieve a more logic-consistent bootstrap path. |
29 |
|
30 |
scripts/bootstrap-prefix.sh | 12 +++++------- |
31 |
1 file changed, 5 insertions(+), 7 deletions(-) |
32 |
|
33 |
diff --git a/scripts/bootstrap-prefix.sh b/scripts/bootstrap-prefix.sh |
34 |
index 7996ccdfae..b85c777174 100755 |
35 |
--- a/scripts/bootstrap-prefix.sh |
36 |
+++ b/scripts/bootstrap-prefix.sh |
37 |
@@ -1570,7 +1570,7 @@ bootstrap_stage3() { |
38 |
configure_toolchain || return 1 |
39 |
export CONFIG_SHELL="${ROOT}"/tmp/bin/bash |
40 |
export CPPFLAGS="-isystem ${ROOT}/usr/include" |
41 |
- export LDFLAGS="-L${ROOT}/usr/$(get_libdir)" |
42 |
+ export LDFLAGS="-L${ROOT}/usr/$(get_libdir) -Wl,-rpath=${ROOT}/usr/$(get_libdir)" |
43 |
unset CC CXX |
44 |
|
45 |
emerge_pkgs() { |
46 |
@@ -1621,12 +1621,16 @@ bootstrap_stage3() { |
47 |
app-portage/elt-patches |
48 |
sys-kernel/linux-headers |
49 |
sys-libs/glibc |
50 |
+ sys-devel/binutils-config |
51 |
sys-libs/zlib |
52 |
+ ${linker} |
53 |
) |
54 |
|
55 |
BOOTSTRAP_RAP=yes \ |
56 |
emerge_pkgs --nodeps "${pkgs[@]}" || return 1 |
57 |
grep -q 'apiversion=9999' "${ROOT}"/usr/bin/perl && rm "${ROOT}"/usr/bin/perl |
58 |
+ # remove stage2 ld so that stage3 ld is used by stage2 gcc. |
59 |
+ [[ -f ${ROOT}/tmp/usr/${CHOST}/bin/ld ]] && mv ${ROOT}/tmp/usr/${CHOST}/bin/ld{,.stage2} |
60 |
else |
61 |
pkgs=( |
62 |
sys-apps/gentoo-functions |
63 |
@@ -1687,12 +1691,6 @@ bootstrap_stage3() { |
64 |
[[ ${CHOST} == *-darwin* ]] && rm -f "${ROOT}"{,/tmp}/usr/bin/{,${CHOST}-}nm |
65 |
|
66 |
rm -f "${ROOT}"/etc/ld.so.conf.d/stage2.conf |
67 |
- if is-rap ; then |
68 |
- "${ROOT}"/sbin/ldconfig |
69 |
- # should be linked against stage3 zlib, and can only |
70 |
- # be compiled after gcc has the headers of Prefix glibc. |
71 |
- emerge_pkgs --nodeps sys-devel/binutils-config ${linker} || return 1 |
72 |
- fi |
73 |
|
74 |
( cd "${ROOT}"/usr/bin && test ! -e python && rm -f python2.7 ) |
75 |
# Use $ROOT tools where possible from now on. |