Skip to content

Commit 86bb2d7

Browse files
authored
thirdparty: add thirdparty/build_scripts/ to prepare for prebuilt tcc upgrades (#23981)
1 parent 87b1de8 commit 86bb2d7

File tree

3 files changed

+146
-0
lines changed

3 files changed

+146
-0
lines changed

thirdparty/build_scripts/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
This folder, contains build scripts used by the CI, to generate prebuilt versions
2+
(or latest version by default) of:
3+
A) TCC from https://repo.or.cz/tinycc.git/
4+
B) libgc from https://github.com/ivmai/bdwgc/
5+
6+
In time, if everything works fine, we can deprecate the older approach, keeping 2 *separate*
7+
binary repos, tccbin/ and libgcbin/, with just pointers back to the build scripts here.
8+
9+
Note: the previous approach (before 2024/08), used in https://github.com/vlang/tccbin/,
10+
where that separate repo contained both prebuilt binaries for tcc AND libgc.a,
11+
AND the separate scripts to generate them, in *separate branches*.
12+
In contrast, this folder contains *all scripts in the same location, in the same branch*, just
13+
with different names, thus making editing them all at the same time and in atomic commits,
14+
that can be reviewed and tested separately in PRs on the CI *much easier*.
15+
16+
WARNING: this is still experimental, and should not be used, except to ease testing on the CI.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if ! test -f vlib/v/compiler_errors_test.v; then
6+
echo "this script should be run in V's main repo folder!"
7+
exit 1
8+
fi
9+
10+
export CURRENT_SCRIPT_PATH=$(realpath "$0")
11+
12+
export CC="${CC:-gcc}"
13+
export TCC_FOLDER="${TCC_FOLDER:-thirdparty/tcc}"
14+
export LIBGC_COMMIT="${LIBGC_COMMIT:-master}"
15+
mkdir -p $TCC_FOLDER/lib/
16+
17+
echo " CC: $CC"
18+
echo " TCC_FOLDER: $TCC_FOLDER"
19+
echo "LIBGC_COMMIT: $LIBGC_COMMIT"
20+
echo ===============================================================
21+
22+
rm -rf bdwgc/
23+
24+
pushd .
25+
git clone https://github.com/ivmai/bdwgc
26+
cd bdwgc/
27+
28+
git checkout $LIBGC_COMMIT
29+
export LIBGC_COMMIT_FULL_HASH=$(git rev-parse HEAD)
30+
31+
./autogen.sh
32+
33+
CC=$CC CFLAGS='-Os -mtune=generic -fPIC' LDFLAGS='-Os -fPIC' ./configure \
34+
--disable-dependency-tracking \
35+
--disable-docs \
36+
--enable-handle-fork=yes \
37+
--enable-rwlock \
38+
--enable-threads=pthreads \
39+
--enable-static \
40+
--enable-shared=no \
41+
--enable-parallel-mark \
42+
--enable-single-obj-compilation \
43+
--enable-gc-debug \
44+
--with-libatomic-ops=yes \
45+
--enable-sigrt-signals
46+
47+
make
48+
49+
popd
50+
51+
cp bdwgc/.libs/libgc.a $TCC_FOLDER/lib/libgc.a
52+
53+
date > $TCC_FOLDER/lib/libgc_build_on_date.txt
54+
echo $LIBGC_COMMIT_FULL_HASH > $TCC_FOLDER/lib/libgc_build_source_hash.txt
55+
uname -a > $TCC_FOLDER/lib/libgc_build_machine_uname.txt
56+
57+
ls -la $TCC_FOLDER/lib/libgc.a
58+
echo "Done compiling libgc, at commit $LIBGC_COMMIT , full hash: $LIBGC_COMMIT_FULL_HASH . The static library is in $TCC_FOLDER/lib/libgc.a "
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if ! test -f vlib/v/compiler_errors_test.v; then
6+
echo "this script should be run in V's main repo folder!"
7+
exit 1
8+
fi
9+
10+
export CURRENT_SCRIPT_PATH=$(realpath "$0")
11+
12+
export TCC_COMMIT="${TCC_COMMIT:-mob}"
13+
export TCC_FOLDER="${TCC_FOLDER:-thirdparty/tcc.$TCC_COMMIT}"
14+
export CC="${CC:-gcc}"
15+
16+
echo " CC: $CC"
17+
echo "TCC_COMMIT: $TCC_COMMIT"
18+
echo "TCC_FOLDER: $TCC_FOLDER"
19+
echo ===============================================================
20+
21+
rm -rf tinycc/
22+
rm -rf thirdparty/tcc.original/
23+
rsync -a thirdparty/tcc/ thirdparty/tcc.original/
24+
## rm -rf $TCC_FOLDER
25+
26+
pushd .
27+
28+
git clone git://repo.or.cz/tinycc.git
29+
30+
cd tinycc
31+
32+
git checkout $TCC_COMMIT
33+
export TCC_COMMIT_FULL_HASH=$(git rev-parse HEAD)
34+
35+
## Note: crt1.o is located in:
36+
## /usr/lib/x86_64-linux-gnu on Debian/Ubuntu
37+
## /usr/lib64 on Redhat/CentOS
38+
## /usr/lib on ArchLinux
39+
40+
./configure \
41+
--prefix=$TCC_FOLDER \
42+
--bindir=$TCC_FOLDER \
43+
--crtprefix=$TCC_FOLDER/lib:/usr/lib/x86_64-linux-gnu:/usr/lib64:/usr/lib:/lib/x86_64-linux-gnu:/lib \
44+
--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 \
45+
--cc=$CC \
46+
--extra-cflags=-O3 \
47+
--config-bcheck=yes \
48+
--config-backtrace=yes \
49+
--debug
50+
51+
make
52+
make install
53+
54+
popd
55+
56+
rsync -a --delete tinycc/$TCC_FOLDER/ $TCC_FOLDER/
57+
rsync -a thirdparty/tcc.original/.git/ $TCC_FOLDER/.git/
58+
rsync -a thirdparty/tcc.original/lib/libgc* $TCC_FOLDER/lib/
59+
rsync -a thirdparty/tcc.original/lib/build* $TCC_FOLDER/lib/
60+
rsync -a thirdparty/tcc.original/README.md $TCC_FOLDER/README.md
61+
rsync -a $CURRENT_SCRIPT_PATH $TCC_FOLDER/build.sh
62+
mv $TCC_FOLDER/tcc $TCC_FOLDER/tcc.exe
63+
64+
date > $TCC_FOLDER/build_on_date.txt
65+
echo $TCC_COMMIT_FULL_HASH > $TCC_FOLDER/build_source_hash.txt
66+
$TCC_FOLDER/tcc.exe --version > $TCC_FOLDER/build_version.txt
67+
uname -a > $TCC_FOLDER/build_machine_uname.txt
68+
69+
## show the builtin search paths for sanity checking:
70+
$TCC_FOLDER/tcc.exe -v -v
71+
72+
echo "tcc commit: $TCC_COMMIT , full hash: $TCC_COMMIT_FULL_HASH . The tcc executable is ready in $TCC_FOLDER/tcc.exe "

0 commit comments

Comments
 (0)