include + update old linux targets/host.c
This commit is contained in:
@ -16,17 +16,25 @@ WASI_CFLAGS := \
|
||||
|
||||
# WASM -> Baremetal
|
||||
WAMR := /opt/wamr
|
||||
IWASM_LIB := /opt/wamr-libiwasm
|
||||
CC := /opt/crosscompiler/bin/i686-elf-gcc
|
||||
# NOTE: When compiling I get "error: bp cannot be used in ‘asm’ here"
|
||||
# I could remove "ebp" from the clobber list (ARCH_ASM_CLOBBER_ALL) or
|
||||
|
||||
WAMRC := /opt/wamr-wamrc/wamrc
|
||||
WAMRCFLAGS := \
|
||||
--target=i386 \
|
||||
--cpu=generic
|
||||
XXD := busybox xxd
|
||||
|
||||
# NOTE: make build-sum: "error: bp cannot be used in ‘asm’ here"
|
||||
# could remove "ebp" from the clobber list (ARCH_ASM_CLOBBER_ALL) or
|
||||
# use the -fomit-frame-pointer flag to tell gcc it shouldn't rely on ebp for enter/leave...
|
||||
CC := /opt/crosscompiler/bin/i686-elf-gcc
|
||||
CFLAGS := \
|
||||
-I. \
|
||||
-O0 \
|
||||
-m32 \
|
||||
-ffunction-sections \
|
||||
-fomit-frame-pointer
|
||||
-fomit-frame-pointer \
|
||||
-ggdb
|
||||
IWASM_LIB := /opt/wamr-libiwasm # Baremetal
|
||||
LDFLAGS = \
|
||||
-Wl,-T linker.ld \
|
||||
$^ \
|
||||
@ -44,8 +52,26 @@ INCL := \
|
||||
-I${WAMR}/core/shared/utils \
|
||||
-I${WAMR}/core/shared/platform/baremetal \
|
||||
-I/opt/crosscompiler/i686-elf/include
|
||||
WAMRC := /opt/wamr-wamrc/wamrc
|
||||
XXD := busybox xxd
|
||||
|
||||
CC_LINUX := gcc
|
||||
CFLAGS_LINUX := \
|
||||
-I. \
|
||||
-O0 \
|
||||
-m32 \
|
||||
-ffunction-sections \
|
||||
-ggdb
|
||||
IWASM_LIB_LINUX := /opt/wamr-libiwasm-linux
|
||||
LDFLAGS_LINUX = \
|
||||
$^ \
|
||||
-m32 \
|
||||
-Wl,-rpath,${IWASM_LIB_LINUX} \
|
||||
-L${IWASM_LIB_LINUX} \
|
||||
-liwasm \
|
||||
-lm
|
||||
INCL_LINUX := \
|
||||
-I${WAMR}/core/iwasm/include \
|
||||
-I${WAMR}/core/shared/utils \
|
||||
-I${WAMR}/core/shared/platform/linux
|
||||
|
||||
################################################################
|
||||
# C -> WASM
|
||||
@ -65,9 +91,9 @@ ${BUILD_DIR}/%/module.wasm: %.c
|
||||
# ${CC} ${LDFLAGS} -o $@
|
||||
|
||||
################################################################
|
||||
# WASM -> AOT -> Loaded by Runtime
|
||||
# WASM -> AOT -> Loaded by Runtime (FAIL)
|
||||
${BUILD_DIR}/%/module.aot: ${BUILD_DIR}/%/module.wasm
|
||||
${WAMRC} -o $@ $<
|
||||
${WAMRC} ${WAMRCFLAGS} -o $@ $<
|
||||
|
||||
${BUILD_DIR}/%/module_wasm.c: ${BUILD_DIR}/%/module.aot
|
||||
${XXD} -i $< > $@
|
||||
@ -90,6 +116,20 @@ ${BUILD_DIR}/syscalls.o: syscalls.c
|
||||
${BUILD_DIR}/%/system.elf: ${BUILD_DIR}/%/system.o ${BUILD_DIR}/syscalls.o ${BUILD_DIR}/startup.o
|
||||
${CC} ${LDFLAGS} -o $@
|
||||
|
||||
################################################################
|
||||
# WASM -> AOT -> Loaded by Runtime (Host/Linux)
|
||||
${BUILD_DIR}/%/system-linux.o: ${BUILD_DIR}/%/module_wasm.c
|
||||
cp embed/host-linux.c ${BUILD_DIR}/$*/module_host-linux.c
|
||||
sed -i \
|
||||
-e "s/__WASM_ARRAY_FILE__/module_wasm.c/g" \
|
||||
-e "s/__WASM_ARRAY__/build_bochs_$*_module_aot/g" \
|
||||
-e "s/__WASM_ARRAY_LEN__/build_bochs_$*_module_aot_len/g" \
|
||||
${BUILD_DIR}/$*/module_host-linux.c
|
||||
${CC_LINUX} ${CFLAGS_LINUX} ${INCL_LINUX} -c ${BUILD_DIR}/$*/module_host-linux.c -o $@
|
||||
|
||||
${BUILD_DIR}/%/system-linux.elf: ${BUILD_DIR}/%/system-linux.o
|
||||
${CC_LINUX} ${LDFLAGS_LINUX} -o $@
|
||||
|
||||
################################################################
|
||||
# Bochs
|
||||
${BUILD_DIR}/%/system.iso: ${BUILD_DIR}/%/system.elf
|
||||
@ -167,6 +207,17 @@ build-$1: ${BUILD_DIR}/$1/system.iso
|
||||
trace-$1: ${BUILD_DIR}/$1/trace.pb
|
||||
|
||||
objdump-$1:
|
||||
objdump --disassemble --disassembler-options intel --disassembler-color=on --source ${BUILD_DIR}/$1/system.elf
|
||||
objdump --disassemble --disassembler-options intel --disassembler-color=off --source ${BUILD_DIR}/$1/system.elf | less
|
||||
|
||||
linux-build-$1: ${BUILD_DIR}/$1/system-linux.elf
|
||||
|
||||
linux-run-$1: ${BUILD_DIR}/$1/system-linux.elf
|
||||
${BUILD_DIR}/$1/system-linux.elf
|
||||
|
||||
linux-gdb-$1: ${BUILD_DIR}/$1/system-linux.elf
|
||||
gdb --tui ${BUILD_DIR}/$1/system-linux.elf
|
||||
|
||||
bochs-run-$1: ${BUILD_DIR}/$1/system.iso
|
||||
bochs -q -f arch/bochs/bochsrc-docker.txt
|
||||
|
||||
endef
|
||||
|
||||
Reference in New Issue
Block a user