Reduced Windows build further, dropping msvcrt.

Added both 32 and 64 bit flavors to deploy.
This commit is contained in:
Brad Nelson
2021-01-10 01:13:04 -08:00
parent 55bc26564c
commit 7e3e5e2a74
5 changed files with 78 additions and 39 deletions

View File

@ -7,17 +7,22 @@ WINDOWS = $(OUT)/windows
ARDUINO = $(OUT)/arduino
DEPLOY = $(OUT)/deploy
CFLAGS = -Wall -Werror \
-O2 \
-fno-exceptions \
-s \
-fomit-frame-pointer \
-fno-stack-protector \
-fno-ident -Wl,--build-id=none \
-ffunction-sections -fdata-sections \
-Wl,--gc-sections \
-fmerge-all-constants \
-I ./ -I $(OUT)
CFLAGS_COMMON = -Wall -Werror \
-O2 \
-s \
-ffreestanding \
-fno-exceptions \
-fno-stack-check \
-fno-stack-protector \
-fno-stack-protector \
-fomit-frame-pointer \
-mno-stack-arg-probe \
-fno-ident -Wl,--build-id=none \
-ffunction-sections -fdata-sections \
-fmerge-all-constants \
-I ./ -I $(OUT)
CFLAGS = $(CFLAGS_COMMON) \
-Wl,--gc-sections
STRIP_ARGS = -S \
--strip-unneeded \
--remove-section=.note.gnu.gold-version \
@ -27,9 +32,9 @@ STRIP_ARGS = -S \
--remove-section=.note.ABI-tag
LIBS=-ldl
WINFLAGS = -ffreestanding -fno-stack-check \
-fno-stack-protector -mno-stack-arg-probe \
-mwindows -lkernel32
WIN_CFLAGS = $(CFLAGS_COMMON) -mwindows -nostdlib \
WIN_LIBS = -lkernel32
# Default to 32-bit Windows for maximum portability.
ifeq ($(WIN_ARCH),)
@ -43,14 +48,23 @@ TARGETS = $(WEB)/terminal.html \
$(ARDUINO)/ueforth/ueforth.ino
# Selectively enable windows if tools available
ifneq (, $(shell which $(WIN_ARCH)-w64-mingw32-windres))
ifneq (, $(shell which $(WIN_ARCH)-w64-mingw32-gcc))
TARGETS += $(WINDOWS)/uEforth.exe
ifneq (, $(shell which i686-w64-mingw32-windres))
ifneq (, $(shell which i686-w64-mingw32-gcc))
TARGETS += $(WINDOWS)/uEforth32.exe
else
$(warning "Missing $(WIN_ARCH)-w64-mingw32-gcc skipping Windows.")
$(warning "Missing i686-w64-mingw32-gcc skipping 32-bit Windows.")
endif
else
$(warning "Missing $(WIN_ARCH)-w64-mingw32-windres skipping Windows.")
$(warning "Missing i686-w64-mingw32-windres skipping 32-bit Windows.")
endif
ifneq (, $(shell which x86_64-w64-mingw32-windres))
ifneq (, $(shell which x86_64-w64-mingw32-gcc))
TARGETS += $(WINDOWS)/uEforth64.exe
else
$(warning "Missing i686-w64-mingw32-gcc skipping 64-bit Windows.")
endif
else
$(warning "Missing i686-w64-mingw32-windres skipping 64-bit Windows.")
endif
all: $(TARGETS) tests $(DEPLOY)/app.yaml
@ -124,10 +138,11 @@ ICON_SIZES = $(RES)/eforth256x256.png \
$(RES)/eforth.ico: $(ICON_SIZES)
convert $^ $< $@
WINDOWS_RESOURCES = $(RES)/ueforth_res.o
$(RES)/ueforth_res32.o: windows/ueforth.rc $(RES)/eforth.ico
i686-w64-mingw32-windres $< $@
$(WINDOWS_RESOURCES): windows/ueforth.rc $(RES)/eforth.ico
$(WIN_ARCH)-w64-mingw32-windres $< $@
$(RES)/ueforth_res64.o: windows/ueforth.rc $(RES)/eforth.ico
x86_64-w64-mingw32-windres $< $@
# ---- WEB ----
@ -163,14 +178,23 @@ $(POSIX)/ueforth: \
$(WINDOWS):
mkdir -p $@
$(WINDOWS)/uEforth.exe: \
$(WINDOWS)/uEforth32.exe: \
windows/windows_main.c \
common/opcodes.h \
common/core.h \
$(GEN)/windows_boot.h \
$(WINDOWS_RESOURCES) | $(WINDOWS)
$(WIN_ARCH)-w64-mingw32-gcc \
$(CFLAGS) $(WINFLAGS) $< $(WINDOWS_RESOURCES) -o $@
$(RES)/ueforth_res32.o | $(WINDOWS)
i686-w64-mingw32-gcc \
$(WIN_CFLAGS) $< $(RES)/ueforth_res32.o -o $@ $(WIN_LIBS)
$(WINDOWS)/uEforth64.exe: \
windows/windows_main.c \
common/opcodes.h \
common/core.h \
$(GEN)/windows_boot.h \
$(RES)/ueforth_res64.o | $(WINDOWS)
x86_64-w64-mingw32-gcc \
$(WIN_CFLAGS) $< $(RES)/ueforth_res64.o -o $@ $(WIN_LIBS)
# ---- ARDUINO ----
@ -203,7 +227,8 @@ $(DEPLOY)/app.yaml: $(ARDUINO)/ueforth-arduino-esp32.zip \
mkdir -p $(DEPLOY)/static
cp -r $(ARDUINO)/ueforth-arduino-esp32.zip $(DEPLOY)/static
cp -r $(POSIX)/ueforth $(DEPLOY)/static/ueforth.linux
cp -r $(WINDOWS)/uEforth.exe $(DEPLOY)/static/uEforth.exe
cp -r $(WINDOWS)/uEforth32.exe $(DEPLOY)/static/uEforth32.exe
cp -r $(WINDOWS)/uEforth64.exe $(DEPLOY)/static/uEforth64.exe
cp -r $(RES)/eforth.ico $(DEPLOY)/static/favicon.ico
cp -r site/* $(DEPLOY)
cp -r site/.gcloudignore $(DEPLOY)

View File

@ -19,20 +19,22 @@ typedef uint64_t udcell_t;
#define COMMA(n) *g_sys.heap++ = (n)
#define IMMEDIATE() g_sys.last[-1] |= 1
#define DOES(ip) *g_sys.last = (cell_t) && OP_DODOES; g_sys.last[1] = (cell_t) ip
#define UMSMOD udcell_t ud = *(udcell_t *) &sp[-1]; \
--sp; *sp = (cell_t) (ud % tos); \
tos = (cell_t) (ud / tos)
#define SSMOD dcell_t d = (dcell_t) *sp * (dcell_t) sp[-1]; \
--sp; *sp = (cell_t) (((udcell_t) d) % tos); \
tos = (cell_t) (d < 0 ? ~(~d / tos) : d / tos)
#ifndef UMSMOD_FUNC
#define UMSMOD_FUNC udcell_t ud = *(udcell_t *) &sp[-1]; \
--sp; *sp = (cell_t) (ud % tos); \
tos = (cell_t) (ud / tos)
#define SSMOD_FUNC dcell_t d = (dcell_t) *sp * (dcell_t) sp[-1]; \
--sp; *sp = (cell_t) (((udcell_t) d) % tos); \
tos = (cell_t) (d < 0 ? ~(~d / tos) : d / tos)
#endif
#define PARK DUP; g_sys.ip = ip; g_sys.rp = rp; g_sys.sp = sp
#define OPCODE_LIST \
X("0=", ZEQUAL, tos = !tos ? -1 : 0) \
X("0<", ZLESS, tos = (tos|0) < 0 ? -1 : 0) \
X("+", PLUS, tos = (tos + *sp) | 0; --sp) \
X("UM/MOD", UMSMOD, UMSMOD) \
X("*/MOD", SSMOD, SSMOD) \
X("UM/MOD", UMSMOD, UMSMOD_FUNC) \
X("*/MOD", SSMOD, SSMOD_FUNC) \
X("AND", AND, tos = tos & *sp; --sp) \
X("OR", OR, tos = tos | *sp; --sp) \
X("XOR", XOR, tos = tos ^ *sp; --sp) \

