sporniket / ideas

My backlog of ideas, organized as a bunch of issues
0 stars 0 forks source link

[fpga] make a wasm-runnable of yices2 for YoWASP #36

Open sporniket opened 11 months ago

sporniket commented 11 months ago

Now on its own repository : https://github.com/sporniket/yices2-built-with-wasi-sdk

Yices2 is required to be included to YoWASP to trully require only python and pdm for my projects with amaranth.

sporniket commented 11 months ago

The story so far :

Playing with environment variables, and reacting to the output and logs of configure, I kind of persuaded configure to use the clang provided by wasi-sdk. And now I will have to get a WASM version of the GMP lib.

The build.sh looks like that so far :

#!/bin/sh -ex

export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct)
YICES2_SRC=yices2-src
YICES2_BUILD=yices2-build

WASI_SDK="wasi-sdk-19.0"
WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
if ! [ -d ${WASI_SDK} ]; then curl -L ${WASI_SDK_URL} | tar xzf -; fi

${WASI_SDK}/bin/clang --sysroot ${WASI_SDK}/share/wasi-sysroot -c getopt_long.c

### START of building using (hopefully) WASI toolchain ###
cp ${WASI_SDK}/share/misc/config.guess ${WASI_SDK}/share/misc/config.sub ${YICES2_SRC}
cp ${WASI_SDK}/share/misc/config.guess ${WASI_SDK}/share/misc/config.sub ${YICES2_SRC}/autoconf

WASI_SDK_PATH=`pwd`/${WASI_SDK}
WASIFLAGS="-D_WASI_EMULATED_PROCESS_CLOCKS"
PRETTY=0 

### --- from ./configure --help
# Some influential environment variables:
#   CC          C compiler command
#   CFLAGS      C compiler flags
#   LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
#               nonstandard directory <lib dir>
#   LIBS        libraries to pass to the linker, e.g. -l<library>
#   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
#               you have headers in a nonstandard directory <include dir>
###

export CC="${WASI_SDK_PATH}/bin/clang"
export CFLAGS="--target=wasm32-unknown-wasi --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
export LDFLAGS="-Wl,--strip-all --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"
export LIBS="-lwasi-emulated-process-clocks $(pwd)/getopt_long.o  --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot"

export TARGET="wasm32-unknown-wasi"
export ARCH="${TARGET}"

cd yices2-src
autoconf
#./configure --build=${TARGET} --host=${TARGET}
./configure  --host=${TARGET}

and I get the following traces :

+ git log -1 --format=%ct
+ export SOURCE_DATE_EPOCH=1699597582
+ YICES2_SRC=yices2-src
+ YICES2_BUILD=yices2-build
+ WASI_SDK=wasi-sdk-19.0
+ WASI_SDK_URL=https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-19/wasi-sdk-19.0-linux.tar.gz
+ [ -d wasi-sdk-19.0 ]
+ wasi-sdk-19.0/bin/clang --sysroot wasi-sdk-19.0/share/wasi-sysroot -c getopt_long.c
+ cp wasi-sdk-19.0/share/misc/config.guess wasi-sdk-19.0/share/misc/config.sub yices2-src
+ cp wasi-sdk-19.0/share/misc/config.guess wasi-sdk-19.0/share/misc/config.sub yices2-src/autoconf
+ pwd
+ WASI_SDK_PATH=/home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0
+ WASIFLAGS=-D_WASI_EMULATED_PROCESS_CLOCKS
+ PRETTY=0
+ export CC=/home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/bin/clang
+ export CFLAGS=--target=wasm32-unknown-wasi --sysroot=/home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/share/wasi-sysroot
+ export LDFLAGS=-Wl,--strip-all --sysroot=/home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/share/wasi-sysroot
+ pwd
+ export LIBS=-lwasi-emulated-process-clocks /home/dsporn/Projects/amaranth/YoWASP/yices2-exp/getopt_long.o  --sysroot=/home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/share/wasi-sysroot
+ export TARGET=wasm32-unknown-wasi
+ export ARCH=wasm32-unknown-wasi
+ cd yices2-src
+ autoconf
configure.ac:905: warning: AC_C_BIGENDIAN should be used with AC_CONFIG_HEADERS
+ ./configure --host=wasm32-unknown-wasi
checking build system type... x86_64-pc-linux-gnux32
checking whether make sets $(MAKE)... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking whether ln -s works... yes
checking for a race-free mkdir -p... /usr/bin/mkdir -p
checking for a BSD-compatible install... /usr/bin/install -c
checking for wasm32-unknown-wasi-gcc... /home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/bin/clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether the compiler supports GNU C... yes
checking whether /home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/bin/clang accepts -g... yes
checking for /home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/bin/clang option to enable C11 features... none needed
checking for wasm32-unknown-wasi-ranlib... no
checking for ranlib... ranlib
configure: WARNING: using cross tools not prefixed with host triplet
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for wasm32-unknown-wasi-ld... no
checking for ld... ld
checking for wasm32-unknown-wasi-ar... no
checking for ar... ar
checking for wasm32-unknown-wasi-strip... no
checking for strip... strip
checking for gperf... gperf
checking gperf version... 3.1
checking whether /home/dsporn/Projects/amaranth/YoWASP/yices2-exp/wasi-sdk-19.0/bin/clang accepts option -fno-stack-protector... yes
checking for stdio.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for strings.h... yes
checking for sys/stat.h... yes
checking for sys/types.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
configure: Trying to find a usable libgmp.a
configure: Searching in  /usr/local/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu64 /usr/local/lib64 /lib64 /usr/lib64 /usr/local/lib /lib /usr/lib /usr/x86_64-linux-gnu/lib64 /usr/x86_64-linux-gnu/lib /usr/local/lib /usr/lib /lib
checking for libgmp.a in /usr/local/lib/x86_64-linux-gnu... no
checking for libgmp.a in /lib/x86_64-linux-gnu... found
checking whether /lib/x86_64-linux-gnu/libgmp.a is usable... yes
checking for main in -lm... yes
checking for __gmpz_cmp in -lgmp... no
configure: error: *** GMP library not found. Try to set LDFLAGS ***