mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-04 06:30:10 +08:00
Patch attempting to build OSX TinyCC.
Applied patch found on stackoverflow (link below). I also found some related changes that looked like logically needed. The stackoverflow changes addressed only two registers which were breaking a compile. However reading the code in the same file shows two other register accesses that, while not breaking the build, should have the same fix. http://stackoverflow.com/questions/3712902/problems-compiling-tcc-on-os-x/3713144#3713144 The test driver was changed by changing 'cp -u' into 'cp' as '-u' is not supported on mac osx. I found that osx build required the WITHOUT_LIBTCC define. I suspect the reason for this is tcc unability to handle mach-o files. In order to properly address this I had to change 'configure' to propagate target os name to Makefile. Current state is that simple tests work, but not the whole 'make test' suite runs. To the best of my knowledge, these changes should not impact other platforms.
This commit is contained in:
parent
9527c4949f
commit
8ca8b08890
5
.gitignore
vendored
5
.gitignore
vendored
@ -38,3 +38,8 @@ config.mak
|
||||
config.texi
|
||||
tests
|
||||
tags
|
||||
.DS_Store
|
||||
*.swp
|
||||
lib/x86_64
|
||||
tcc-doc.info
|
||||
conftest*
|
||||
|
4
Makefile
4
Makefile
@ -51,6 +51,10 @@ NATIVE_DEFINES+=$(if $(wildcard /lib/ld-linux.so.3),-DTCC_ARM_EABI)
|
||||
NATIVE_DEFINES+=$(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo),-DTCC_ARM_VFP)
|
||||
endif
|
||||
|
||||
ifeq ($(TARGETOS),Darwin)
|
||||
NATIVE_DEFINES+=-DWITHOUT_LIBTCC
|
||||
endif
|
||||
|
||||
ifdef CONFIG_WIN32
|
||||
NATIVE_DEFINES+=-DTCC_TARGET_PE
|
||||
endif
|
||||
|
2
configure
vendored
2
configure
vendored
@ -352,6 +352,7 @@ echo "Doc directory $docdir"
|
||||
echo "Target root prefix $sysroot"
|
||||
echo "Source path $source_path"
|
||||
echo "C compiler $cc"
|
||||
echo "Target OS $targetos"
|
||||
echo "CPU $cpu"
|
||||
echo "Big Endian $bigendian"
|
||||
echo "gprof enabled $gprof"
|
||||
@ -425,6 +426,7 @@ else
|
||||
echo "Unsupported CPU"
|
||||
exit 1
|
||||
fi
|
||||
echo "TARGETOS=$targetos" >> config.mak
|
||||
if test "$noldl" = "yes" ; then
|
||||
echo "CONFIG_NOLDL=yes" >> config.mak
|
||||
fi
|
||||
|
16
tccrun.c
16
tccrun.c
@ -461,7 +461,9 @@ static int rt_get_caller_pc(unsigned long *paddr, ucontext_t *uc, int level)
|
||||
int i;
|
||||
|
||||
if (level == 0) {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if defined(__APPLE__)
|
||||
*paddr = uc->uc_mcontext->__ss.__eip;
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
*paddr = uc->uc_mcontext.mc_eip;
|
||||
#elif defined(__dietlibc__)
|
||||
*paddr = uc->uc_mcontext.eip;
|
||||
@ -470,7 +472,9 @@ static int rt_get_caller_pc(unsigned long *paddr, ucontext_t *uc, int level)
|
||||
#endif
|
||||
return 0;
|
||||
} else {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if defined(__APPLE__)
|
||||
fp = uc->uc_mcontext->__ss.__ebp;
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
fp = uc->uc_mcontext.mc_ebp;
|
||||
#elif defined(__dietlibc__)
|
||||
fp = uc->uc_mcontext.ebp;
|
||||
@ -500,14 +504,18 @@ static int rt_get_caller_pc(unsigned long *paddr,
|
||||
|
||||
if (level == 0) {
|
||||
/* XXX: only support linux */
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if defined(__APPLE__)
|
||||
*paddr = uc->uc_mcontext->__ss.__rip;
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
*paddr = uc->uc_mcontext.mc_rip;
|
||||
#else
|
||||
*paddr = uc->uc_mcontext.gregs[REG_RIP];
|
||||
#endif
|
||||
return 0;
|
||||
} else {
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#if defined(__APPLE__)
|
||||
fp = uc->uc_mcontext->__ss.__rbp;
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
fp = uc->uc_mcontext.mc_rbp;
|
||||
#else
|
||||
fp = uc->uc_mcontext.gregs[REG_RBP];
|
||||
|
@ -45,7 +45,7 @@ libtcc_test$(EXESUF): libtcc_test.c ../$(LIBTCC)
|
||||
# test.ref - generate using gcc
|
||||
# copy only tcclib.h so GCC's stddef and stdarg will be used
|
||||
test.ref: tcctest.c
|
||||
cp -u ../include/tcclib.h .
|
||||
cp ../include/tcclib.h .
|
||||
$(CC) -o tcctest.gcc $< -I. -w $(CFLAGS) -std=gnu99
|
||||
./tcctest.gcc > $@
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user