-
Notifications
You must be signed in to change notification settings - Fork 16
/
6.17-chroot_gcc.sh
231 lines (199 loc) · 6.14 KB
/
6.17-chroot_gcc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/bin/bash
CHAPTER_SECTION=17
INSTALL_NAME=gcc
echo ""
echo "### ---------------------------"
echo "### GCC ###"
echo "### CHAPTER 6.$CHAPTER_SECTION ###"
echo "### GCC-5.2.0"
echo "### Must be run as \"chroot\" user"
echo ""
echo "### Time estimate:"
echo "### real 235m26.724s ~= 4h"
echo "### user 212m30.493s"
echo "### sys 22m7.003s"
echo "### ---------------------------"
echo ""
echo "... Loading commun functions and variables"
if [ ! -f ./script-all_commun-functions.sh ]
then
echo "!! Fatal Error 1: './script-all_commun-functions.sh' not found."
exit 1
fi
source ./script-all_commun-functions.sh
if [ ! -f ./script-all_commun-variables.sh ]
then
echo "!! Fatal Error 1: './script-all_commun-variables.sh' not found."
exit 1
fi
source ./script-all_commun-variables.sh
echo ""
echo "... Validating the environment"
is_user root
check_chroot
echo ""
echo "... Setup building environment"
BUILD_DIRECTORY=$INSTALL_NAME-build
LOG_FILE=$LFS_BUILD_LOGS_6$CHAPTER_SECTION-$INSTALL_NAME
cd /sources
check_tarball_uniqueness
extract_tarball
cd $(ls -d /sources/$INSTALL_NAME*/)
echo ""
echo "... Installation starts now"
time {
echo ".... Pre-Configuring $SOURCE_FILE_NAME"
mkdir ../$BUILD_DIRECTORY
cd ../$BUILD_DIRECTORY
echo ".... Configuring $SOURCE_FILE_NAME"
SED=sed \
../gcc-5.2.0/configure \
--prefix=/usr \
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap \
--with-system-zlib \
&> $LOG_FILE-configure.log
echo ".... Making $SOURCE_FILE_NAME"
make $PROCESSOR_CORES &> $LOG_FILE-make.log
echo ".... Make Checking $SOURCE_FILE_NAME"
ulimit -s 32768
make -k check $PROCESSOR_CORES &> $LOG_FILE-make-check.log
../gcc-4.9.2/contrib/test_summary &> $LOG_FILE-test-summary.log
echo ".... Installing $SOURCE_FILE_NAME"
make install $PROCESSOR_CORES &> $LOG_FILE-make-install.log
echo ".... Post-Installing $SOURCE_FILE_NAME"
ln -sv ../usr/bin/cpp /lib
ln -sv gcc /usr/bin/cc
install -v -dm755 /usr/lib/bfd-plugins
ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/5.2.0/liblto_plugin.so /usr/lib/bfd-plugins/
}
echo ".... Sanity Checking"
echo 'int main(){}' > dummy.c
cc dummy.c -v -Wl,--verbose &> dummy.log
echo ""
echo "It was a long ride, please, human, come back and follow the steps"
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""
readelf -l a.out | grep ': /lib'
echo ""
echo "ABOVE should be the same output than below"
case $(uname -m) in x86_64)
echo "64bit: [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]" ;;
*)
echo "32bit: [Requesting program interpreter: /lib/ld-linux.so.2]" ;;
esac
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""
grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
echo ""
echo "ABOVE should be the same output than below"
case $(uname -m) in x86_64)
echo "64bit:"
echo "### /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../lib64/crt1.o succeeded"
echo "### /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../lib64/crti.o succeeded"
echo "### /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../lib64/crti.o succeeded" ;;
*)
echo "32bit:"
echo "### /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../crt1.o succeeded"
echo "### /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../crti.o succeeded"
echo "### /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../crtn.o succeeded" ;;
esac
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""
grep -B4 '^ /usr/include' dummy.log
echo ""
echo "ABOVE should be the same output than below"
case $(uname -m) in x86_64)
echo "64bit:"
echo "### #include <...> search starts here:"
echo "### /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/include"
echo "### /usr/local/include"
echo "### /usr/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/include-fixed"
echo "### /usr/include" ;;
*)
echo "32bit:"
echo "### #include <...> search starts here:"
echo "### /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/include"
echo "### /usr/local/include"
echo "### /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/include-fixed"
echo "### /usr/include" ;;
esac
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""
grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
echo ""
echo "ABOVE should be the same output than below"
case $(uname -m) in x86_64)
echo "64bit:"
echo '### SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")'
echo '### SEARCH_DIR("/usr/local/lib64")'
echo '### SEARCH_DIR("/lib64")'
echo '### SEARCH_DIR("/usr/lib64")'
echo '### SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")'
echo '### SEARCH_DIR("/usr/local/lib")'
echo '### SEARCH_DIR("/lib")'
echo '### SEARCH_DIR("/usr/lib");' ;;
*)
echo "32bit:"
echo 'SEARCH_DIR("/usr/i686-pc-linux-gnu/lib32")'
echo 'SEARCH_DIR("/usr/local/lib32")'
echo 'SEARCH_DIR("/lib32")'
echo 'SEARCH_DIR("/usr/lib32")'
echo 'SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")'
echo 'SEARCH_DIR("/usr/local/lib")'
echo 'SEARCH_DIR("/lib")'
echo 'SEARCH_DIR("/usr/lib");' ;;
esac
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""
grep "/lib.*/libc.so.6 " dummy.log
echo ""
echo "ABOVE should be the same output than below"
case $(uname -m) in x86_64)
echo "64bit: attempt to open /lib64/libc.so.6 succeeded" ;;
*)
echo "32bit: attempt to open /lib/libc.so.6 succeeded" ;;
esac
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""
grep found dummy.log
echo ""
echo "ABOVE should be the same output than below"
case $(uname -m) in x86_64)
echo "64bit: found ld-linux-x86-64.so.2 at /lib64/ld-linux-x86-64.so.2" ;;
*)
echo "32bit: found ld-linux.so.2 at /lib/ld-linux.so.2" ;;
esac
echo ""
echo -e "\a"
read -p "Enter to confirm" -n 1 -r
echo ""
echo ".... Finishing"
rm -v dummy.c a.out dummy.log
mkdir -pv /usr/share/gdb/auto-load/usr/lib
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib
echo ""
echo "... Cleaning up $SOURCE_FILE_NAME"
cd /sources
[ ! $SHOULD_NOT_CLEAN ] && rm -rf $(ls -d /sources/$INSTALL_NAME*/)
get_build_errors_6
echo ""
echo "######### END OF CHAPTER 6.$CHAPTER_SECTION ########"
echo "///// HUMAN REQUIRED \\\\\\\\\\\\\\\\\\\\"
echo "### Please run the next step:"
echo "### ./6.18-chroot_bzip2.sh"
echo ""
exit