Skip to content

Commit c6dbe32

Browse files
authored
thirdparty: add thirdparty/build_scripts/thirdparty-openbsd-amd64_tcc.sh for compiling tcc on OpenBSD (#24592)
1 parent af8ecda commit c6dbe32

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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-openbsd-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+
13+
BUILD_CMD=`fc -nl -0`
14+
## remove whitespaces before/after the actual command:
15+
BUILD_CMD="$(echo "${BUILD_CMD}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
16+
17+
set -e
18+
19+
if ! 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
22+
fi
23+
24+
export CFLAGS='-O3'
25+
export CURRENT_SCRIPT_PATH=$(realpath "$0")
26+
27+
export TCC_COMMIT="${TCC_COMMIT:-mob}"
28+
export TCC_FOLDER="${TCC_FOLDER:-thirdparty/tcc.$TCC_COMMIT}"
29+
export CC="${CC:-clang}"
30+
31+
echo " BUILD_CMD: \`$BUILD_CMD\`"
32+
echo " CC: $CC"
33+
echo "TCC_COMMIT: $TCC_COMMIT"
34+
echo "TCC_FOLDER: \`$TCC_FOLDER\`"
35+
echo ===============================================================
36+
37+
rm -rf tinycc/
38+
rm -rf thirdparty/tcc.original/
39+
rsync -a thirdparty/tcc/ thirdparty/tcc.original/
40+
41+
pushd .
42+
43+
git clone git://repo.or.cz/tinycc.git
44+
45+
cd tinycc
46+
47+
git checkout $TCC_COMMIT
48+
export TCC_COMMIT_FULL_HASH=$(git rev-parse HEAD)
49+
50+
./configure \
51+
--prefix=$TCC_FOLDER \
52+
--bindir=$TCC_FOLDER \
53+
--crtprefix=$TCC_FOLDER/lib:/usr/lib \
54+
--sysincludepaths=$TCC_FOLDER/lib/tcc/include:/usr/local/include:/usr/include \
55+
--libpaths=$TCC_FOLDER/lib/tcc:$TCC_FOLDER/lib:/usr/lib:/usr/local/lib \
56+
--cc="$CC" \
57+
--extra-cflags="$CFLAGS" \
58+
--config-backtrace=yes \
59+
--config-bcheck=yes \
60+
--debug
61+
62+
gmake
63+
gmake install
64+
65+
popd
66+
67+
rsync -a --delete tinycc/$TCC_FOLDER/ $TCC_FOLDER/
68+
rsync -a thirdparty/tcc.original/.git/ $TCC_FOLDER/.git/
69+
# rsync -a thirdparty/tcc.original/lib/libgc* $TCC_FOLDER/lib/
70+
rsync -a thirdparty/tcc.original/lib/build* $TCC_FOLDER/lib/
71+
rsync -a thirdparty/tcc.original/README.md $TCC_FOLDER/README.md
72+
rsync -a $CURRENT_SCRIPT_PATH $TCC_FOLDER/build.sh
73+
mv $TCC_FOLDER/tcc $TCC_FOLDER/tcc.exe
74+
75+
date > $TCC_FOLDER/build_on_date.txt
76+
echo $TCC_COMMIT_FULL_HASH > $TCC_FOLDER/build_source_hash.txt
77+
$TCC_FOLDER/tcc.exe --version > $TCC_FOLDER/build_version.txt
78+
uname -a > $TCC_FOLDER/build_machine_uname.txt
79+
80+
## show the builtin search paths for sanity checking:
81+
$TCC_FOLDER/tcc.exe -v -v
82+
83+
pushd .
84+
cd $TCC_FOLDER
85+
git add .
86+
git commit -m "build with \`$BUILD_CMD\`"
87+
popd
88+
89+
echo "tcc commit: $TCC_COMMIT , full hash: $TCC_COMMIT_FULL_HASH ."
90+
echo "The tcc executable is ready in $TCC_FOLDER/tcc.exe"

0 commit comments

Comments
 (0)