Tcc + Open2x App Libs


xhyldazhk

Still Fresh
Joined
Feb 16, 2006
Messages
47
Hi all,

I usually use TCC-arm + Termula2x to do onboard development while commuting. I just installed on my andLinux Open2x to take advantage of its optimizations, and tried replacing the libs i configured for TCC (that if i remember well are the official SDK ones) with the Open2x libs. The result: The executables produced now segfault. Any help on this? Thanks in advance.
 
Hi, i have to admit i have never used TCC etc. Theres a good chance that the libs are using a conflicting version with those on the gp2x. Have you tried statically linking by passing in '-static' to the linker to see if that helps?

Thats the first thing that came to mind, hope that helps
 
Thanks Lonewolf... Yes, i've been linking them statically... But i think it could have more to do with the fact that Open2x libs are compiled with soft float emulation or something alike... there is any patch to enable tcc to link with libraries compiled with gcc and soft float emulation?
 
I use this script to build the TinyCC onboard package in a bash environment, like MinGW or native GNU/Linux. Its installed on dev/tcc inside of the SD card.
CODE
#!/bin/sh

# tcc_distro.sh
# This script tries to generate a GP2X suitable TCC distro.

# CVS path to retrieve latest TCC sources
TCC_CVS_PATH=":pserver:anonymous@cvs.savannah.nongnu.org:/sources/tinycc"

# ARM libtcc1.a sourcecode URL
LIBTCC1_ARM_URL="http://www.stud.uni-hannover.de/~daniel/tcc"
LIBTCC1_ARM_FILE="libtcc1-src.tar.gz"

# onboard prefix
PREFIX="/mnt/sd/dev/tcc"

# cross compiler
CC="arm-gp2x-linux-gcc"

# library archiver
AR="arm-gp2x-linux-ar"

# crt1.o, crtn.o path
OBJ01="/e/GP2XSDK/Tools/arm-gp2x-linux/lib"

# standard library path
LIB01="/e/GP2XSDK/Tools/arm-gp2x-linux/lib"

# extra libraries path
LIB02="/e/GP2XSDK/Tools/arm-gp2x-linux/lib"

# libgcc.a path
LIB03="/e/GP2XSDK/Tools/lib/gcc/arm-gp2x-linux/3.4.6"

# compiler internals include path
INCLUDE01="/e/GP2XSDK/Tools/lib/gcc/arm-gp2x-linux/3.4.6/include"

# standard include path
INCLUDE02="/e/GP2XSDK/Tools/arm-gp2x-linux/include"

# extra include path
INCLUDE03="/e/GP2XSDK/Tools/include"

# name of the generated patch
PATCH01="tinycc_ofiles_prefix.patch"

# extra options to compiler
CFLAGS="-static"

rm -rf tinycc
cvs -z3 -d$TCC_CVS_PATH co tinycc
cat<<EOF>$PATCH01
--- tinycc/tcc.c 2007-06-30 09:08:52.000000000 -0500
+++ tinycc/tcc.c 2007-06-30 08:49:59.000000000 -0500
@@ -113,7 +113,7 @@

/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
executables or dlls */
-#define CONFIG_TCC_CRT_PREFIX "/usr/lib"
+#define CONFIG_TCC_CRT_PREFIX CONFIG_TCCDIR

#define INCLUDE_STACK_SIZE 32
#define IFDEF_STACK_SIZE 64
EOF
patch -p0 < $PATCH01
cd tinycc
./configure --prefix=$PREFIX --enable-cross \
--cc="$CC"
$CC $CFLAGS -O2 -g -Wall -falign-functions=0 -fno-strict-aliasing -DTCC_TARGET_ARM \
-o tcc tcc.c -ldl
cd ..

wget -c $LIBTCC1_ARM_URL/$LIBTCC1_ARM_FILE
tar xvzf $LIBTCC1_ARM_FILE
cat makelib1 | sed -e "s/arm-linux-gcc/$CC/g" > makelib.modified1
cat makelib.modified1 | sed -e "s/arm-linux-ar/$AR/g" > makelib.modified
rm -rf makelib.modified1
sh makelib.modified

