diff --git a/CMakeLists.txt b/CMakeLists.txt index 23583375bb3..871f913a8cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,6 +161,9 @@ endfunction() # enable json support if(ENABLE_RAPIDJSON) find_package(RapidJSON CONFIG REQUIRED) + if(NOT TARGET RapidJSON) + message(FATAL_ERROR "RapidJSON package configuration did not define the RapidJSON target") + endif() abacus_add_feature_definitions(__RAPIDJSON) target_link_libraries(abacus_external_deps INTERFACE RapidJSON) endif() diff --git a/toolchain/build_abacus_aocc-aocl.sh b/toolchain/build_abacus_aocc-aocl.sh index b32295bf119..c8a991f17d5 100755 --- a/toolchain/build_abacus_aocc-aocl.sh +++ b/toolchain/build_abacus_aocc-aocl.sh @@ -24,7 +24,6 @@ rm -rf $BUILD_DIR PREFIX=$ABACUS_DIR ELPA=${ELPA_ROOT} CEREAL=${CEREAL_ROOT}/include -RAPIDJSON=${RAPIDJSON_ROOT} LAPACK=$AOCLhome/lib SCALAPACK=$AOCLhome/lib FFTW3=$AOCLhome @@ -75,7 +74,6 @@ cmake -B $BUILD_DIR -DCMAKE_INSTALL_PREFIX=$PREFIX \ -DUSE_OPENMP=ON \ -DUSE_ELPA=ON \ -DENABLE_RAPIDJSON=ON \ - -DRapidJSON_DIR=$RAPIDJSON \ -DENABLE_LIBRI=ON \ -DLIBRI_DIR=$LIBRI \ -DLIBCOMM_DIR=$LIBCOMM \ diff --git a/toolchain/install_abacus_toolchain_new.sh b/toolchain/install_abacus_toolchain_new.sh index 0f0d85d42e3..cbcd4385589 100755 --- a/toolchain/install_abacus_toolchain_new.sh +++ b/toolchain/install_abacus_toolchain_new.sh @@ -50,7 +50,7 @@ main() { # Initialize configuration with command line arguments if ! config_init "${args[@]}"; then show_help - exit 0 + exit 1 fi # Handle special version-related requests diff --git a/toolchain/scripts/lib/config_manager.sh b/toolchain/scripts/lib/config_manager.sh index fc7ca306837..249e6515566 100644 --- a/toolchain/scripts/lib/config_manager.sh +++ b/toolchain/scripts/lib/config_manager.sh @@ -456,13 +456,13 @@ config_validate() { if [[ -n "${CONFIG_CACHE[NPROCS_OVERWRITE]}" ]]; then if ! [[ "${CONFIG_CACHE[NPROCS_OVERWRITE]}" =~ ^[0-9]+$ ]]; then report_error ${LINENO} "Invalid number of processes: ${CONFIG_CACHE[NPROCS_OVERWRITE]}" - exit 1 + return 1 fi fi if ! [[ "${CONFIG_CACHE[LOG_LINES]}" =~ ^[0-9]+$ ]]; then report_error ${LINENO} "Invalid log lines value: ${CONFIG_CACHE[LOG_LINES]}" - exit 1 + return 1 fi # Validate GPU version - support only numeric formats @@ -476,7 +476,7 @@ config_validate() { CONFIG_CACHE["ARCH_NUM"]="$arch_num" else report_error ${LINENO} "Invalid GPU version: $gpu_ver. Supported formats: numeric with decimal (6.0, 7.0, 8.0, 8.9, etc.) or numeric without decimal (60, 70, 80, 89, etc.)" - exit 1 + return 1 fi else CONFIG_CACHE["ARCH_NUM"]="no" @@ -1166,27 +1166,37 @@ config_parse_arguments() { config_init() { # Set defaults first config_set_defaults - + # Initialize version helper to ensure VERSION_STRATEGY defaults are set if command -v version_helper_init > /dev/null 2>&1; then version_helper_init fi - + # Load configuration from file (if available) - this will override defaults - config_load_from_file - + if ! config_load_from_file; then + return 1 + fi + # Apply mode-based configurations from file - this will override defaults - config_apply_modes_from_file - + if ! config_apply_modes_from_file; then + return 1 + fi + # Parse command line arguments - this will override file settings - config_parse_arguments "$@" - + if ! config_parse_arguments "$@"; then + return 1 + fi + # Apply mode-based configurations from command line - config_apply_modes - + if ! config_apply_modes; then + return 1 + fi + # Validate configuration - config_validate - + if ! config_validate; then + return 1 + fi + return 0 } @@ -1262,4 +1272,6 @@ config_apply_modes() { ;; esac fi + + return 0 } diff --git a/toolchain/scripts/lib/wrapper_runner.sh b/toolchain/scripts/lib/wrapper_runner.sh new file mode 100644 index 00000000000..81adb56c1ac --- /dev/null +++ b/toolchain/scripts/lib/wrapper_runner.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +run_toolchain_with_log() { + local log_file="$1" + shift + + "$@" | tee "$log_file" + local installer_status=${PIPESTATUS[0]} + + return "$installer_status" +} diff --git a/toolchain/tests/test_installer_argument_failures.sh b/toolchain/tests/test_installer_argument_failures.sh new file mode 100755 index 00000000000..48c153dad8b --- /dev/null +++ b/toolchain/tests/test_installer_argument_failures.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +set -u + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" +TOOLCHAIN_DIR="${REPO_ROOT}/toolchain" +FAILURES=0 + +fail() { + printf 'FAIL: %s\n' "$*" >&2 + FAILURES=$((FAILURES + 1)) +} + +copy_toolchain() { + local tmpdir="$1" + local entry name + mkdir -p "${tmpdir}/toolchain" + while IFS= read -r -d '' entry; do + name="${entry##*/}" + case "$name" in + build|install) continue ;; + esac + cp -a "$entry" "${tmpdir}/toolchain/" + done < <(find "${TOOLCHAIN_DIR}" -mindepth 1 -maxdepth 1 -print0) +} + +run_installer_in_copy() { + local tmpdir="$1" + shift + (cd "${tmpdir}/toolchain" && ./install_abacus_toolchain_new.sh "$@") >"${tmpdir}/output.log" 2>&1 +} + +assert_invalid_input_fails() { + local name="$1" + local expected_text="$2" + shift 2 + + local tmpdir status + tmpdir="$(mktemp -d)" + copy_toolchain "$tmpdir" + + run_installer_in_copy "$tmpdir" "$@" + status=$? + + if [[ "$status" -eq 0 ]]; then + cat "${tmpdir}/output.log" >&2 + fail "${name} exited 0; expected nonzero" + fi + + if ! grep -Fq -- "$expected_text" "${tmpdir}/output.log"; then + cat "${tmpdir}/output.log" >&2 + fail "${name} did not report expected error: ${expected_text}" + fi + + if ! grep -Fq "install_abacus_toolchain_new.sh [OPTIONS]" "${tmpdir}/output.log"; then + cat "${tmpdir}/output.log" >&2 + fail "${name} output did not contain usage text" + fi + + if [[ -e "${tmpdir}/toolchain/install/setup" ]]; then + fail "${name} wrote install/setup even though argument parsing failed" + fi + + rm -rf "$tmpdir" +} + +assert_valid_dry_run_succeeds() { + local name="$1" + shift + + local tmpdir status + tmpdir="$(mktemp -d)" + copy_toolchain "$tmpdir" + + run_installer_in_copy "$tmpdir" "$@" + status=$? + + if [[ "$status" -ne 0 ]]; then + cat "${tmpdir}/output.log" >&2 + fail "${name} exited ${status}; expected 0" + fi + + if ! grep -Fq "Configuration files generated successfully (dry-run mode)" "${tmpdir}/output.log"; then + cat "${tmpdir}/output.log" >&2 + fail "${name} output did not contain dry-run success text" + fi + + if grep -Fq "Attempting secure download" "${tmpdir}/output.log"; then + cat "${tmpdir}/output.log" >&2 + fail "${name} attempted a package download during dry-run" + fi + + rm -rf "$tmpdir" +} + +assert_valid_help_succeeds() { + local tmpdir status + tmpdir="$(mktemp -d)" + copy_toolchain "$tmpdir" + + run_installer_in_copy "$tmpdir" --help + status=$? + + if [[ "$status" -ne 0 ]]; then + cat "${tmpdir}/output.log" >&2 + fail "--help exited ${status}; expected 0" + fi + + if ! grep -Fq "install_abacus_toolchain_new.sh [OPTIONS]" "${tmpdir}/output.log"; then + cat "${tmpdir}/output.log" >&2 + fail "--help output did not contain usage text" + fi + + rm -rf "$tmpdir" +} + +assert_invalid_input_fails "invalid package version" "Invalid package version format" --dry-run --package-version bad:wrong +assert_invalid_input_fails "missing package version value" "--package-version requires at least one package:version argument" --dry-run --package-version +assert_invalid_input_fails "invalid mpi mode" "Invalid MPI mode: invalid" --dry-run --mpi-mode invalid +assert_invalid_input_fails "invalid gpu version" "Invalid GPU version" --dry-run --gpu-ver bad +assert_valid_dry_run_succeeds "explicit system openblas dry-run" --dry-run --with-openblas=system +assert_valid_help_succeeds + +if [[ "$FAILURES" -ne 0 ]]; then + printf '%s installer argument failure test(s) failed\n' "$FAILURES" >&2 + exit 1 +fi + +printf 'installer argument failure tests passed\n' diff --git a/toolchain/tests/test_rapidjson_cmake.sh b/toolchain/tests/test_rapidjson_cmake.sh new file mode 100755 index 00000000000..bd3089d99cd --- /dev/null +++ b/toolchain/tests/test_rapidjson_cmake.sh @@ -0,0 +1,192 @@ +#!/usr/bin/env bash +set -u + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" +FAILURES=0 + +fail() { + printf 'FAIL: %s\n' "$*" >&2 + FAILURES=$((FAILURES + 1)) +} + +write_target_package() { + local prefix="$1" + mkdir -p "${prefix}/include/rapidjson" "${prefix}/lib/cmake/RapidJSON" + printf '#pragma once\n' >"${prefix}/include/rapidjson/document.h" + cat >"${prefix}/lib/cmake/RapidJSON/RapidJSONConfig.cmake" <<'EOF' +get_filename_component(RapidJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_rapidjson_prefix "${RapidJSON_CMAKE_DIR}/../../.." ABSOLUTE) +if(NOT TARGET RapidJSON) + add_library(RapidJSON INTERFACE IMPORTED) + set_property(TARGET RapidJSON PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${_rapidjson_prefix}/include") +endif() +EOF +} + +write_variable_only_package() { + local prefix="$1" + mkdir -p "${prefix}/include/rapidjson" "${prefix}/lib/cmake/RapidJSON" + printf '#pragma once\n' >"${prefix}/include/rapidjson/document.h" + cat >"${prefix}/lib/cmake/RapidJSON/RapidJSONConfig.cmake" <<'EOF' +get_filename_component(RapidJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +get_filename_component(_rapidjson_prefix "${RapidJSON_CMAKE_DIR}/../../.." ABSOLUTE) +set(RapidJSON_INCLUDE_DIR "${_rapidjson_prefix}/include") +set(RapidJSON_INCLUDE_DIRS "${RapidJSON_INCLUDE_DIR}") +EOF +} + +write_test_project() { + local project_dir="$1" + mkdir -p "$project_dir" + cat >"${project_dir}/CMakeLists.txt" <<'EOF' +cmake_minimum_required(VERSION 3.16) +project(check_rapidjson_target LANGUAGES CXX) + +function(abacus_add_feature_definitions) + set_property(GLOBAL APPEND PROPERTY ABACUS_FEATURE_DEFINITIONS ${ARGN}) +endfunction() + +find_package(RapidJSON CONFIG REQUIRED) +if(NOT TARGET RapidJSON) + message(FATAL_ERROR "RapidJSON package configuration did not define the RapidJSON target") +endif() + +add_library(deps INTERFACE) +target_link_libraries(deps INTERFACE RapidJSON) +abacus_add_feature_definitions(__RAPIDJSON) + +get_target_property(_links deps INTERFACE_LINK_LIBRARIES) +if(NOT "RapidJSON" IN_LIST _links) + message(FATAL_ERROR "Expected deps to link to RapidJSON target, got '${_links}'") +endif() + +get_property(_defs GLOBAL PROPERTY ABACUS_FEATURE_DEFINITIONS) +if(NOT "__RAPIDJSON" IN_LIST _defs) + message(FATAL_ERROR "Expected __RAPIDJSON feature definition") +endif() +EOF +} + +run_cmake_configure() { + local source_dir="$1" + local build_dir="$2" + local prefix="$3" + + cmake -S "$source_dir" -B "$build_dir" \ + -DCMAKE_PREFIX_PATH="$prefix" \ + >"${build_dir}.log" 2>&1 +} + +run_top_level_configure() { + local build_dir="$1" + local prefix="$2" + + cmake -S "$REPO_ROOT" -B "$build_dir" \ + -DENABLE_RAPIDJSON=ON \ + -DCMAKE_PREFIX_PATH="$prefix" \ + >"${build_dir}.log" 2>&1 +} + +test_rapidjson_target_package_configures() { + local tmpdir prefix source_dir build_dir status + tmpdir="$(mktemp -d)" + prefix="${tmpdir}/prefix" + source_dir="${tmpdir}/target-project" + build_dir="${tmpdir}/target-build" + + write_target_package "$prefix" + write_test_project "$source_dir" + run_cmake_configure "$source_dir" "$build_dir" "$prefix" + status=$? + + if [[ "$status" -ne 0 ]]; then + cat "${build_dir}.log" >&2 + fail "RapidJSON target package did not configure" + fi + + rm -rf "$tmpdir" +} + +test_variable_only_package_fails() { + local tmpdir prefix source_dir build_dir status + tmpdir="$(mktemp -d)" + prefix="${tmpdir}/prefix" + source_dir="${tmpdir}/variable-project" + build_dir="${tmpdir}/variable-build" + + write_variable_only_package "$prefix" + write_test_project "$source_dir" + run_cmake_configure "$source_dir" "$build_dir" "$prefix" + status=$? + + if [[ "$status" -eq 0 ]]; then + cat "${build_dir}.log" >&2 + fail "variable-only RapidJSON package configured; expected target-missing failure" + elif ! grep -Fq "RapidJSON package configuration did not define the RapidJSON target" "${build_dir}.log"; then + cat "${build_dir}.log" >&2 + fail "variable-only RapidJSON package failed for the wrong reason" + fi + + rm -rf "$tmpdir" +} + +test_top_level_rejects_variable_only_package() { + local tmpdir prefix build_dir status + tmpdir="$(mktemp -d)" + prefix="${tmpdir}/prefix" + build_dir="${tmpdir}/top-level-build" + + write_variable_only_package "$prefix" + run_top_level_configure "$build_dir" "$prefix" + status=$? + + if [[ "$status" -eq 0 ]]; then + cat "${build_dir}.log" >&2 + fail "top-level CMake configured with variable-only RapidJSON package; expected target-missing failure" + elif ! grep -Fq "RapidJSON package configuration did not define the RapidJSON target" "${build_dir}.log"; then + cat "${build_dir}.log" >&2 + fail "top-level CMake failed for the wrong reason with variable-only RapidJSON package" + fi + + rm -rf "$tmpdir" +} + +test_top_level_uses_rapidjson_target_directly() { + local cmakelists="${REPO_ROOT}/CMakeLists.txt" + + if [[ -e "${REPO_ROOT}/cmake/AbacusRapidJSON.cmake" ]]; then + fail "cmake/AbacusRapidJSON.cmake still exists; RapidJSON config should provide the target" + fi + + if ! grep -Fq "find_package(RapidJSON CONFIG REQUIRED)" "$cmakelists"; then + fail "top-level CMakeLists.txt does not call find_package(RapidJSON CONFIG REQUIRED)" + fi + + if ! grep -Fq "target_link_libraries(abacus_external_deps INTERFACE RapidJSON)" "$cmakelists"; then + fail "top-level CMakeLists.txt does not link abacus_external_deps to RapidJSON target" + fi + + if grep -Fq "include(cmake/AbacusRapidJSON.cmake)" "$cmakelists"; then + fail "top-level CMakeLists.txt still includes the RapidJSON compatibility helper" + fi +} + +test_aocc_build_script_does_not_override_rapidjson_dir() { + local script="${REPO_ROOT}/toolchain/build_abacus_aocc-aocl.sh" + if grep -Fq -- '-DRapidJSON_DIR=$RAPIDJSON' "$script"; then + fail "${script} still passes RapidJSON_DIR as the package prefix" + fi +} + +test_rapidjson_target_package_configures +test_variable_only_package_fails +test_top_level_rejects_variable_only_package +test_top_level_uses_rapidjson_target_directly +test_aocc_build_script_does_not_override_rapidjson_dir + +if [[ "$FAILURES" -ne 0 ]]; then + printf '%s RapidJSON CMake test(s) failed\n' "$FAILURES" >&2 + exit 1 +fi + +printf 'RapidJSON CMake tests passed\n' diff --git a/toolchain/tests/test_wrapper_failure_propagation.sh b/toolchain/tests/test_wrapper_failure_propagation.sh new file mode 100755 index 00000000000..5e33ebb2434 --- /dev/null +++ b/toolchain/tests/test_wrapper_failure_propagation.sh @@ -0,0 +1,72 @@ +#!/usr/bin/env bash +set -u + +REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" +TOOLCHAIN_DIR="${REPO_ROOT}/toolchain" +FAILURES=0 + +fail() { + printf 'FAIL: %s\n' "$*" >&2 + FAILURES=$((FAILURES + 1)) +} + +assert_file_contains() { + local file="$1" + local text="$2" + if ! grep -Fq "$text" "$file"; then + fail "${file} does not contain expected text: ${text}" + fi +} + +test_runner_preserves_command_failure() { + # shellcheck source=/dev/null + source "${TOOLCHAIN_DIR}/scripts/lib/wrapper_runner.sh" + + local tmpdir log status + tmpdir="$(mktemp -d)" + log="${tmpdir}/compile.log" + + run_toolchain_with_log "$log" bash -c 'printf "installer stdout\n"; exit 37' + status=$? + + if [[ "$status" -ne 37 ]]; then + fail "run_toolchain_with_log returned ${status}; expected 37" + fi + assert_file_contains "$log" "installer stdout" + + rm -rf "$tmpdir" +} + +test_wrappers_use_runner() { + local wrappers=( + "${TOOLCHAIN_DIR}/toolchain_gnu.sh" + "${TOOLCHAIN_DIR}/toolchain_intel.sh" + "${TOOLCHAIN_DIR}/toolchain_gcc-mkl.sh" + "${TOOLCHAIN_DIR}/toolchain_gcc-aocl.sh" + "${TOOLCHAIN_DIR}/toolchain_aocc-aocl.sh" + ) + + local wrapper + for wrapper in "${wrappers[@]}"; do + assert_file_contains "$wrapper" 'source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh"' + assert_file_contains "$wrapper" 'run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh' + + if grep -Eq '\|\s*tee[[:space:]]+compile\.log' "$wrapper"; then + fail "${wrapper} still contains a raw pipe to tee compile.log" + fi + + if grep -Eq '^exec[[:space:]]+\./install_abacus_toolchain_new\.sh' "$wrapper"; then + fail "${wrapper} still execs the installer directly" + fi + done +} + +test_runner_preserves_command_failure +test_wrappers_use_runner + +if [[ "$FAILURES" -ne 0 ]]; then + printf '%s wrapper failure propagation test(s) failed\n' "$FAILURES" >&2 + exit 1 +fi + +printf 'wrapper failure propagation tests passed\n' diff --git a/toolchain/toolchain_aocc-aocl.sh b/toolchain/toolchain_aocc-aocl.sh index bfc4b4bc1a2..83ad0a1c841 100755 --- a/toolchain/toolchain_aocc-aocl.sh +++ b/toolchain/toolchain_aocc-aocl.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -84,7 +87,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-amd="$WITH_AMD" \ --with-gcc="$WITH_GCC" \ --math-mode="$MATH_MODE" \ @@ -115,5 +118,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_gcc-aocl.sh b/toolchain/toolchain_gcc-aocl.sh index f77b533989c..1238defd361 100755 --- a/toolchain/toolchain_gcc-aocl.sh +++ b/toolchain/toolchain_gcc-aocl.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -81,7 +84,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-gcc="$WITH_GCC" \ --with-amd="$WITH_AMD" \ --math-mode="$MATH_MODE" \ @@ -111,5 +114,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_gcc-mkl.sh b/toolchain/toolchain_gcc-mkl.sh index bac479c38f7..df0fc04d108 100755 --- a/toolchain/toolchain_gcc-mkl.sh +++ b/toolchain/toolchain_gcc-mkl.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -84,7 +87,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-gcc="$WITH_GCC" \ --math-mode="$MATH_MODE" \ --mpi-mode="$MPI_MODE" \ @@ -114,5 +117,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_gnu.sh b/toolchain/toolchain_gnu.sh index a934fed0181..e297c0e453b 100755 --- a/toolchain/toolchain_gnu.sh +++ b/toolchain/toolchain_gnu.sh @@ -4,6 +4,10 @@ #SBATCH -n 16 #SBATCH -o compile.log #SBATCH -e compile.err + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -84,7 +88,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-gcc="$WITH_GCC" \ --with-intel="$WITH_INTEL" \ --with-amd="$WITH_AMD" \ @@ -119,5 +123,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@" diff --git a/toolchain/toolchain_intel.sh b/toolchain/toolchain_intel.sh index ab40cf55b2b..9f854a0b4a1 100755 --- a/toolchain/toolchain_intel.sh +++ b/toolchain/toolchain_intel.sh @@ -5,6 +5,9 @@ #SBATCH -o compile.log #SBATCH -e compile.err +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" +source "${SCRIPT_DIR}/scripts/lib/wrapper_runner.sh" + # Users can easily modify these parameters to customize the build # Before running this script, ensure you have loaded your system packages @@ -103,7 +106,7 @@ LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC) # ============================================================================ # Call the main installation script with configured parameters -exec ./install_abacus_toolchain_new.sh \ +run_toolchain_with_log compile.log ./install_abacus_toolchain_new.sh \ --with-intel="$WITH_INTEL" \ --with-gcc="$WITH_GCC" \ --math-mode="$MATH_MODE" \ @@ -136,5 +139,4 @@ exec ./install_abacus_toolchain_new.sh \ ${PACK_RUN_MODE:+$([ "$PACK_RUN_MODE" = "yes" ] && echo "--pack-run")} \ ${ENABLE_CUDA:+--enable-cuda} \ ${GPU_VERSION:+--gpu-ver="$GPU_VERSION"} \ - "$@" \ - | tee compile.log + "$@"