-
Notifications
You must be signed in to change notification settings - Fork 11
/
bos-lite.sh
223 lines (143 loc) · 7.42 KB
/
bos-lite.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
#!/bin/sh
# BUGS
#--- read.o ---
#/b/main/src/contrib/mandoc/read.c:40:10: fatal error: 'zlib.h' file not found
#include <zlib.h>
# (REVISED) USAGE
# BY DEFAULT USE /usr/src and /usr/ojb or take in a branch $1
branch="/usr"
# src/
# obj/
[ -n "$1" ] && branch="$1"
[ -f "${branch}/src/Makefile" ] || \
{ echo "branch ${branch}/src not found" ; exit 1 ; }
# i.e. $branch = /b/stable/13
# src/
# obj/
# githash
# gitdate
# ADDING WITHOUT_MACHDEP_OPTIMIZATIONS because of the regresion
required_options="WITHOUT_AUTO_OBJ WITHOUT_UNIFIED_OBJDIR WITHOUT_INSTALLLIB"
#[ -d "/b/HTML" ] || mkdir -p /b/HTML
#[ -f lib_occambsd.sh ] || \
# { echo lib_occambsd.sh not found ; exit 1 ; }
#echo Sourcing lib_occambsd.sh
#. lib_occambsd.sh || \
# { echo lib_occambsd.sh failed to source ; exit 1 ; }
case $( uname -s ) in
FreeBSD)
buildjobs="$(sysctl -n hw.ncpu)"
allopts=$( make -C $branch/src showconfig __MAKE_CONF=/dev/null SRCCONF=/dev/null )
;;
Linux)
buildjobs="$(nproc)"
# which cc, clang, and llvm give nothing
# which cpp does
# NOTE THE 11 or 13!
#sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
#update-alternatives --install /usr/bin/cc cc /usr/bin/clang-11 100
#update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-11 100
#update-alternatives --install /usr/bin/cpp cpp /usr/bin/clang++-11 100
# make XCC=/usr/local/bin/clang XCXX=/usr/local/bin/clang++ XCPP=/usr/local/bin/clang-cpp buildworld
# MOST I HAVE SEEN
# https://maskray.me/blog/2021-08-22-freebsd-src-browsing-on-linux-and-my-rtld-contribution
# HOLY CRAP WORKS
#env MAKEOBJDIRPREFIX=/b/main/obj env XCC=/usr/bin/clang-11 env XCXX=/usr/bin/clang++-11 env XCPP=/usr/bin/clang-cpp-11 XLD=/usr/bin/lldb-11 /b/main/src/tools/build/make.py buildworld TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64
# MORE
#env MAKEOBJDIRPREFIX=/b/main/obj env XCC=/usr/bin/clang-11 env XCXX=/usr/bin/clang++-11 env XCPP=/usr/bin/clang-cpp-11 env XLD=/usr/bin/lldb-11 /b/main/src/tools/build/make.py -j 16 buildworld TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64 SRCCONF=/b/main/without
# AGAIN YEP, need to env them or... --cross-bindir= (no workie)
#env MAKEOBJDIRPREFIX=/b/main/obj /b/main/src/tools/build/make.py -j 16 buildworld SRCCONF=/b/main/without TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amdenv 64 XCC=/usr/bin/clang-11 XCXX=/usr/bin/clang++-11 XCPP=/usr/bin/clang-cpp-11 XLD=/usr/bin/lldb-11
#env MAKEOBJDIRPREFIX=/b/main/obj env XCC=/usr/bin/clang-11 env XCXX=/usr/bin/clang++-11 env XCPP=/usr/bin/clang-cpp-11 env XLD=/usr/bin/lldb-11 /b/main/src/tools/build/make.py -j 16 buildworld SRCCONF=/b/main/without TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64
# FAILS ON bmake[4]: "/b/main/src/lib/libc/Makefile" line 195: amd64 libc requires linker ifunc support
#env MAKEOBJDIRPREFIX=/b/main/obj env XCC=/usr/bin/clang-13 env XCXX=/usr/bin/clang++-13 env XCPP=/usr/bin/clang-cpp-13 env XLD=/usr/bin/lldb-13 /b/main/src/tools/build/make.py -j 16 buildworld SRCCONF=/b/main/without TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64
# Verify without_src.conf generation
# LOOKS LIKE SRCCONF WAS NOT RESPECTED BUT /ETC/SRC.CONF MIGHT WORK, MAYBE ENV
# Not sure we need machine arch
#USING --bootstrap-toolchain
# NOT SURE HOW MANY ALTERNATIVES ARE NEEDED FOR THIS
env MAKEOBJDIRPREFIX=/b/main/obj /b/main/src/tools/build/make.py --bootstrap-toolchain /b/main/src/tools/build/make.py -j 16 buildworld SRCCONF=/b/main/without_src.conf TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64 -j 16 buildworld SRCCONF=/b/main/without TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64 > /b/main/cross-build-log.txt
# WTF
#time env MAKEOBJDIRPREFIX=/b/main/obj env SRCCONF=/b/main/without_src.conf /b/main/src/tools/build/make.py --bootstrap-toolchain /b/main/src/tools/build/make.py -j 16 buildworld SRCCONF=/b/main/without_src.conf TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64 -j 16 buildworld SRCCONF=/b/main/without_src.conf TARGET=amd64 TARGET_ARCH=amd64 COMPILER_TYPE=clang > /b/main/cross-build-log2.txt
#Trying 13.2
#root@pve:/b/releng/13.2# time env MAKEOBJDIRPREFIX=/b/releng/13.2/obj env SRCCONF=/b/releng/13.2/without_src.conf /b/releng/13.2/src/tools/build/make.py --bootstrap-toolchain /b/main/src/tools/build/make.py -j 16 buildworld SRCCONF=/b/releng/13.2/without_src.conf TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64 -j 16 buildworld SRCCONF=/b/releng/13.2/without_src.conf TARGET=amd64 TARGET_ARCH=amd64 COMPILER_TYPE=clang > /b/releng/13.2/cross-build-log2.txt
#Failed tests: opt-debug-x-trace
#*** Error code 1
#Stop.
#bmake[1]: stopped in /b/releng/13.2/src/contrib/bmake/unit-tests
#*** Error code 1
# apt install clang-11 llvm-11 lldb-11 libarchive-dev libbz2-dev bmake
which bmake || { echo "bmake not found" ; exit 1 ; }
which cc || { echo "cc not found" ; exit 1 ; }
allopts=$( bmake -C $branch/src showconfig __MAKE_CONF=/dev/null SRCCONF=/dev/null COMPILER_TYPE=foo TARGET=amd64 MACHINE_ARCH=amd64 )
;;
esac
echo DEBUG branch is $branch
echo Generating all_options.txt
#f_occam_options $branch/src "$required_options" \
# > $branch/src.conf || \
# { echo $branch/src.conf generation failed ; exit 1 ; }
allopts=$( $allopts | sort | sed '
s/^MK_//
s/=//
' | awk '
$2 == "yes" { printf "WITHOUT_%s=YES\n", $1 }
$2 == "no" { printf "WITH_%s=YES\n", $1 }
' )
echo DEBUG did the alltops processing work?
echo $allopts | tail
read allops
# STEP ONE COLLECT ALL OPTIONS LIKE BOS listallopts.sh does
# Set the IFS to space or you will not get carriage returns
IFS=" "
echo $allopts > $branch/all_options.txt
tail -10 $branch/all_options.txt
IFS=" "
for exclusion in $required_options ; do
allopts=$( echo $allopts | grep -v $exclusion )
done
echo $allopts > $branch/valid_options.txt
# STEP TWO grep -v out the WITH_ options for the WITHOUT_ build
echo $allopts | grep -v "WITH_" > $branch/without_src.conf
echo $allopts | grep -v "WITHOUT_" > $branch/with_src.conf
echo DEBUG tailing $branch/without_src.conf
tail $branch/without_src.conf
status="success"
start_time=$( date +%s )
# MOVED THE LOGGING FROM /b/HTML/
git_date=$( cat $branch/gitdate )
git_hash=$( cat $branch/lasthash )
echo Building WITHOUT_ world - logging to $branch/${git_date}-WITHOUT.log
# MOVED THE LOG DIRECTORY
case $( uname -s ) in
FreeBSD)
\time -h env MAKEOBJDIRPREFIX=$branch/obj \
make -C $branch/src -j$buildjobs \
SRCCONF=$branch/without_src.conf buildworld \
> $branch/${git_date}-WITHOUT.log || status="failed"
;;
Linux)
#env MAKEOBJDIRPREFIX=/b/main/obj /b/main/src/tools/build/make.py buildworld TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64
#Could not infer value for $CC: /usr/bin/cc does not exist
# --bootstrap-toolchain to bootstrap the native toolchain
# NOPE
export PATH=$PATH:/usr/bin/clang-11:/usr/bin/clang++-11
# export CMAKE_C_COMPILER=clang-11
# export CMAKE_CXX_COMPILER=clang++-11
\time env MAKEOBJDIRPREFIX=$branch/obj \
$branch/src/tools/build/make.py \
TARGET=amd64 TARGET_ARCH=amd64 MACHINE_ARCH=amd64 \
> $branch/${git_date}-WITHOUT.log || status="failed"
;;
esac
end_time=$( date +%s )
build_time=$(( $end_time - $start_time ))
echo build_time is $build_time
# Remove the directory prefix /b/ from the branch
# The user may have nested it, which will fail
printbranch=$( echo ${branch#/*/} )
echo Build results:
echo "$git_date $printbranch $git_hash $build_time WITHOUT $status"
echo "$git_date $printbranch $git_hash $build_time WITHOUT $status" \
> $branch/bos-lite-latest.log
# >> /b/bos-lite.log
exit 0