rm -rf distro
mkdir distro
mkdir distro/tcc
mkdir distro/tcc/bin
cp tinycc/tcc distro/tcc/bin
mkdir distro/tcc/lib
mkdir distro/tcc/lib/tcc
echo -n "Copying object files... "
cp -rL $OBJ01/crt*.o distro/tcc/lib/tcc
echo "done."
echo -n "Copying libs... "
cp -rL libtcc1.a distro/tcc/lib/tcc
cp -rL $LIB01/lib* distro/tcc/lib
cp -rL $LIB02/lib* distro/tcc/lib
cp -rL $LIB03/lib* distro/tcc/lib
echo "done."
mkdir distro/tcc/lib/tcc/include
echo -n "Copying include files... "
cp -rL $INCLUDE01/* distro/tcc/lib/tcc/include
cp -rL $INCLUDE02/* distro/tcc/lib/tcc/include
cp -rL $INCLUDE03/* distro/tcc/lib/tcc/include
# to override stdarg.h, because SDK's one doesn't seem to work with TCC
cp -rL tinycc/std*.h distro/tcc/lib/tcc/include
echo "done."




I have to set up paths in my .bashrc so /mnt/sd/dev/tcc/bin is en the path.

I hope this helps you all.
 
At least! I made Tiny C Compiler work with the official libs...
You will need:
- The official SDK
- The latest patch to the official SDK
- MSYS with CVS
- wget in your path

This script is easily adaptable to run on other operating system
CODE
#!/bin/sh

# tcc_distro.sh
# This script tries to generate a GP2X suitable TCC distro.

# for GP2XSDK+MSYS
export PATH=$PATH:/c/GP2XSDK/dll:/c/GP2XSDK/Tools/bin

# CVS path to retrieve latest TCC sources
TCC_CVS_PATH=":pserver:anonymous@cvs.savannah.nongnu.org:/sources/tinycc"

# ARM libtcc1.a sourcecode URL
LIBTCC1_ARM_URL="http://www.stud.uni-hannover.de/~daniel/tcc"
LIBTCC1_ARM_FILE="libtcc1-src.tar.gz"

# onboard prefix
PREFIX="/mnt/sd/dev/tcc"

# cross compiler
CC="arm-gp2x-linux-gcc"

# library archiver
AR="arm-gp2x-linux-ar"

# crt1.o, crtn.o path
OBJ01="/c/GP2XSDK/Tools/arm-gp2x-linux/lib"

# standard library path
LIB01="/c/GP2XSDK/Tools/arm-gp2x-linux/lib"

# extra libraries path
LIB02="/c/GP2XSDK/Tools/arm-gp2x-linux/lib"

# libgcc.a path
LIB03="/c/GP2XSDK/Tools/lib/gcc/arm-gp2x-linux/3.4.6"

# compiler internals include path
INCLUDE01="/c/GP2XSDK/Tools/lib/gcc/arm-gp2x-linux/3.4.6/include"

# standard include path
INCLUDE02="/c/GP2XSDK/Tools/arm-gp2x-linux/include"

# extra include path
INCLUDE03="/c/GP2XSDK/Tools/include"

# name of the generated patch
PATCH01="tinycc_ofiles_prefix.patch"

# extra options to compiler
#CFLAGS="-static"
CFLAGS=""

rm -rf tinycc
cvs -z3 -d$TCC_CVS_PATH co tinycc
cat<<EOF>$PATCH01
--- tinycc/tcc.c 2007-06-30 09:08:52.000000000 -0500
+++ tinycc/tcc.c 2007-06-30 08:49:59.000000000 -0500
@@ -113,7 +113,7 @@

/* path to find crt1.o, crti.o and crtn.o. Only needed when generating
executables or dlls */
-#define CONFIG_TCC_CRT_PREFIX CONFIG_SYSROOT "/usr/lib"
+#define CONFIG_TCC_CRT_PREFIX CONFIG_TCCDIR

#define INCLUDE_STACK_SIZE 32
#define IFDEF_STACK_SIZE 64
EOF
patch -p0 < $PATCH01
rm -rf $PATCH01
cd tinycc
./configure --prefix=$PREFIX --enable-cross \
--cc="$CC"
$CC $CFLAGS -O2 -g -Wall -falign-functions=0 -fno-strict-aliasing -DTCC_TARGET_ARM \
-o tcc tcc.c -ldl
cd ..

wget -c $LIBTCC1_ARM_URL/$LIBTCC1_ARM_FILE
tar xvzf $LIBTCC1_ARM_FILE
cat makelib1 | sed -e "s/arm-linux-gcc/$CC/g" > makelib.modified1
cat makelib.modified1 | sed -e "s/arm-linux-ar/$AR/g" > makelib.modified
rm -rf makelib.modified1
sh makelib.modified
rm -rf makelib.modified

rm -rf distro
mkdir distro
mkdir distro/tcc
mkdir distro/tcc/bin
cp tinycc/tcc distro/tcc/bin
mkdir distro/tcc/lib
#mkdir distro/tcc/lib/tcc
echo -n "Copying object files... "
cp -rL $OBJ01/crt*.o distro/tcc/
echo "done."
echo -n "Copying libs... "
cp -rL libtcc1.a distro/tcc/
cp -rL $LIB01/lib* distro/tcc/lib
cp -rL $LIB02/lib* distro/tcc/lib
cp -rL $LIB03/lib* distro/tcc/lib
echo "done."
mkdir distro/tcc/include
echo -n "Copying include files... "
cp -rL $INCLUDE01/* distro/tcc/include
cp -rL $INCLUDE02/* distro/tcc/include
cp -rL $INCLUDE03/* distro/tcc/include
# to override stdarg.h, because SDK's one doesn't seem to work with TCC
cp -rL tinycc/std*.h distro/tcc/include
echo "done."
echo -n "Cleaning up... "
rm -rf tinycc
echo "done."




With this and Termula2x, you can code games on the go...
 
Back
Top