mirror of https://github.com/python/cpython.git
gh-95174: Move WASIX logic into wasi-env (GH-95320)
wasi-env now sets WASIX flags. This allows us to control all build
parameter for wasm32-wasi buildbot from CPython repository.
Also export and improve SYSROOT parameter.
(cherry picked from commit 2833f3798d
)
Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
parent
e14c4d5a2b
commit
25086f1eed
|
@ -234,15 +234,14 @@ ## Cross-compile to wasm32-wasi
|
||||||
|
|
||||||
The script ``wasi-env`` sets necessary compiler and linker flags as well as
|
The script ``wasi-env`` sets necessary compiler and linker flags as well as
|
||||||
``pkg-config`` overrides. The script assumes that WASI-SDK is installed in
|
``pkg-config`` overrides. The script assumes that WASI-SDK is installed in
|
||||||
``/opt/wasi-sdk`` or ``$WASI_SDK_PATH``.
|
``/opt/wasi-sdk`` or ``$WASI_SDK_PATH`` and WASIX is installed in
|
||||||
|
``/opt/wasix`` or ``$WASIX_PATH``.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mkdir -p builddir/wasi
|
mkdir -p builddir/wasi
|
||||||
pushd builddir/wasi
|
pushd builddir/wasi
|
||||||
|
|
||||||
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi \
|
CONFIG_SITE=../../Tools/wasm/config.site-wasm32-wasi \
|
||||||
CFLAGS="-isystem /opt/wasix/include" \
|
|
||||||
LDFLAGS="-L/opt/wasix/lib -lwasix" \
|
|
||||||
../../Tools/wasm/wasi-env ../../configure -C \
|
../../Tools/wasm/wasi-env ../../configure -C \
|
||||||
--host=wasm32-unknown-wasi \
|
--host=wasm32-unknown-wasi \
|
||||||
--build=$(../../config.guess) \
|
--build=$(../../config.guess) \
|
||||||
|
|
|
@ -30,17 +30,24 @@ if test -z "$1"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
WASI_SDK_PATH="${WASI_SDK_PATH:-/opt/wasi-sdk}"
|
WASI_SDK_PATH="${WASI_SDK_PATH:-/opt/wasi-sdk}"
|
||||||
|
WASI_SYSROOT="${WASI_SDK_PATH}/share/wasi-sysroot"
|
||||||
|
WASIX_PATH="${WASIX_PATH:-/opt/wasix}"
|
||||||
|
|
||||||
if ! test -x "${WASI_SDK_PATH}/bin/clang"; then
|
if ! test -x "${WASI_SDK_PATH}/bin/clang"; then
|
||||||
echo "Error: ${WASI_SDK_PATH}/bin/clang does not exist." >&2
|
echo "Error: ${WASI_SDK_PATH}/bin/clang does not exist." >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CC="${WASI_SDK_PATH}/bin/clang"
|
||||||
|
CPP="${WASI_SDK_PATH}/bin/clang-cpp"
|
||||||
|
CXX="${WASI_SDK_PATH}/bin/clang++"
|
||||||
|
|
||||||
# --sysroot is required if WASI-SDK is not installed in /opt/wasi-sdk.
|
# --sysroot is required if WASI-SDK is not installed in /opt/wasi-sdk.
|
||||||
WASI_SYSROOT="${WASI_SDK_PATH}/share/wasi-sysroot"
|
if test "${WASI_SDK_PATH}" != "/opt/wasi-sdk"; then
|
||||||
CC="${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SYSROOT}"
|
CC="${CC} --sysroot=${WASI_SYSROOT}"
|
||||||
CPP="${WASI_SDK_PATH}/bin/clang-cpp --sysroot=${WASI_SYSROOT}"
|
CPP="${CPP} --sysroot=${WASI_SYSROOT}"
|
||||||
CXX="${WASI_SDK_PATH}/bin/clang++ --sysroot=${WASI_SYSROOT}"
|
CXX="${CXX} --sysroot=${WASI_SYSROOT}"
|
||||||
|
fi
|
||||||
|
|
||||||
# use ccache if available
|
# use ccache if available
|
||||||
if command -v ccache >/dev/null 2>&1; then
|
if command -v ccache >/dev/null 2>&1; then
|
||||||
|
@ -58,10 +65,17 @@ PKG_CONFIG_PATH=""
|
||||||
PKG_CONFIG_LIBDIR="${WASI_SYSROOT}/lib/pkgconfig:${WASI_SYSROOT}/share/pkgconfig"
|
PKG_CONFIG_LIBDIR="${WASI_SYSROOT}/lib/pkgconfig:${WASI_SYSROOT}/share/pkgconfig"
|
||||||
PKG_CONFIG_SYSROOT_DIR="${WASI_SYSROOT}"
|
PKG_CONFIG_SYSROOT_DIR="${WASI_SYSROOT}"
|
||||||
|
|
||||||
PATH="${WASI_SDK_PATH}/bin:$PATH"
|
# add WASIX (POSIX stubs for WASI) if WASIX is installed
|
||||||
|
if test -f "${WASIX_PATH}/lib/libwasix.a"; then
|
||||||
|
CFLAGS="${CFLAGS} -isystem ${WASIX_PATH}/include"
|
||||||
|
LDFLAGS="${LDFLAGS} -L${WASIX_PATH}/lib -lwasix"
|
||||||
|
fi
|
||||||
|
|
||||||
export WASI_SDK_PATH
|
PATH="${WASI_SDK_PATH}/bin:${PATH}"
|
||||||
|
|
||||||
|
export WASI_SDK_PATH WASI_SYSROOT
|
||||||
export CC CPP CXX LDSHARED AR RANLIB
|
export CC CPP CXX LDSHARED AR RANLIB
|
||||||
|
export CFLAGS LDFLAGS
|
||||||
export PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR
|
export PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue