Check-in [fd6711ab73]
Overview
Comment:Updated to not build TCC as a static so that existing symbols could resolved by TCC itself
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fd6711ab7374b8fff538aa6ef3ad4869af256555
User & Date: rkeene on 2014-06-16 04:48:58
Other Links: manifest | tags
Context
2014-06-17
05:26
tcc4tcl 0.19 check-in: 3c95a2ab7e user: rkeene tags: trunk, 0.19
2014-06-16
04:48
Updated to not build TCC as a static so that existing symbols could resolved by TCC itself check-in: fd6711ab73 user: rkeene tags: trunk
04:20
Updated to allow external symbols to be resolved if dlopen() is available check-in: 82e8ebb242 user: rkeene tags: trunk
Changes

Modified Makefile.in from [a0fe9448ac] to [0a8186dc49].

    19     19   PACKAGE_NAME = @PACKAGE_NAME@
    20     20   PACKAGE_VERSION = @PACKAGE_VERSION@
    21     21   
    22     22   TCLCONFIGPATH = @TCLCONFIGPATH@
    23     23   TCL_PACKAGE_PATH = @TCL_PACKAGE_PATH@
    24     24   tcllibdir = $(shell if echo "$(libdir)" | grep '^UNSPECIFIED' >/dev/null; then echo $(TCL_PACKAGE_PATH); else echo "$(libdir)"; fi)
    25     25   PACKAGE_INSTALL_DIR = $(tcllibdir)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
    26         -TCC_CONFIGURE_OPTS = --cc='$(CC)' --extra-cflags='$(CPPFLAGS) $(CFLAGS) -DCONFIG_TCC_STATIC=1' --with-tcl=$(TCLCONFIGPATH) --sysincludepaths='{B}/include@HOST_PATH_SEPARATOR@{B}/include/1@HOST_PATH_SEPARATOR@{B}/include/2@HOST_PATH_SEPARATOR@{B}/include/3@HOST_PATH_SEPARATOR@{B}/include/4@HOST_PATH_SEPARATOR@{B}/include/5@HOST_PATH_SEPARATOR@{B}/include/6@HOST_PATH_SEPARATOR@{B}/include/7@HOST_PATH_SEPARATOR@{B}/include/8@HOST_PATH_SEPARATOR@{B}/include/9' --libpaths='{B}/lib' @TCC_CONFIGURE_OPTS@
           26  +TCC_CONFIGURE_OPTS = --cc='$(CC)' --extra-cflags='$(CPPFLAGS) $(CFLAGS) @TCC_EXTRA_CFLAGS@' --with-tcl=$(TCLCONFIGPATH) --sysincludepaths='{B}/include@HOST_PATH_SEPARATOR@{B}/include/1@HOST_PATH_SEPARATOR@{B}/include/2@HOST_PATH_SEPARATOR@{B}/include/3@HOST_PATH_SEPARATOR@{B}/include/4@HOST_PATH_SEPARATOR@{B}/include/5@HOST_PATH_SEPARATOR@{B}/include/6@HOST_PATH_SEPARATOR@{B}/include/7@HOST_PATH_SEPARATOR@{B}/include/8@HOST_PATH_SEPARATOR@{B}/include/9' --libpaths='{B}/lib' @TCC_CONFIGURE_OPTS@
    27     27   INSTALL_HEADERS = tcl.h assert.h ctype.h errno.h float.h limits.h locale.h math.h setjmp.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h time.h wctype.h
    28     28   srcdir = @srcdir@
    29     29   host_os = @host_os@
    30     30   @SET_MAKE@
    31     31   
    32     32   all: $(TARGET)
    33     33   

