Build libiwasm in debug/release configuration
This commit is contained in:
2
Makefile
2
Makefile
@ -1,5 +1,5 @@
|
||||
docker:
|
||||
docker build -t gitea.vps.chriphost.de/christoph/wasm-base:latest -f wasm-base.dockerfile . --build-arg CACHE_DATE="$(shell date)"
|
||||
docker build --progress=plain -t gitea.vps.chriphost.de/christoph/wasm-base:latest -f wasm-base.dockerfile . --build-arg CACHE_DATE="$(shell date)"
|
||||
|
||||
run:
|
||||
docker run --rm -it gitea.vps.chriphost.de/christoph/wasm-base:latest /usr/bin/fish
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
WASI_ROOT := /opt/wasi-sdk
|
||||
WAMR := /opt/wamr
|
||||
OPT := -O3
|
||||
|
||||
################################################################
|
||||
# C -> WASM
|
||||
@ -34,7 +35,7 @@ ${BUILD_DIR}/%/module.wasm: %.c
|
||||
# ${CC} ${LDFLAGS} -o $@
|
||||
|
||||
################################################################
|
||||
# WASM -> AOT -> Loaded by Runtime (FAIL)
|
||||
# WASM -> AOT
|
||||
|
||||
WAMRC := /opt/wamr-wamrc/wamrc
|
||||
WAMRCFLAGS := \
|
||||
@ -50,19 +51,23 @@ XXD := busybox xxd
|
||||
${BUILD_DIR}/%/module_wasm.c: ${BUILD_DIR}/%/module.aot
|
||||
${XXD} -i $< > $@
|
||||
|
||||
################################################################
|
||||
# WASM loaded by Runtime (FAIL+Baremetal platform)
|
||||
|
||||
# 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/i386-elf-gcc
|
||||
CFLAGS := \
|
||||
-I. \
|
||||
-O2 \
|
||||
${OPT} \
|
||||
-m32 \
|
||||
-ffunction-sections \
|
||||
-ffreestanding \
|
||||
-fomit-frame-pointer \
|
||||
-ggdb
|
||||
IWASM_LIB := /opt/wamr-libiwasm # Baremetal
|
||||
IWASM_LIB_DEBUG := /opt/wamr-libiwasm-baremetal-debug
|
||||
IWASM_LIB_RELEASE := /opt/wamr-libiwasm-baremetal-release
|
||||
LDFLAGS = \
|
||||
-Wl,-T linker.ld \
|
||||
$^ \
|
||||
@ -70,7 +75,7 @@ LDFLAGS = \
|
||||
-static \
|
||||
-nostdlib \
|
||||
-m32 \
|
||||
-L${IWASM_LIB} \
|
||||
-L${IWASM_LIB_RELEASE} \
|
||||
-liwasm \
|
||||
-lc \
|
||||
-lgcc \
|
||||
@ -99,23 +104,24 @@ ${BUILD_DIR}/%/system.elf: ${BUILD_DIR}/%/system.o ${BUILD_DIR}/syscalls.o ${BUI
|
||||
${CC} ${LDFLAGS} -o $@
|
||||
|
||||
################################################################
|
||||
# WASM -> AOT -> Loaded by Runtime (Host/Linux platform)
|
||||
# WASM loaded by Runtime (Host+Linux platform)
|
||||
|
||||
CC_LINUX := gcc
|
||||
CFLAGS_LINUX := \
|
||||
-I. \
|
||||
-O0 \
|
||||
${OPT} \
|
||||
-m32 \
|
||||
-ffunction-sections \
|
||||
-ggdb
|
||||
IWASM_LIB_LINUX := /opt/wamr-libiwasm-linux
|
||||
IWASM_LIB_LINUX_DEBUG := /opt/wamr-libiwasm-linux-debug
|
||||
IWASM_LIB_LINUX_RELEASE := /opt/wamr-libiwasm-linux-release
|
||||
LDFLAGS_LINUX = \
|
||||
$^ \
|
||||
-Wl,--build-id=none \
|
||||
-static \
|
||||
-m32 \
|
||||
-Wl,-rpath,${IWASM_LIB_LINUX} \
|
||||
-L${IWASM_LIB_LINUX} \
|
||||
-Wl,-rpath,${IWASM_LIB_LINUX_RELEASE} \
|
||||
-L${IWASM_LIB_LINUX_RELEASE} \
|
||||
-liwasm \
|
||||
-lm
|
||||
INCL_LINUX := \
|
||||
@ -136,12 +142,12 @@ ${BUILD_DIR}/%/system-linux.elf: ${BUILD_DIR}/%/system-linux.o
|
||||
${CC_LINUX} ${LDFLAGS_LINUX} -o $@
|
||||
|
||||
################################################################
|
||||
# WASM -> AOT -> Loaded by Runtime (Host/Baremetal platform)
|
||||
# WASM loaded by Runtime (Host+Baremetal platform)
|
||||
|
||||
CC_BAREMETAL := /opt/crosscompiler/bin/i386-elf-gcc
|
||||
CFLAGS_BAREMETAL := \
|
||||
-I. \
|
||||
-O0 \
|
||||
${OPT} \
|
||||
-m32 \
|
||||
-ffunction-sections \
|
||||
-ffreestanding \
|
||||
|
||||
@ -165,7 +165,7 @@ RUN git clone https://gitea.vps.chriphost.de/christoph/wamr wamrlib \
|
||||
# TODO: Should probably put the cross-compilation definitions in a toolchain file
|
||||
COPY --from=compiler-builder /opt/crosscompiler /opt/crosscompiler
|
||||
WORKDIR /wamrlib
|
||||
RUN mkdir build_libiwasm && cd build_libiwasm \
|
||||
RUN mkdir build_libiwasm_baremetal_release && cd build_libiwasm_baremetal_release \
|
||||
&& cmake \
|
||||
-DCMAKE_SYSTEM_NAME=Generic \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=i386 \
|
||||
@ -174,8 +174,36 @@ RUN mkdir build_libiwasm && cd build_libiwasm \
|
||||
-DCMAKE_ASM_COMPILER=/opt/crosscompiler/bin/i386-elf-gcc \
|
||||
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_FLAGS_RELEASE="-O3 -ggdb -DNDEBUG" \
|
||||
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -ggdb -DNDEBUG" \
|
||||
-DCMAKE_VERBOSE_MAKEFILE=ON \
|
||||
-DWAMR_BUILD_PLATFORM=baremetal \
|
||||
-DWAMR_BUILD_TARGET=X86_32 \
|
||||
-DWAMR_BUILD_AOT=1 \
|
||||
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
||||
-DWAMR_BUILD_INTERP=1 \
|
||||
-DWAMR_BUILD_FAST_INTERP=0 \
|
||||
-DWAMR_BUILD_JIT=0 \
|
||||
-DWAMR_BUILD_FAST_JIT=0 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=0 \
|
||||
-DWAMR_BUILD_SIMD=0 \
|
||||
-DCMAKE_COLOR_DIAGNOSTICS=ON \
|
||||
.. \
|
||||
&& make -j$(nproc)
|
||||
|
||||
WORKDIR /wamrlib
|
||||
RUN mkdir build_libiwasm_baremetal_debug && cd build_libiwasm_baremetal_debug \
|
||||
&& cmake \
|
||||
-DCMAKE_SYSTEM_NAME=Generic \
|
||||
-DCMAKE_SYSTEM_PROCESSOR=i386 \
|
||||
-DCMAKE_C_COMPILER=/opt/crosscompiler/bin/i386-elf-gcc \
|
||||
-DCMAKE_CXX_COMPILER=/opt/crosscompiler/bin/i386-elf-g++ \
|
||||
-DCMAKE_ASM_COMPILER=/opt/crosscompiler/bin/i386-elf-gcc \
|
||||
-DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_C_FLAGS_DEBUG="-O0 -ggdb" \
|
||||
-DCMAKE_C_FLAGS_RELEASE="-O2 -ggdb" \
|
||||
-DCMAKE_CXX_FLAGS_DEBUG="-O0 -ggdb" \
|
||||
-DCMAKE_VERBOSE_MAKEFILE=ON \
|
||||
-DWAMR_BUILD_PLATFORM=baremetal \
|
||||
-DWAMR_BUILD_TARGET=X86_32 \
|
||||
@ -194,8 +222,32 @@ RUN mkdir build_libiwasm && cd build_libiwasm \
|
||||
|
||||
# Build WAMR libiwasm for the host system
|
||||
WORKDIR /wamrlib
|
||||
RUN mkdir build_libiwasm_linux && cd build_libiwasm_linux \
|
||||
RUN mkdir build_libiwasm_linux_release && cd build_libiwasm_linux_release \
|
||||
&& cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_C_FLAGS_RELEASE="-O3 -ggdb -DNDEBUG" \
|
||||
-DCMAKE_CXX_FLAGS_RELEASE="-O3 -ggdb -DNDEBUG" \
|
||||
-DWAMR_BUILD_PLATFORM=linux \
|
||||
-DWAMR_BUILD_TARGET=X86_32 \
|
||||
-DWAMR_BUILD_AOT=1 \
|
||||
-DWAMR_BUILD_WAMR_COMPILER=0 \
|
||||
-DWAMR_BUILD_INTERP=1 \
|
||||
-DWAMR_BUILD_FAST_INTERP=0 \
|
||||
-DWAMR_BUILD_JIT=0 \
|
||||
-DWAMR_BUILD_FAST_JIT=0 \
|
||||
-DWAMR_BUILD_LIBC_BUILTIN=1 \
|
||||
-DWAMR_BUILD_LIBC_WASI=0 \
|
||||
-DWAMR_BUILD_SIMD=0 \
|
||||
-DCMAKE_COLOR_DIAGNOSTICS=ON \
|
||||
.. \
|
||||
&& make -j$(nproc)
|
||||
|
||||
WORKDIR /wamrlib
|
||||
RUN mkdir build_libiwasm_linux_debug && cd build_libiwasm_linux_debug \
|
||||
&& cmake \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_C_FLAGS_DEBUG="-O0 -ggdb" \
|
||||
-DCMAKE_CXX_FLAGS_DEBUG="-O0 -ggdb" \
|
||||
-DWAMR_BUILD_PLATFORM=linux \
|
||||
-DWAMR_BUILD_TARGET=X86_32 \
|
||||
-DWAMR_BUILD_AOT=1 \
|
||||
@ -243,15 +295,12 @@ COPY --from=wamr-builder /wamr/product-mini/platforms/linux/build_iwasm /opt/wam
|
||||
RUN ln -sf /opt/wamr/product-mini/platforms/linux/build_iwasm /opt/wamr-iwasm \
|
||||
&& ln -sf /opt/wamr/wamr-compiler/build_wamrc /opt/wamr-wamrc \
|
||||
&& ln -sf /opt/wamr/wamr-compiler/build_libvmlib /opt/wamr-libvmlib \
|
||||
&& ln -sf /opt/wamr/build_libiwasm /opt/wamr-libiwasm \
|
||||
&& ln -sf /opt/wamr/build_libiwasm_linux /opt/wamr-libiwasm-linux
|
||||
&& ln -sf /opt/wamr/build_libiwasm_baremetal_release /opt/wamr-libiwasm-baremetal-release \
|
||||
&& ln -sf /opt/wamr/build_libiwasm_baremetal_debug /opt/wamr-libiwasm-baremetal-debug \
|
||||
&& ln -sf /opt/wamr/build_libiwasm_linux_release /opt/wamr-libiwasm-linux-release \
|
||||
&& ln -sf /opt/wamr/build_libiwasm_linux_debug /opt/wamr-libiwasm-linux-debug
|
||||
|
||||
RUN useradd fail \
|
||||
&& mkdir /home/fail && chown fail /home/fail \
|
||||
&& echo 'fail:fail' | chpasswd && chsh fail --shell /usr/bin/fish \
|
||||
&& adduser fail sudo
|
||||
|
||||
COPY ./examples /home/fail/examples
|
||||
WORKDIR /home/fail/examples
|
||||
COPY ./examples /home/ubuntu/examples
|
||||
WORKDIR /home/ubuntu/examples
|
||||
|
||||
ENV PATH="$PATH:/opt/wasi-sdk/bin:/opt/wamr-iwasm:/opt/wamr-wamrc"
|
||||
|
||||
Reference in New Issue
Block a user