mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-24 12:36:01 -07:00
First step towards WASI support
This commit is contained in:
parent
4d1c4bf0ba
commit
8745c85114
38
dist-build/wasi.sh
Executable file
38
dist-build/wasi.sh
Executable file
@ -0,0 +1,38 @@
|
||||
#! /bin/sh
|
||||
|
||||
if [ -z "$WASI_SYSROOT" ]; then
|
||||
export WASI_SYSROOT="/opt/wasi-sysroot"
|
||||
fi
|
||||
|
||||
export PATH="/usr/local/opt/llvm/bin:$PATH"
|
||||
|
||||
export PREFIX="$(pwd)/libsodium-wasm32-wasi"
|
||||
|
||||
mkdir -p $PREFIX || exit 1
|
||||
|
||||
export CC="clang"
|
||||
export CFLAGS="--target=wasm32-unknkown-wasi --sysroot=${WASI_SYSROOT} -Os"
|
||||
export LDFLAGS="-s"
|
||||
export NM="llvm-nm"
|
||||
export AR="llvm-ar"
|
||||
export RANLIB="llvm-ranlib"
|
||||
export STRIP="llvm-strip"
|
||||
|
||||
make distclean > /dev/null
|
||||
|
||||
if [ -z "$LIBSODIUM_FULL_BUILD" ]; then
|
||||
export LIBSODIUM_ENABLE_MINIMAL_FLAG="--enable-minimal"
|
||||
else
|
||||
export LIBSODIUM_ENABLE_MINIMAL_FLAG=""
|
||||
fi
|
||||
|
||||
./configure ${LIBSODIUM_ENABLE_MINIMAL_FLAG} \
|
||||
--prefix="$PREFIX" --with-sysroot="$WASI_SYSROOT" \
|
||||
--host=wasm32-unknown-wasi --disable-ssp --disable-shared || exit 1
|
||||
|
||||
NPROCESSORS=$(getconf NPROCESSORS_ONLN 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null)
|
||||
PROCESSORS=${NPROCESSORS:-3}
|
||||
|
||||
make -j${PROCESSORS} install || exit 1
|
||||
|
||||
make distclean > /dev/null
|
@ -23,6 +23,7 @@ segv_handler(int sig)
|
||||
|
||||
printf("Intentional segfault / bus error caught\n");
|
||||
printf("OK\n");
|
||||
#ifdef SIG_DFL
|
||||
# ifdef SIGSEGV
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
# endif
|
||||
@ -31,6 +32,7 @@ segv_handler(int sig)
|
||||
# endif
|
||||
# ifdef SIGABRT
|
||||
signal(SIGABRT, SIG_DFL);
|
||||
# endif
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
@ -70,7 +72,7 @@ main(void)
|
||||
sodium_free(buf);
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
#ifdef SIG_DFL
|
||||
# ifdef SIGSEGV
|
||||
signal(SIGSEGV, segv_handler);
|
||||
# endif
|
||||
@ -79,6 +81,7 @@ main(void)
|
||||
# endif
|
||||
# ifdef SIGABRT
|
||||
signal(SIGABRT, segv_handler);
|
||||
# endif
|
||||
#endif
|
||||
size = 1U + randombytes_uniform(100000U);
|
||||
buf = sodium_malloc(size);
|
||||
|
@ -19,6 +19,7 @@ segv_handler(int sig)
|
||||
|
||||
printf("Intentional segfault / bus error caught\n");
|
||||
printf("OK\n");
|
||||
#ifdef SIG_DFL
|
||||
# ifdef SIGSEGV
|
||||
signal(SIGSEGV, SIG_DFL);
|
||||
# endif
|
||||
@ -27,6 +28,7 @@ segv_handler(int sig)
|
||||
# endif
|
||||
# ifdef SIGABRT
|
||||
signal(SIGABRT, SIG_DFL);
|
||||
# endif
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
@ -37,6 +39,7 @@ main(void)
|
||||
void * buf;
|
||||
size_t size;
|
||||
|
||||
#ifdef SIG_DFL
|
||||
# ifdef SIGSEGV
|
||||
signal(SIGSEGV, segv_handler);
|
||||
# endif
|
||||
@ -45,6 +48,7 @@ main(void)
|
||||
# endif
|
||||
# ifdef SIGABRT
|
||||
signal(SIGABRT, segv_handler);
|
||||
# endif
|
||||
#endif
|
||||
size = 1U + randombytes_uniform(100000U);
|
||||
buf = sodium_malloc(size);
|
||||
|
Loading…
Reference in New Issue
Block a user