v2 / thirdparty / build_scripts / thirdparty-linux-amd64_tcc.sh
94 lines · 72 sloc · 3.29 KB · e411ee141199f543f55cebdc0d58a0428fda8dfc
Raw
1## NOTE: this script does *not* use a shebang **deliberately**, in order to
2## access the same shell, to capture its own launching command with `fc`,
3## and to record it later in the new commit message in thirdpart/tcc.
4
5## WARNING: THE ORIGINAL OF THIS SCRIPT IS IN:
6## https://github.com/vlang/v/blob/master/thirdparty/build_scripts/thirdparty-linux-amd64_tcc.sh ,
7## I.E. IN THE MAIN V REPOSITORY. IF YOU NEED TO MAKE CHANGES, CHANGE THAT.
8##
9## THE `build.sh` FILE IN `vlang/tccbin` REPO IS A COPY, RECORDED AT THE TIME
10## OF REBUILDING, FOR EASIER/RELIABLE REPRODUCTION OF HISTORIC VERSIONS.
11## IT IS NOT INTENDED TO BE MODIFIED.
12
13BUILD_CMD=`fc -nl -0`
14## remove whitespaces before/after the actual command:
15BUILD_CMD="$(echo "${BUILD_CMD}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
16
17set -e
18
19if ! test -f vlib/v/compiler_errors_test.v; then
20 echo "this script should be run in V's main repo folder!"
21 exit 1
22fi
23
24export CURRENT_SCRIPT_PATH=$(realpath "$0")
25
26export TCC_COMMIT="${TCC_COMMIT:-mob}"
27export TCC_FOLDER="${TCC_FOLDER:-thirdparty/tcc.$TCC_COMMIT}"
28export CC="${CC:-gcc}"
29
30echo " BUILD_CMD: \`$BUILD_CMD\`"
31echo " CC: $CC"
32echo "TCC_COMMIT: $TCC_COMMIT"
33echo "TCC_FOLDER: \`$TCC_FOLDER\`"
34echo ===============================================================
35
36rm -rf tinycc/
37rm -rf thirdparty/tcc.original/
38rsync -a thirdparty/tcc/ thirdparty/tcc.original/
39## rm -rf $TCC_FOLDER
40
41pushd .
42
43git clone git://repo.or.cz/tinycc.git
44
45cd tinycc
46
47git checkout $TCC_COMMIT
48export TCC_COMMIT_FULL_HASH=$(git rev-parse HEAD)
49
50## Note: crt1.o is located in:
51## /usr/lib/x86_64-linux-gnu on Debian/Ubuntu
52## /usr/lib64 on Redhat/CentOS
53## /usr/lib on ArchLinux
54
55./configure \
56 --prefix=$TCC_FOLDER \
57 --bindir=$TCC_FOLDER \
58 --crtprefix=$TCC_FOLDER/lib:/usr/lib/x86_64-linux-gnu:/usr/lib64:/usr/lib:/lib/x86_64-linux-gnu:/lib \
59 --libpaths=$TCC_FOLDER/lib/tcc:$TCC_FOLDER/lib:/usr/lib/x86_64-linux-gnu:/usr/lib64:/usr/lib:/lib/x86_64-linux-gnu:/lib:/usr/local/lib/x86_64-linux-gnu:/usr/local/lib \
60 --cc=$CC \
61 --extra-cflags=-O3 \
62 --config-bcheck=yes \
63 --config-backtrace=yes \
64 --debug
65
66make
67make install
68
69popd
70
71rsync -a --delete tinycc/$TCC_FOLDER/ $TCC_FOLDER/
72rsync -a thirdparty/tcc.original/.git/ $TCC_FOLDER/.git/
73rsync -a thirdparty/tcc.original/lib/libgc* $TCC_FOLDER/lib/
74rsync -a thirdparty/tcc.original/lib/build* $TCC_FOLDER/lib/
75rsync -a thirdparty/tcc.original/README.md $TCC_FOLDER/README.md
76rsync -a $CURRENT_SCRIPT_PATH $TCC_FOLDER/build.sh
77mv $TCC_FOLDER/tcc $TCC_FOLDER/tcc.exe
78
79date > $TCC_FOLDER/build_on_date.txt
80echo $TCC_COMMIT_FULL_HASH > $TCC_FOLDER/build_source_hash.txt
81$TCC_FOLDER/tcc.exe --version > $TCC_FOLDER/build_version.txt
82uname -a > $TCC_FOLDER/build_machine_uname.txt
83
84## show the builtin search paths for sanity checking:
85$TCC_FOLDER/tcc.exe -v -v
86
87pushd .
88cd $TCC_FOLDER
89git add .
90git commit -m "build with \`$BUILD_CMD\`"
91popd
92
93echo "tcc commit: $TCC_COMMIT , full hash: $TCC_COMMIT_FULL_HASH . The tcc executable is ready in $TCC_FOLDER/tcc.exe "
94
95