View File

@ -17,10 +17,11 @@ In its original form metacompilation is avoided.
<p>
Version of uEforth - A reduced cross-platform EForth version (RECOMMENDED)
<ul>
<li><a href="static/uEforth.exe">uEforth.exe</a> - Window EXE uEforth</li>
<li><a href="static/ueforth.linux">ueforth.linux</a> - Linux Executable uEforth</li>
<li><a href="static/ueforth-arduino-esp32.zip">ueforth-arduino-esp32.zip</a>
- Arudino Source Code</li>
<li><a href="static/uEforth32.exe">uEforth32.exe</a> - Window 32-bit EXE uEforth</li>
<li><a href="static/uEforth64.exe">uEforth64.exe</a> - Window 64-bit EXE uEforth</li>
<li><a href="static/ueforth.linux">ueforth.linux</a> - Linux 64-bit Executable uEforth</li>
<li><a href="https://github.com/flagxor/eforth" target="_blank">http://github.com/flagxor/eforth</a>
- Complete Source Code (under ueforth)</li>
</ul>

View File

@ -31,4 +31,5 @@ int main(int argc, char *argv[]) {
fprintf(stderr, "USAGE: %s cases/dict\n", argv[1]);
return 1;
}
return 0;
}

View File

@ -2,6 +2,17 @@
#define CALLTYPE WINAPI
# define UMSMOD_FUNC \
asm("div %2" \
: "=a" (tos), "=d" (sp[-1]) \
: "r" (tos), "a" (sp[-1]), "d" (*sp)); --sp
# define SSMOD_FUNC \
w = tos; asm("imul %4\n\t" \
"idiv %2" \
: "=a" (tos), "=d" (sp[-1]) \
: "r" (w), "a" (sp[-1]), "d" (*sp)); --sp; if (*sp < 0) { *sp += w; --tos; }
#include "common/opcodes.h"
#include "common/calling.h"
@ -19,8 +30,7 @@
#include "gen/windows_boot.h"
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev,
PSTR pCmdLine, int nCmdShow) {
int WINAPI WinMainCRTStartup(void) {
void *heap = VirtualAlloc(
NULL, HEAP_SIZE, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE);
ueforth(0, 0, heap, boot, sizeof(boot));