Deleted aclocal/dlsym.m4 version [9b676022d2].

     1         -AC_DEFUN([TCC4TCL_FIND_DLOPEN], [
     2         -	AC_CHECK_HEADERS_ONCE([dlfcn.h])
     3         -
     4         -	AC_SEARCH_LIBS([dlsym], [dl dld], [
     5         -		AC_DEFINE([HAVE_DLSYM], [1], [Have the dlsym function])
     6         -	], [
     7         -		AC_CHECK_HEADERS([windows.h])
     8         -
     9         -		AC_MSG_CHECKING([for working EnumProcessModules])
    10         -		SAVE_LIBS="$LIBS"
    11         -		LIBS="$LIBS -lpsapi"
    12         -		AC_LINK_IFELSE([
    13         -			AC_LANG_PROGRAM([
    14         -#ifdef HAVE_WINDOWS_H
    15         -#  include <windows.h>
    16         -#endif
    17         -#include <psapi.h>
    18         -			], [
    19         -HANDLE cur_proc;
    20         -DWORD needed;
    21         -
    22         -needed = 0;
    23         -
    24         -cur_proc = GetCurrentProcess();
    25         -EnumProcessModules(cur_proc, NULL, 0, &needed);
    26         -			]
    27         -		)], [
    28         -			AC_DEFINE([HAVE_ENUMPROCESSMODULES], [1], [Have the EnumProcessModules function])
    29         -			AC_DEFINE([HAVE_PSAPI_H], [1], [Have the psapi.h header file])
    30         -			AC_MSG_RESULT([found])
    31         -		], [
    32         -			LIBS="$SAVE_LIBS"
    33         -			AC_MSG_RESULT([not found])
    34         -		])
    35         -	])
    36         -])

Modified build/build-platform from [af2d67d68b] to [50ab5da7e8].

     1      1   #! /bin/bash
     2      2   
     3      3   platform="$1"
     4      4   shift
     5      5   
     6      6   if [ -z "${platform}" ]; then
     7      7   	echo "Platforms:"
            8  +	echo "  native"
     8      9   fi
     9     10   
    10     11   for dir in work/libtclkit-*/ __fail__; do
           12  +	if [ "${platform}" = 'native' ]; then
           13  +		break
           14  +	fi
           15  +
    11     16   	if [ "${dir}" == '__fail__' ]; then
    12     17   		if [ -z "${platform}" ]; then
    13     18   			exit 0
    14     19   		fi
    15     20   
    16     21   		echo "No such platform: ${platform}" >&2
    17     22   
................................................................................
    28     33   			break
    29     34   		fi
    30     35   	fi
    31     36   done
    32     37   dir="$(pwd)/${dir}"
    33     38   
    34     39   case "${platform}" in
           40  +	native)
           41  +		platform=''
           42  +		;;
    35     43   	linux-i386)
    36     44   		platform="x86_64-redhat5-linux 32"
    37     45   		;;
    38     46   	linux-mipsel)
    39     47   		platform="mipsel-unknown-linux-uclibc"
    40     48   		;;
    41     49   	solaris-amd64)
................................................................................
    66     74   		;;
    67     75   esac
    68     76   
    69     77   TCLKIT_SDK_DIR="${dir}"
    70     78   export TCLKIT_SDK_DIR
    71     79   
    72     80   make distclean
    73         -eval `~/root/cross-compilers/setup-cc $platform`
           81  +
           82  +if [ "${platform}" != '' ]; then
           83  +	eval `~/root/cross-compilers/setup-cc $platform`
           84  +
           85  +	platform="$(echo "${platform}" | cut -f1 -d ' ')"
           86  +fi
    74     87   
    75         -platform="$(echo "${platform}" | cut -f1 -d ' ')"
           88  +rm -rf INST
           89  +if [ "${platform}" = '' ]; then
           90  +	./configure --libdir="$(pwd)/INST" "$@" || exit 1
           91  +else
           92  +	./configure --host="${platform}" --libdir="$(pwd)/INST" --with-tcl="${dir}/lib" "$@" || exit 1
           93  +fi
    76     94   
    77         -./configure --host="${platform}" --libdir="$(pwd)/INST" --with-tcl="${dir}/lib" "$@"
    78         -make 
           95  +make  || exit 1
    79     96   make install
           97  +
           98  +case "${platform}" in
           99  +	i586-mingw32msvc)
          100  +		make TCLSH="wine ${dir}/lib/tclsh.exe" test
          101  +		;;
          102  +	x86_64-w64-mingw32)
          103  +		WINEPREFIX="${HOME}/.wine64"
          104  +		export WINEPREFIX
          105  +
          106  +		make TCLSH="wine64 ${dir}/lib/tclsh.exe" test
          107  +		;;
          108  +	x86_64-redhat5-linux)
          109  +		make TCLSH="${dir}/lib/tclsh" test
          110  +		;;
          111  +	'')
          112  +		make test
          113  +		;;
          114  +esac

