From 2685f2cae0141361a780fbf7826a00b4d6284cc8 Mon Sep 17 00:00:00 2001 From: Marcin Kolny Date: Wed, 30 Jul 2025 04:25:52 +0200 Subject: [PATCH] Use venv to install llvm dependencies and run build script (#4514) Installing pip packages system-wide is no longer recommended, therefore we create virtual environment for setting up the build environment for LLVM. --- wamr-compiler/build_llvm.sh | 14 +++++++++++++- wamr-compiler/build_llvm_arc.sh | 4 ++-- wamr-compiler/build_llvm_xtensa.sh | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/wamr-compiler/build_llvm.sh b/wamr-compiler/build_llvm.sh index c3ec54b61..75285b52c 100755 --- a/wamr-compiler/build_llvm.sh +++ b/wamr-compiler/build_llvm.sh @@ -3,5 +3,17 @@ # Copyright (C) 2020 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt +TEMP_DIR=$(mktemp -d) + +cleanup() { + local exit_code=$? + rm -rf "$TEMP_DIR" + exit $exit_code +} + +trap cleanup EXIT INT TERM + +/usr/bin/env python3 -m venv --clear "$TEMP_DIR" +source "$TEMP_DIR/bin/activate" +/usr/bin/env python3 -m pip install -r ../build-scripts/requirements.txt /usr/bin/env python3 ../build-scripts/build_llvm.py "$@" diff --git a/wamr-compiler/build_llvm_arc.sh b/wamr-compiler/build_llvm_arc.sh index d148e11ec..bc10216e1 100755 --- a/wamr-compiler/build_llvm_arc.sh +++ b/wamr-compiler/build_llvm_arc.sh @@ -3,5 +3,5 @@ # Copyright (C) 2020 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt -/usr/bin/env python3 ../build-scripts/build_llvm.py --platform arc "$@" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +$SCRIPT_DIR/build_llvm.sh --platform arc "$@" diff --git a/wamr-compiler/build_llvm_xtensa.sh b/wamr-compiler/build_llvm_xtensa.sh index 183ea379f..29559ce35 100755 --- a/wamr-compiler/build_llvm_xtensa.sh +++ b/wamr-compiler/build_llvm_xtensa.sh @@ -3,5 +3,5 @@ # Copyright (C) 2020 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt -/usr/bin/env python3 ../build-scripts/build_llvm.py --platform xtensa "$@" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +$SCRIPT_DIR/build_llvm.sh --platform xtensa "$@"