| diff --git a/Makefile.in b/Makefile.in |
| --- a/Makefile.in |
| +++ b/Makefile.in |
| @@ -262,7 +262,10 @@ LIBCC_SRC = cstr.fs unix/socket.fs |
| |
| LIBCC_DIST_SRC = libffi.fs fflib.fs $(LIBCC_SRC) |
| |
| -LIBCC_BUILD_SRC = @LIBCC_BUILD_SRC@ $(LIBCC_SRC) |
| +# Disable socket, cstr, fflib and libffi bindings as they have trouble |
| +# building. |
| +#LIBCC_BUILD_SRC = @LIBCC_BUILD_SRC@ $(LIBCC_SRC) |
| +LIBCC_BUILD_SRC = |
| |
| FORTH_SRC = $(KERN_SRC) $(GFORTH_FI_SRC) $(EC_SRC) $(LIBCC_DIST_SRC) \ |
| ans-report.fs ansi.fs answords.fs \ |
| @@ -788,14 +791,14 @@ $(FORTH_GEN_ENGINE): prim.b prims2x.fs |
| engine/prim-s.i: engine/prim.i |
| grep -v '^#line ' $(srcdir)/engine/prim.i >$@ |
| |
| -kernel/aliases.fs: prim.b prims2x.fs kernel/aliases0.fs |
| - $(CP) kernel/aliases0.fs $@- |
| +kernel/aliases.fs: prim.b prims2x.fs $(srcdir)/kernel/aliases0.fs |
| + $(CP) $(srcdir)/kernel/aliases0.fs $@- |
| $(PREFORTH) prims2x.fs -e "forth-flag on s\" prim.b\" ' output-alias ' noop process-file bye" >>$@- |
| $(CP) $@- $@ |
| $(RM) $@- |
| |
| -kernel/prim.fs: prim.b prims2x.fs kernel/prim0.fs |
| - $(CP) kernel/prim0.fs kernel/prim.fs- |
| +kernel/prim.fs: prim.b prims2x.fs $(srcdir)/kernel/prim0.fs |
| + $(CP) $(srcdir)/kernel/prim0.fs kernel/prim.fs- |
| $(PREFORTH) prims2x.fs -e "forth-flag on s\" prim.b\" ' output-forth ' output-forth-combined process-file bye" >>$@- |
| $(CP) $@- $@ |
| $(RM) $@- |
| @@ -1001,18 +1004,22 @@ stamp-h: engine/config.h.in config.status stamp-h.in |
| Makefile Makedist engine/Makefile gforthmi vmgen preforth machpc.fs doc/version.texi envos.fs build-ec: Makefile.in Makedist.in engine/Makefile.in gforthmi.in vmgen.in preforth.in machpc.fs.in doc/version.texi.in config.status configure.in envos.fs.in build-ec.in engine/libcc.h.in |
| ./config.status |
| |
| -config.status: configure |
| +config.status: $(srcdir)/configure |
| ./config.status --recheck |
| |
| +# NOTE: Redone to work correctly with VPATH. |
| #create files for DOS, because DOS cannot do it itself |
| -makefile.dos engine/makefile.dos: mkdosmf.sed Makefile.in engine/Makefile.in |
| - sed -f mkdosmf.sed <Makefile.in >makefile.dos |
| - sed -f mkdosmf.sed <engine/Makefile.in >engine/makefile.dos |
| - |
| -makefile.os2 engine/makefile.os2: mkos2mf.sed Makefile.in engine/Makefile.in |
| - sed -f mkos2mf.sed <Makefile.in >makefile.os2 |
| - sed -f mkos2mf.sed <engine/Makefile.in >engine/makefile.os2 |
| - echo '%.o: %.c' >>makefile.os2 |
| - echo ' $$(GCC) $$(CFLAGS) $$(CPPFLAGS) -c $$<' >>makefile.os2 |
| - echo '%.o: %.c' >>engine/makefile.os2 |
| - echo ' $$(GCC) $$(CFLAGS) $$(CPPFLAGS) -c $$<' >>engine/makefile.os2 |
| +makefile.dos: mkdosmf.sed Makefile.in |
| + sed -f $< <$(word 2,$^) >$@ |
| +engine/makefile.dos: mkdosmf.sed engine/Makefile.in |
| + sed -f $< <$(word 2,$^) >$@ |
| + |
| +makefile.os2: mkos2mf.sed Makefile.in |
| + sed -f $< <$(word 2,$^) >$@ |
| + echo '%.o: %.c' >>$@ |
| + echo ' $$(GCC) $$(CFLAGS) $$(CPPFLAGS) -c $$<' >>$@ |
| + |
| +engine/makefile.os2: mkos2mf.sed engine/Makefile.in |
| + sed -f $< <$(word 2,$^) >$@ |
| + echo '%.o: %.c' >>$@ |
| + echo ' $$(GCC) $$(CFLAGS) $$(CPPFLAGS) -c $$<' >>$@ |
| diff --git a/arch/386/machine.h b/arch/386/machine.h |
| --- a/arch/386/machine.h |
| +++ b/arch/386/machine.h |
| @@ -39,11 +39,13 @@ |
| #endif |
| #endif |
| |
| +#if !defined(__native_client__) |
| #define ASM_SM_SLASH_REM(d1lo, d1hi, n1, n2, n3) \ |
| asm("idivl %4": "=a"(n3),"=d"(n2) : "a"(d1lo),"d"(d1hi),"g"(n1):"cc"); |
| |
| #define ASM_UM_SLASH_MOD(d1lo, d1hi, n1, n2, n3) \ |
| asm("divl %4": "=a"(n3),"=d"(n2) : "a"(d1lo),"d"(d1hi),"g"(n1):"cc"); |
| +#endif |
| |
| #include "../generic/machine.h" |
| |
| diff --git a/arch/amd64/machine.h b/arch/amd64/machine.h |
| --- a/arch/amd64/machine.h |
| +++ b/arch/amd64/machine.h |
| @@ -42,11 +42,13 @@ |
| |
| #endif |
| |
| +#if !defined(__native_client__) |
| #define ASM_SM_SLASH_REM(d1lo, d1hi, n1, n2, n3) \ |
| asm("idivq %4": "=a"(n3),"=d"(n2) : "a"(d1lo),"d"(d1hi),"g"(n1):"cc"); |
| |
| #define ASM_UM_SLASH_MOD(d1lo, d1hi, n1, n2, n3) \ |
| asm("divq %4": "=a"(n3),"=d"(n2) : "a"(d1lo),"d"(d1hi),"g"(n1):"cc"); |
| +#endif |
| |
| #include "../generic/machine.h" |
| |
| diff --git a/configure.in b/configure.in |
| --- a/configure.in |
| +++ b/configure.in |
| @@ -241,15 +241,15 @@ case "$host_cpu" in |
| ;; |
| i386) |
| machine=386 |
| - CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr" |
| + CFLAGS="$CFLAGS -fomit-frame-pointer" |
| ;; |
| i486) |
| machine=386 |
| - CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr" |
| + CFLAGS="$CFLAGS -fomit-frame-pointer" |
| ;; |
| i*86) |
| machine=386 |
| - CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr" |
| + CFLAGS="$CFLAGS -fomit-frame-pointer" |
| CFLAGS_1="$CFLAGS" |
| CFLAGS="$CFLAGS -march=pentium" |
| AC_TRY_COMPILE(,,,CFLAGS="$CFLAGS_1 -m486") |
| @@ -259,7 +259,7 @@ case "$host_cpu" in |
| in |
| *-m32*) |
| machine=386 |
| - CFLAGS="$CFLAGS -fomit-frame-pointer -fforce-addr" |
| + CFLAGS="$CFLAGS -fomit-frame-pointer" |
| CFLAGS_1="$CFLAGS" |
| CFLAGS="$CFLAGS -march=athlon64" |
| ;; |
| @@ -637,7 +637,9 @@ AC_MSG_RESULT($M4) |
| AC_MSG_CHECKING([for gforth]) |
| GFORTH="`cd / && which gforth 2>/dev/null`" |
| #the "$srcdir" = "." test defends agains the "../" bug in gforth-0.6.2 |
| -(cd / && $GFORTH -e bye >/dev/null 2>/dev/null && test "$srcdir" = ".") || GFORTH="" |
| +# NOTE: Disabling this, as it prevents sharing $srcdir with the host build and |
| +# is not a problem in this version. |
| +#(cd / && $GFORTH -e bye >/dev/null 2>/dev/null && test "$srcdir" = ".") || GFORTH="" |
| if test -z "$GFORTH"; then |
| PREFORTH='echo "You need to configure with a gforth in \$PATH to build this part" && false' |
| kernel_anti_dependence='' |
| @@ -651,12 +653,22 @@ AC_MSG_RESULT($PREFORTH) |
| |
| #echo "machine='$machine'" |
| |
| -dnl AC_CHECK_PROG(asm_fs,asm.fs,arch/$machine/asm.fs,,$srcdir/arch/$machine) |
| -AC_CHECK_FILE($srcdir/arch/$machine/asm.fs,[asm_fs=arch/$machine/asm.fs],) |
| +# NOTE: Switched to unconditional test, as these files are relevant even for a |
| +# cross compiled build. |
| +if test -e "$srcdir/arch/$machine/asm.fs"; then |
| + asm_fs="arch/$machine/asm.fs" |
| +else |
| + asm_fs='' |
| +fi |
| AC_SUBST(asm_fs) |
| |
| -dnl AC_CHECK_PROG(disasm_fs,disasm.fs,arch/$machine/disasm.fs,,$srcdir/arch/$machine) |
| -AC_CHECK_FILE($srcdir/arch/$machine/disasm.fs,[disasm_fs=arch/$machine/disasm.fs],) |
| +# NOTE: Switched to unconditional test, as these files are relevant even for a |
| +# cross compiled build. |
| +if test -e "$srcdir/arch/$machine/disasm.fs"; then |
| + disasm_fs="arch/$machine/disasm.fs" |
| +else |
| + disasm_fs='' |
| +fi |
| AC_SUBST(disasm_fs) |
| |
| AC_PATH_PROG(INSTALL_INFO,install-info,[echo '>>>>Please make info dir entry:'],$PATH:/sbin:/usr/sbin:/usr/local/sbin) |
| diff --git a/engine/Makefile.in b/engine/Makefile.in |
| --- a/engine/Makefile.in |
| +++ b/engine/Makefile.in |
| @@ -89,7 +89,8 @@ XCFLAGS = @CFLAGS@ |
| XDEFINES = @DEFS@ |
| SWITCHES = $(XCFLAGS) $(XDEFINES) $(OPTDEFINES) |
| #use -fno-inline to avoid register problems with asinh, atanh on gcc-3.3 on 386 |
| -ENGINE_FLAGS = @ENGINE_FLAGS@ -fno-defer-pop -fcaller-saves -fno-inline -fno-reorder-blocks |
| +#ENGINE_FLAGS = @ENGINE_FLAGS@ -fno-defer-pop -fcaller-saves -fno-inline -fno-reorder-blocks |
| +ENGINE_FLAGS = @ENGINE_FLAGS@ -fno-inline |
| DEBUGFLAG = @DEBUGFLAG@ |
| CFLAGS = $(DEBUGFLAG) -I$(srcdir)/../arch/$(machine) -I. -Wall $(SWITCHES) -DDEFAULTPATH='"$(FORTHPATH)"' $(LTDLINCL) |
| CFLAGS2 = $(DEBUGFLAG) -I$(srcdir)/../arch/$(machine) -I. -Wall $(SWITCHES) -DDEFAULTPATH='"$(FORTHPATH)"' $(LTDLINCL) |
| diff --git a/engine/engine.c b/engine/engine.c |
| --- a/engine/engine.c |
| +++ b/engine/engine.c |
| @@ -221,6 +221,14 @@ extern int gforth_memcmp(const char * s1, const char * s2, size_t n); |
| #endif |
| #define SUPER_CONTINUE |
| |
| +/* |
| + * Redefined asm to nothing as even empty asm("") blocks won't build with |
| + * pnacl. |
| + */ |
| +#if defined(__pnacl__) |
| +#define asm(x) |
| +#endif |
| + |
| #ifdef ASMCOMMENT |
| /* an individualized asm statement so that (hopefully) gcc's optimizer |
| does not do cross-jumping */ |
| diff --git a/engine/io.c b/engine/io.c |
| --- a/engine/io.c |
| +++ b/engine/io.c |
| @@ -79,7 +79,7 @@ typedef unsigned int uint32_t; |
| |
| /* System V machines use termio. */ |
| #if !defined (_POSIX_VERSION) |
| -# if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (ultrix) || defined (Solaris) || defined(_WIN32) |
| +# if defined (USG) || defined (hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (ultrix) || defined (Solaris) || defined(_WIN32) || (defined(__native_client__) && defined(_NEWLIB_VERSION)) |
| # undef NEW_TTY_DRIVER |
| # define TERMIO_TTY_DRIVER |
| # include <termio.h> |
| diff --git a/engine/longlong.h b/engine/longlong.h |
| --- a/engine/longlong.h |
| +++ b/engine/longlong.h |
| @@ -335,8 +335,8 @@ UDItype __umulsidi3 (USItype, USItype); |
| "rm" ((USItype) (v))) |
| #define udiv_qrnnd(q, r, n1, n0, dv) \ |
| __asm__ ("divl %4" \ |
| - : "=a" ((USItype) (q)), \ |
| - "=d" ((USItype) (r)) \ |
| + : "=a" (q), \ |
| + "=d" (r) \ |
| : "0" ((USItype) (n0)), \ |
| "1" ((USItype) (n1)), \ |
| "rm" ((USItype) (dv))) |
| diff --git a/engine/main.c b/engine/main.c |
| --- a/engine/main.c |
| +++ b/engine/main.c |
| @@ -49,6 +49,10 @@ |
| /* #include <systypes.h> */ |
| #endif |
| |
| +#if defined(__native_client__) |
| +# include "nacl_main.h" |
| +#endif |
| + |
| /* output rules etc. for burg with --debug and --print-sequences */ |
| /* #define BURG_FORMAT*/ |
| |
| @@ -2263,7 +2267,11 @@ void data_abort_C(void) |
| } |
| #endif |
| |
| +#if defined(__native_client__) |
| +int main(int argc, char **argv) |
| +#else |
| int main(int argc, char **argv, char **env) |
| +#endif |
| { |
| #ifdef HAS_OS |
| char *path = getenv("GFORTHPATH") ? : DEFAULTPATH; |
| @@ -2276,6 +2284,10 @@ int main(int argc, char **argv, char **env) |
| Address image; |
| #endif |
| int retvalue; |
| + |
| +#if defined(__native_client__) |
| + nacl_startup_untar(argv[0], "gforth.tar", "/"); |
| +#endif |
| |
| code_here = ((void *)0)+CODE_BLOCK_SIZE; /* llvm-gcc does not like this as |
| initializer, so we do it here */ |