Modified configure.ac from [13d9b5f529] to [b6d99aa0b3].

    34     34   if test "${TCC4TCL_TARGET}" = "shared"; then
    35     35   	dnl Determine how to make shared objects
    36     36   	DC_GET_SHOBJFLAGS
    37     37   
    38     38   	dnl Only export symbols we wish to expose
    39     39   	TARGET="tcc4tcl.${SHOBJEXT}"
    40     40   else
           41  +	TCC_EXTRA_CFLAGS="${TCC_EXTRA_CFLAGS} -DCONFIG_TCC_STATIC=1"
           42  +
    41     43   	AC_CHECK_TOOL([RANLIB], [ranlib])
    42     44   	AC_CHECK_TOOL([AR], [ar])
    43     45   
    44     46   	TARGET="tcc4tcl-static.a"
    45     47   fi
    46     48   AC_SUBST(TARGET)
    47     49   AC_SUBST(TCC4TCL_TARGET)
           50  +AC_SUBST(TCC_EXTRA_CFLAGS)
    48     51   
    49     52   no_dlopen='0'
    50     53   AC_ARG_WITH([dlopen], AS_HELP_STRING([--without-dlopen], [do not define dlopen/dlclose/dlerror]), [
    51     54   	if test "$withval" = "no"; then
    52     55   		no_dlopen='1'
    53     56   	else
    54     57   		no_dlopen='0'
................................................................................
    66     69   		;;
    67     70   	*)
    68     71   		HOST_PATH_SEPARATOR=':'
    69     72   		;;
    70     73   esac
    71     74   AC_SUBST(HOST_PATH_SEPARATOR)
    72     75   
    73         -dnl Determine how to lookup symbols at runtime
    74         -TCC4TCL_FIND_DLOPEN
    75         -
    76     76   dnl Perform Tcl Extension required stuff
    77     77   TCLEXT_INIT
    78     78   
    79     79   dnl This must be done last since it breaks the compilation
    80     80   if test "${TCC4TCL_TARGET}" = "shared"; then
    81     81   	DC_SETVERSIONSCRIPT([${srcdir}/tcc4tcl.vers], [tcc4tcl.syms])
    82     82   	DC_FIND_STRIP_AND_REMOVESYMS([tcc4tcl.syms])
    83     83   fi
    84     84   
    85     85   dnl Produce output
    86     86   AC_OUTPUT(Makefile pkgIndex.tcl tcc4tcl.syms)

Modified tcc4tcl.c from [0dd7284c29] to [24c78e2cb7].

    18     18    * License along with this library; if not, write to the Free Software
    19     19    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    20     20    */
    21     21   
    22     22   #include <tcl.h>
    23     23   #include <stdlib.h>
    24     24   #include "tcc.h"
    25         -#ifdef HAVE_DLFCN_H
    26         -#include <dlfcn.h>
    27         -#endif
    28         -#ifdef HAVE_PSAPI_H
    29         -#  ifdef HAVE_WINDOWS_H
    30         -#    include <windows.h>
    31         -#  endif
    32         -#  include <psapi.h>
    33         -#endif
    34     25   
    35     26   struct TclTCCState {
    36     27   	TCCState *s;
    37     28   	int relocated;
    38     29   };
    39     30   
    40     31   static void Tcc4tclErrorFunc(Tcl_Interp * interp, char * msg) {
................................................................................
    65     56   	struct TclTCCState *ts;
    66     57   	TCCState *s;
    67     58   	Tcl_Obj *sym_addr;
    68     59   	static CONST char *options[] = {
    69     60   		"add_include_path", "add_file",  "add_library", 
    70     61   		"add_library_path", "add_symbol", "command", "compile",
    71     62   		"define", "get_symbol", "output_file", "undefine",
    72         -		"add_runtime_sym",
    73     63   		(char *) NULL
    74     64   	};
    75     65   	enum options {
    76     66   		TCC4TCL_ADD_INCLUDE, TCC4TCL_ADD_FILE, TCC4TCL_ADD_LIBRARY, 
    77     67   		TCC4TCL_ADD_LIBRARY_PATH, TCC4TCL_ADD_SYMBOL, TCC4TCL_COMMAND, TCC4TCL_COMPILE,
    78         -		TCC4TCL_DEFINE, TCC4TCL_GET_SYMBOL, TCC4TCL_OUTPUT_FILE, TCC4TCL_UNDEFINE,
    79         -		TCC4TCL_ADD_RUNTIME_SYM
           68  +		TCC4TCL_DEFINE, TCC4TCL_GET_SYMBOL, TCC4TCL_OUTPUT_FILE, TCC4TCL_UNDEFINE
    80     69   	};
    81     70   	char *str;
    82     71   
    83     72   	ts = (struct TclTCCState *) cdata;
    84     73   	s = ts->s;
    85     74   
    86     75       if (objc < 2) {
................................................................................
   234    223           case TCC4TCL_UNDEFINE:
   235    224               if (objc != 3) {
   236    225                   Tcl_WrongNumArgs(interp, 2, objv, "symbol");
   237    226                   return TCL_ERROR;
   238    227               }
   239    228               tcc_undefine_symbol(s,Tcl_GetString(objv[2]));
   240    229               return TCL_OK;
   241         -	case TCC4TCL_ADD_RUNTIME_SYM:
   242         -		if (objc != 3) {
   243         -			Tcl_WrongNumArgs(interp, 2, objv, "symbol_name");
   244         -			return(TCL_ERROR);
   245         -		}
   246         -
   247         -		str = Tcl_GetString(objv[2]);
   248         -#ifdef HAVE_DLSYM
   249         -		val_p = dlsym(NULL, str);
   250         -#elif defined(HAVE_ENUMPROCESSMODULES)
   251         -		val_p = NULL;
   252         -		{
   253         -			HANDLE cur_proc;
   254         -			HMODULE *modules;
   255         -			DWORD needed, i;
   256         -
   257         -			needed = 0;
   258         -
   259         -			cur_proc = GetCurrentProcess();
   260         -			EnumProcessModules(cur_proc, NULL, 0, &needed);
   261         -
   262         -			if (needed > 0) {
   263         -				modules = (void *) ckalloc(needed);
   264         -				if (EnumProcessModules(cur_proc, modules, needed, &needed)) {
   265         -					for (i = 0; i < (needed / sizeof(HMODULE)); i++) {
   266         -						val_p = (void *) GetProcAddress(modules[i], str);
   267         -
   268         -						if (val_p) {
   269         -							break;
   270         -						}
   271         -					}
   272         -				}
   273         -
   274         -				ckfree((void *) modules);
   275         -			}
   276         -		}
   277         -#else
   278         -		val_p = NULL;
   279         -#endif
   280         -
   281         -		if (val_p == NULL) {
   282         -			Tcl_AppendResult(interp, "symbol not found", NULL);
   283         -
   284         -			return(TCL_ERROR);
   285         -		}
   286         -
   287         -		tcc_add_symbol(s, Tcl_GetString(objv[2]), val_p); 
   288         -
   289         -		return(TCL_OK);
   290    230           default:
   291    231               Tcl_Panic("internal error during option lookup");
   292    232       }
   293    233       return TCL_OK;
   294    234   } 
   295    235   
   296    236   static int Tcc4tclCreateCmd( ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj * CONST objv[]){

Modified tcc4tcl.tcl from [47dd5cbf47] to [7f2fbfc8a7].

   352    352   	append code $body
   353    353   	append code "\nreturn TCL_OK;\n\}"
   354    354   
   355    355   	return $code
   356    356   }
   357    357   
   358    358   #---------------------------------------------------------------------
   359         -proc ::tcc4tcl::cproc {name adefs rtype {body "#"} {addfuncs ""}} {
          359  +proc ::tcc4tcl::cproc {name adefs rtype {body "#"}} {
   360    360   	foreach {code cbody} [wrap $name $adefs $rtype $body] break
   361    361   
   362    362   	::tcc4tcl::ccode $code
   363    363   
   364         -	uplevel 1 [list ::tcc4tcl::ccommand $name {dummy ip objc objv} $cbody $addfuncs]
          364  +	uplevel 1 [list ::tcc4tcl::ccommand $name {dummy ip objc objv} $cbody]
   365    365   }
   366    366   
   367    367   #---------------------------------------------------------------------
   368    368   proc ::tcc4tcl::cdata {name data} {
   369    369   	# Extract bytes from data
   370    370   	binary scan $data c* bytes
   371    371   
................................................................................
   405    405   
   406    406   	uplevel 1 [list tcc4tcl::ccommand $name {dummy ip objc objv} $cbody]
   407    407   
   408    408   	return $name
   409    409   }
   410    410   
   411    411   #-------------------------------------------------------------------
   412         -proc ::tcc4tcl::ccommand {procname anames body {addfuncs ""}} {
          412  +proc ::tcc4tcl::ccommand {procname anames body} {
   413    413   	variable tcc
   414    414   
   415    415   	# Fully qualified proc name
   416    416   	if {[string match "::*" $procname]} {
   417    417   		# procname is already absolute
   418    418   	} else {
   419    419   		set nsfrom [uplevel 1 {namespace current}]    
................................................................................
   461    461   	set tcc(code) ""
   462    462   
   463    463   	append code "int $cname (ClientData $v(clientdata),Tcl_Interp *$v(interp),"
   464    464   	append code "int $v(objc),Tcl_Obj *CONST $v(objv)\[\]) {" "\n"
   465    465   	append code $body "\n"
   466    466   	append code "}" "\n"
   467    467   
   468         -	if {[llength $addfuncs] > 0} {
   469         -		set tcc(cc) [tcc4tcl::new]
   470         -
   471         -		foreach addfunc $addfuncs {
   472         -			$tcc(cc) add_runtime_sym $addfunc
   473         -		}
   474         -	}
   475         -
   476    468   	if {[catch {
   477    469   		uplevel 1 [list tcc4tcl::cc $code]
   478    470   	} err]} {
   479    471   		unset tcc(cc)
   480    472   		tcc4tcl::reset
   481    473   
   482    474   		return -code error $err

Modified test from [e2e01fc434] to [7d8a169a15].

    24     24   
    25     25   	rv = mkdir(dir);
    26     26   	if (rv == 0) {
    27     27   		return(TCL_OK);
    28     28   	};
    29     29   
    30     30   	return(TCL_ERROR);
    31         -} [list mkdir]
           31  +}
    32     32   
    33     33   
    34     34   puts [test 1]
    35     35   puts [test1 1]
    36     36   puts [test3 1]
    37     37   puts [::bob::test1 1]
    38     38   puts [add [test 1] 1]