mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-14 04:11:03 +00:00
Add directory arg support to clone-llvm
This commit is contained in:
+24
-26
@@ -3,46 +3,44 @@
|
||||
set -euo pipefail
|
||||
|
||||
INSTALL_DIR="${PWD}/llvm18.0-emscripten"
|
||||
mkdir -p ${INSTALL_DIR}
|
||||
|
||||
./clone-llvm.sh
|
||||
|
||||
# Build LLVM, clang
|
||||
cd llvm-project
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
|
||||
# Check if EMSDK_ROOT is defined
|
||||
if [ -z "$EMSDK_ROOT" ]; then
|
||||
if [ -z "${EMSDK_ROOT:-}" ]; then
|
||||
echo "Error: EMSDK_ROOT is not defined."
|
||||
echo "Please set the EMSDK_ROOT environment variable to the root directory of your Emscripten SDK."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source ${EMSDK_ROOT}/emsdk_env.sh
|
||||
source "${EMSDK_ROOT}/emsdk_env.sh"
|
||||
|
||||
LLVM_SRC=$(pwd)
|
||||
LLVM_SRC=$(pwd)/llvm-project
|
||||
LLVM_SRC=$(realpath "$LLVM_SRC")
|
||||
LLVM_NATIVE=$LLVM_SRC/build-native
|
||||
LLVM_WASM=$LLVM_SRC/build-wasm
|
||||
LLVM_NATIVE="${LLVM_SRC}/build-native"
|
||||
LLVM_WASM="${LLVM_SRC}/build-wasm"
|
||||
|
||||
# Cross compiling llvm needs a native build of "llvm-tblgen" and "clang-tblgen"
|
||||
if [ ! -d $LLVM_NATIVE/ ]; then
|
||||
./clone-llvm.sh "${LLVM_SRC}"
|
||||
|
||||
# Cross-compiling LLVM requires a native build of "llvm-tblgen" and "clang-tblgen"
|
||||
if [ ! -d "${LLVM_NATIVE}" ]; then
|
||||
cmake -G Ninja \
|
||||
-S $LLVM_SRC/llvm/ \
|
||||
-B $LLVM_NATIVE/ \
|
||||
-S "${LLVM_SRC}/llvm" \
|
||||
-B "${LLVM_NATIVE}" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_TARGETS_TO_BUILD=WebAssembly \
|
||||
-DLLVM_ENABLE_PROJECTS="clang"
|
||||
fi
|
||||
cmake --build $LLVM_NATIVE/ -- llvm-tblgen clang-tblgen llvm-config
|
||||
|
||||
if [ ! -d $LLVM_WASM/ ]; then
|
||||
cmake --build "${LLVM_NATIVE}" -- llvm-tblgen clang-tblgen llvm-config
|
||||
|
||||
if [ ! -d "${LLVM_WASM}" ]; then
|
||||
EMCC_DEBUG=2 \
|
||||
CXXFLAGS="-Dwait4=__syscall_wait4" \
|
||||
LDFLAGS="-lnodefs.js -s NO_INVOKE_RUN -s EXIT_RUNTIME -s INITIAL_MEMORY=64MB -s ALLOW_MEMORY_GROWTH -s \
|
||||
EXPORTED_RUNTIME_METHODS=FS,callMain,NODEFS -s MODULARIZE -s EXPORT_ES6 -s WASM_BIGINT" \
|
||||
emcmake cmake -G Ninja \
|
||||
-S $LLVM_SRC/llvm/ \
|
||||
-B $LLVM_WASM/ \
|
||||
-S "${LLVM_SRC}/llvm" \
|
||||
-B "${LLVM_WASM}" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DLLVM_TARGETS_TO_BUILD='RISCV' \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;lld" \
|
||||
@@ -58,15 +56,15 @@ if [ ! -d $LLVM_WASM/ ]; then
|
||||
-DLLVM_ENABLE_LIBXML2=Off \
|
||||
-DLLVM_ENABLE_ZLIB=Off \
|
||||
-DLLVM_ENABLE_ZSTD=Off \
|
||||
-DLLVM_TABLEGEN=$LLVM_NATIVE/bin/llvm-tblgen \
|
||||
-DCLANG_TABLEGEN=$LLVM_NATIVE/bin/clang-tblgen \
|
||||
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}/
|
||||
-DLLVM_TABLEGEN="${LLVM_NATIVE}/bin/llvm-tblgen" \
|
||||
-DCLANG_TABLEGEN="${LLVM_NATIVE}/bin/clang-tblgen" \
|
||||
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
|
||||
fi
|
||||
|
||||
cmake --build $LLVM_WASM/
|
||||
cmake --install $LLVM_WASM/
|
||||
cmake --build "${LLVM_WASM}"
|
||||
cmake --install "${LLVM_WASM}"
|
||||
|
||||
cp $LLVM_NATIVE/bin/llvm-config $INSTALL_DIR/bin
|
||||
cp "${LLVM_NATIVE}/bin/llvm-config" "${INSTALL_DIR}/bin"
|
||||
|
||||
echo ""
|
||||
echo "success"
|
||||
echo "LLVM cross-compilation for WebAssembly completed successfully."
|
||||
|
||||
Reference in New Issue
Block a user