macos: more adjustments for OSX systems

* instead of /usr/include use the current SDK path as system
  include directory (/usr/include is empty with current tools)
  (this also removes the need to add these paths in individual
  Makefiles)
* define _DARWIN_C_SOURCE in tcc.h to get the full set of decls
  from system headers (e.g. vsnprintf), similar to _GNU_SOURCE
  (and don't define _ANSI_SOURCE in the main Makefile anymore)
* tests/tests2/Makefile: remove the -w flag, it's added when necessary
  in the rules generating the .expect files
This commit is contained in:
Michael Matz 2020-05-22 05:27:30 +02:00
parent f18f865159
commit 4eff2b5f6a
5 changed files with 10 additions and 11 deletions

View File

@ -58,9 +58,6 @@ TCCFLAGS-unx = -B$(TOP) -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP)
TCCFLAGS-win = -B$(TOPSRC)/win32 -I$(TOPSRC)/include -I$(TOPSRC) -I$(TOP) -L$(TOP)
TCCFLAGS = $(TCCFLAGS$(CFGWIN))
TCC = $(TOP)/tcc$(EXESUF) $(TCCFLAGS)
ifdef CONFIG_OSX
TCCFLAGS += -D_ANSI_SOURCE
endif
# cross compiler targets to build
TCC_X = i386 x86_64 i386-win32 x86_64-win32 x86_64-osx arm arm64 arm-wince c67

4
configure vendored
View File

@ -35,6 +35,7 @@ mingw32="no"
LIBSUF=".a"
EXESUF=""
DLLSUF=".so"
tcc_usrinclude=""
tcc_sysincludepaths=""
tcc_libpaths=""
tcc_crtprefix=""
@ -53,6 +54,7 @@ targetos=`uname`
case $targetos in
Darwin)
confvars="$confvars OSX"
tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"
DLLSUF=".dylib"
;;
Windows_NT|MINGW*|MSYS*|CYGWIN*)
@ -401,6 +403,7 @@ fcho "Manual directory " "$mandir"
fcho "Info directory " "$infodir"
fcho "Doc directory " "$docdir"
fcho "Target root prefix " "$sysroot"
fcho "/usr/include dir " "$tcc_usrinclude"
echo "Source path $source_path"
echo "C compiler $cc ($gcc_major.$gcc_minor)"
echo "Target OS $targetos"
@ -455,6 +458,7 @@ echo "/* Automatically generated by configure - do not modify */" > $TMPH
print_inc CONFIG_SYSROOT "$sysroot"
print_inc CONFIG_TCCDIR "$tccdir"
print_mak CONFIG_USR_INCLUDE "$tcc_usrinclude"
print_mak CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
print_mak CONFIG_TCC_LIBPATHS "$tcc_libpaths"
print_mak CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"

View File

@ -17,10 +17,6 @@ XFLAGS = $(XFLAGS$(XCFG)) -I$(TOP)
XCFG = $(or $(findstring -win,$T),-unx)
S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
ifdef CONFIG_OSX
XFLAGS += -I`xcrun --show-sdk-path`/usr/include
endif
# in order to use gcc, type: make <target>-libtcc1-usegcc=yes
arm-libtcc1-usegcc ?= no

7
tcc.h
View File

@ -22,6 +22,7 @@
#define _TCC_H
#define _GNU_SOURCE
#define _DARWIN_C_SOURCE
#include "config.h"
#include <stdarg.h>
@ -217,6 +218,10 @@ extern long double strtold (const char *__nptr, char **__endptr);
# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)
#endif
#ifndef CONFIG_USR_INCLUDE
# define CONFIG_USR_INCLUDE "/usr/include"
#endif
/* Below: {B} is substituted by CONFIG_TCCDIR (rsp. -B option) */
/* system include paths */
@ -227,7 +232,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
# define CONFIG_TCC_SYSINCLUDEPATHS \
"{B}/include" \
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)
# endif
#endif

View File

@ -15,9 +15,6 @@ endif
ifdef CONFIG_OSX
SKIP += 40_stdio.test 42_function_pointer.test
SKIP += 113_btdll.test # no shared lib support yet
FLAGS += -w
SDK := `xcrun --show-sdk-path`
TCCFLAGS += -I$(SDK)/usr/include
endif
ifeq ($(ARCH),x86_64)
SKIP += 73_arm64.test