Further changes improving the OSX build. Everything builds. libtest passes.

Other tests still have issues, currently with weak linking.

One of the primary stumbling blocks on OSX is the lack of support for
mach-o binaries. Therefore all tcc usage on OSX has to be limited to elf
binaries, presumably produced by tcc itself.

Therefore I had to enable building of tiny_libmaker for OSX. Then changed
the make to use tcc and tiny_libmaker to compile the tcclib1.

In order to compile the tests, specifically the parts that use weak linking,
I have had to define MACOSX_DEPLOYMENT_TARGET to 10.2, which seems like a
hack, but extensive searching seems to indicate that this is the only way
to make apple gcc allow weak linking. Using any other value, bigger or smaller
breaks weak linking.

Also added _ANSI_SOURCE define required by some OSX headers, and some cosmetic
gitignore changes. I believe these changes should not impact other platforms.
This commit is contained in:
Milutin Jovanovic 2012-03-06 13:26:36 -05:00
parent ae191c3a61
commit de54586d5b
4 changed files with 27 additions and 11 deletions

5
.gitignore vendored
View File

@ -30,16 +30,19 @@ p.c
p2.c p2.c
tcctest[1234] tcctest[1234]
test[1234].out test[1234].out
tests/tcclib.h
tests/tcctest.gcc
.gdb_history .gdb_history
tcc.1 tcc.1
tcc.pod tcc.pod
config.h config.h
config.mak config.mak
config.texi config.texi
tests
tags tags
.DS_Store .DS_Store
*.swp *.swp
lib/x86_64 lib/x86_64
tcc-doc.info tcc-doc.info
conftest* conftest*
tiny_libmaker
*.dSYM

View File

@ -53,10 +53,6 @@ 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) NATIVE_DEFINES+=$(if $(shell grep -l "^Features.* \(vfp\|iwmmxt\) " /proc/cpuinfo),-DTCC_ARM_VFP)
endif endif
ifeq ($(TARGETOS),Darwin)
NATIVE_DEFINES+=-DWITHOUT_LIBTCC
endif
ifdef CONFIG_WIN32 ifdef CONFIG_WIN32
NATIVE_DEFINES+=-DTCC_TARGET_PE NATIVE_DEFINES+=-DTCC_TARGET_PE
endif endif
@ -144,6 +140,7 @@ BCHECK_O=
endif endif
ifeq ($(TARGETOS),Darwin) ifeq ($(TARGETOS),Darwin)
BCHECK_O= BCHECK_O=
PROGS+=tiny_libmaker$(EXESUF)
endif endif
ifdef CONFIG_USE_LIBGCC ifdef CONFIG_USE_LIBGCC

View File

@ -14,11 +14,15 @@ ifndef TARGET
else else
ifeq ($(ARCH),i386) ifeq ($(ARCH),i386)
TARGET = i386 TARGET = i386
XCC = gcc -O2 -m32 ifneq ($(TARGETOS),Darwin)
XCC = gcc -O2 -m32
endif
else else
ifeq ($(ARCH),x86-64) ifeq ($(ARCH),x86-64)
TARGET = x86_64 TARGET = x86_64
XCC = gcc -O2 -m64 ifneq ($(TARGETOS),Darwin)
XCC = gcc -O2 -m64
endif
endif endif
endif endif
endif endif
@ -55,12 +59,18 @@ else
ifeq "$(TARGET)" "i386" ifeq "$(TARGET)" "i386"
OBJ = $(addprefix $(DIR)/,$(I386_O)) OBJ = $(addprefix $(DIR)/,$(I386_O))
TGT = -DTCC_TARGET_I386 TGT = -DTCC_TARGET_I386
XCC ?= $(TCC) -B$(TOP) XCC ?= $(TCC) -B$(TOP) -m32 -D_ANSI_SOURCE
ifeq ($(TARGETOS),Darwin)
XAR = $(DIR)/tiny_libmaker$(EXESUF)
endif
else else
ifeq "$(TARGET)" "x86_64" ifeq "$(TARGET)" "x86_64"
OBJ = $(addprefix $(DIR)/,$(X86_64_O)) OBJ = $(addprefix $(DIR)/,$(X86_64_O))
TGT = -DTCC_TARGET_X86_64 TGT = -DTCC_TARGET_X86_64
XCC ?= $(TCC) -B$(TOP) XCC ?= $(TCC) -B$(TOP) -m64 -D_ANSI_SOURCE
ifeq ($(TARGETOS),Darwin)
XAR = $(DIR)/tiny_libmaker$(EXESUF)
endif
else else
$(error libtcc1.a not supported on target '$(TARGET)') $(error libtcc1.a not supported on target '$(TARGET)')
endif endif

View File

@ -3,10 +3,10 @@
# #
# what tests to run # what tests to run
TESTS = libtest test3 TESTS = libtest test1 test3
# these should work too # these should work too
# TESTS += test1 test2 speedtest btest weaktest TESTS += test2 speedtest btest weaktest
# these don't work as they should # these don't work as they should
# TESTS += test4 asmtest # TESTS += test4 asmtest
@ -18,6 +18,12 @@ ifdef DISABLE_STATIC
export LD_LIBRARY_PATH:=$(CURDIR)/.. export LD_LIBRARY_PATH:=$(CURDIR)/..
endif endif
ifeq ($(TARGETOS),Darwin)
CFLAGS+=-Wl,-flat_namespace,-undefined,warning
export MACOSX_DEPLOYMENT_TARGET:=10.2
NATIVE_DEFINES+=-D_ANSI_SOURCE
endif
# run local version of tcc with local libraries and includes # run local version of tcc with local libraries and includes
TCC = ../tcc -B.. TCC = ../tcc -B..
RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B.. RUN_TCC = $(NATIVE_DEFINES) -run -DONE_SOURCE ../tcc.c -B..