From b8f4e987b7d58fdd5df04c4d9694a445a96ae716 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Thu, 29 Jan 2026 00:55:02 +0100 Subject: [PATCH] move clobber definition into base lib.c --- examples/arch/bochs.mk | 13 ++++++------- examples/arch/bochs/lib.c | 4 ---- examples/lib.c | 4 ++++ 3 files changed, 10 insertions(+), 11 deletions(-) delete mode 100644 examples/arch/bochs/lib.c diff --git a/examples/arch/bochs.mk b/examples/arch/bochs.mk index bff5be5..34c837a 100644 --- a/examples/arch/bochs.mk +++ b/examples/arch/bochs.mk @@ -4,8 +4,7 @@ WASI_CC := ${WASI_ROOT}/bin/clang WASI_CFLAGS := --target=wasm32 \ --sysroot=${WASI_ROOT}/share/wasi-sysroot \ -z stack-size=4096 \ - -nostdlib \ - -O0 -g -Wall \ + -O2 -nostdlib \ -Wl,--no-entry \ -Wl,--initial-memory=65536 \ -Wl,--export-all \ @@ -16,7 +15,8 @@ WASI_CFLAGS := --target=wasm32 \ WAMR := /opt/wamr IWASM_LIB := /opt/wamr-libiwasm CC := gcc -CFLAGS := -I. -include arch/${ARCH}/lib.c -O0 -g -m32 -fomit-frame-pointer +# NOTE: Without -fomit-frame-pointer I get "error: bp cannot be used in ‘asm’ here" +CFLAGS := -I. -O2 -m32 -ffunction-sections -fomit-frame-pointer LDFLAGS := -Wl,-T linker.ld $^ -Wl,--build-id=none -static -nostdlib -m32 \ -Wl,-rpath,${IWASM_LIB} -L${IWASM_LIB} -liwasm INCL := -I${WAMR}/core/iwasm/include \ @@ -29,7 +29,6 @@ INCL := -I${WAMR}/core/iwasm/include \ WAMRC := /opt/wamr-wamrc/wamrc WAMRCFLAGS := --target=i386 --format=object XXD := busybox xxd -WASM2C := wasm2c ################################################################ @@ -45,7 +44,7 @@ ${BUILD_DIR}/%/module.wasm: %.c # ${WAMRC} ${WAMRCFLAGS} -o ${BUILD_DIR}/$*/system.o ${BUILD_DIR}/$*/module.wasm # # ${BUILD_DIR}/startup.o: arch/bochs/startup.s -# ${CC} $< ${CFLAGS} -c -ffunction-sections -o $@ +# ${CC} $< ${CFLAGS} -c -o $@ # # ${BUILD_DIR}/%/system.elf: ${BUILD_DIR}/%/system.o ${BUILD_DIR}/startup.o # ${CC} ${LDFLAGS} -o $@ @@ -66,10 +65,10 @@ ${BUILD_DIR}/%/system.o: ${BUILD_DIR}/%/module_wasm.c -e "s/__WASM_ARRAY__/build_bochs_$*_module_aot/g" \ -e "s/__WASM_ARRAY_LEN__/build_bochs_$*_module_aot_len/g" \ ${BUILD_DIR}/$*/module_host.c - ${CC} ${CFLAGS} ${INCL} -c -ffunction-sections ${BUILD_DIR}/$*/module_host.c -o $@ + ${CC} ${CFLAGS} ${INCL} -c ${BUILD_DIR}/$*/module_host.c -o $@ ${BUILD_DIR}/startup.o: arch/bochs/startup.s - ${CC} $< ${CFLAGS} -c -ffunction-sections -o $@ + ${CC} $< ${CFLAGS} -c -o $@ ${BUILD_DIR}/%/system.elf: ${BUILD_DIR}/%/system.o ${BUILD_DIR}/startup.o ${CC} ${LDFLAGS} -o $@ diff --git a/examples/arch/bochs/lib.c b/examples/arch/bochs/lib.c deleted file mode 100644 index 2eab5ee..0000000 --- a/examples/arch/bochs/lib.c +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#define ARCH_ASM_CLOBBER_ALL "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp" - diff --git a/examples/lib.c b/examples/lib.c index a6ce812..daabf67 100644 --- a/examples/lib.c +++ b/examples/lib.c @@ -6,6 +6,10 @@ #define __QUOTE(x) #x #define QUOTE(x) __QUOTE(x) +#ifndef ARCH_ASM_CLOBBER_ALL +#define ARCH_ASM_CLOBBER_ALL "eax", "ebx", "ecx", "edx", "esi", "edi", "ebp" +#endif + #ifndef MARKER #define MARKER(str) \ __asm__ volatile(QUOTE(str) ":" \