| 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 | ## ensure all output is in English, independent from the current user's local: |
| 11 | export LANG=C |
| 12 | |
| 13 | export CURRENT_SCRIPT_PATH=$(realpath "$0") |
| 14 | |
| 15 | export CC="${CC:-gcc}" |
| 16 | export TCC_FOLDER="${TCC_FOLDER:-thirdparty/tcc}" |
| 17 | export LIBGC_COMMIT="${LIBGC_COMMIT:-master}" |
| 18 | mkdir -p $TCC_FOLDER/lib/ |
| 19 | |
| 20 | echo " CC: $CC" |
| 21 | echo " TCC_FOLDER: $TCC_FOLDER" |
| 22 | echo "LIBGC_COMMIT: $LIBGC_COMMIT" |
| 23 | echo =============================================================== |
| 24 | |
| 25 | rm -rf bdwgc/ |
| 26 | |
| 27 | pushd . |
| 28 | git clone https://github.com/ivmai/bdwgc |
| 29 | cd bdwgc/ |
| 30 | |
| 31 | git checkout $LIBGC_COMMIT |
| 32 | export LIBGC_COMMIT_FULL_HASH=$(git rev-parse HEAD) |
| 33 | |
| 34 | git clone https://github.com/bdwgc/libatomic_ops |
| 35 | |
| 36 | ./autogen.sh |
| 37 | |
| 38 | CC=$CC CFLAGS="-Os -mtune=generic -fPIC" LDFLAGS="-Os -fPIC" ./configure \ |
| 39 | --disable-dependency-tracking \ |
| 40 | --disable-docs \ |
| 41 | --enable-static=yes \ |
| 42 | --enable-shared=yes \ |
| 43 | --enable-single-obj-compilation \ |
| 44 | --enable-gc-debug \ |
| 45 | --enable-large-config \ |
| 46 | --enable-cplusplus \ |
| 47 | --with-libatomic-ops=check \ |
| 48 | --enable-sigrt-signals |
| 49 | |
| 50 | make |
| 51 | |
| 52 | cd .libs/ |
| 53 | for dname in *.dylib; do |
| 54 | echo "Post processing ${dname} ..." |
| 55 | install_name_tool -id "@rpath/${dname}" $dname; |
| 56 | otool -D $dname; |
| 57 | done |
| 58 | |
| 59 | popd |
| 60 | |
| 61 | ################################################################################################ |
| 62 | date > $TCC_FOLDER/lib/libgc_build_on_date.txt |
| 63 | echo $LIBGC_COMMIT_FULL_HASH > $TCC_FOLDER/lib/libgc_build_source_hash.txt |
| 64 | uname -a > $TCC_FOLDER/lib/libgc_build_machine_uname.txt |
| 65 | echo "$0" > $TCC_FOLDER/lib/libgc_build_cmd.txt |
| 66 | |
| 67 | rsync -a bdwgc/.libs/ $TCC_FOLDER/lib/ |
| 68 | ls -lad $TCC_FOLDER/lib/* |
| 69 | |
| 70 | echo "Done compiling libgc, at commit $LIBGC_COMMIT , full hash: $LIBGC_COMMIT_FULL_HASH . The static library is in $TCC_FOLDER/lib/libgc.a " |
| 71 | |