Skip to content

Instantly share code, notes, and snippets.

@Larpon
Last active November 13, 2023 12:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Larpon/998febd5f3c33f995f0ecd561c043dcb to your computer and use it in GitHub Desktop.
Save Larpon/998febd5f3c33f995f0ecd561c043dcb to your computer and use it in GitHub Desktop.
#!/bin/bash
## should be run in V's main repo folder!
rm -rf tinycc/
rm -rf thirdparty/tcc/
pushd .
git clone git://repo.or.cz/tinycc.git
cd tinycc
./configure \
--prefix=thirdparty/tcc \
--bindir=thirdparty/tcc \
--crtprefix=thirdparty/tcc/lib:/usr/lib:/usr/lib/arm-linux-gnueabihf \
--libpaths=thirdparty/tcc/lib:/usr/lib/arm-linux-gnueabihf:/usr/lib:/lib/arm-linux-gnueabihf:/lib:/usr/local/lib/arm-linux-gnueabihf:/usr/local/lib \
--extra-cflags="-O3 -flto" \
--debug
make
make install
popd
mv tinycc/thirdparty/tcc thirdparty/tcc
mv thirdparty/tcc/tcc thirdparty/tcc/tcc.exe
thirdparty/tcc/tcc.exe -v -v
ln -s /usr/lib/arm-linux-gnueabihf/libatomic.so.1 "$(pwd)/thirdparty/tcc/lib/libatomic.so"
ln -s /usr/lib/arm-linux-gnueabihf/libgc.a "$(pwd)/thirdparty/tcc/lib/libgc.a"
export LD_FLAGS=-latomic
@wbehrens-on-gh
Copy link

for me I found the easiest fix was just running LDFLAGS+=-latomic make

@Larpon
Copy link
Author

Larpon commented Mar 18, 2022

for me I found the easiest fix was just running LDFLAGS+=-latomic make

Nice - that didn't work for me unfortunately.

Do you have tcc working?
E.g. try: v -no-retry-compilation self
(-no-retry-compilation is to ensure that v doesn't switch to gcc automatically)

@Larpon
Copy link
Author

Larpon commented Sep 2, 2023

Relayed from Discord:

credits to @spytheman :
"the full script so far from a fresh Raspbian installation with tcc is:"

#!/bin/bash

set -x ## show commands as they run
set -e ## stop on errors

sudo apt-get install git build-essential libatomic1 libgc-dev libc6-dev
cc --version ## should be a modern-ish gcc or clang
make --version ## should be GNU Make

export VFLAGS='-cc /usr/local/bin/tcc -d dynamic_boehm'
export LDFLAGS='-latomic'

pushd .
git clone git://repo.or.cz/tinycc.git
cd tinycc/
./configure --extra-cflags='-O3 -flto' ## or --debug initially
make
sudo make install
popd
rm -rf tinycc/
tcc --version ## similar to: 'tcc version 0.9.27 2023-08-31 mob@...'

git clone https://github.com/vlang/v
cd v
make
./v --version
./v run examples/hello_world.v ## should work
echo 'println(2+2)' | ./v ## should be 4

Without tcc (more reliable, but slower):

#!/bin/bash

set -x ## show commands as they run
set -e ## stop on errors

sudo apt-get install git build-essential libatomic1 libgc-dev libc6-dev
cc --version ## should be a modern-ish gcc or clang
make --version ## should be GNU Make

export VFLAGS='-cc cc -d dynamic_boehm'
export LDFLAGS='-latomic'

git clone https://github.com/vlang/v
cd v
make
./v --version
./v run examples/hello_world.v ## should work
echo 'println(2+2)' | ./v ## should be 4

More resources on how to compile/use it there:
vlang/v#13759
and the exports can be added to the end of ~/.bashrc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment