From e9922f6e7b595c390ea48d1f645f760bb8606243 Mon Sep 17 00:00:00 2001 From: Johannes Pietrzyk <40020979+JPietrzykTUD@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:11:21 +0200 Subject: [PATCH] Bash cpuflags (#109) * added bash-only script to detect cpuid flags based on g++ and/or clang * wip bash script * unified arch detection * wip arch detection * dynamic executable detection * removed old regex * added lscpu detection as first-choice * Updated install_tsl.sh --------- Co-authored-by: Alexander Krause --- .github/workflows/install_tsl.sh | 10 ++++++++-- .github/workflows/release-tsl.yml | 1 + detect_flags.sh | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/install_tsl.sh b/.github/workflows/install_tsl.sh index a389637..f3ed264 100755 --- a/.github/workflows/install_tsl.sh +++ b/.github/workflows/install_tsl.sh @@ -9,9 +9,15 @@ WORK_DIR=$(pwd) curl -L "https://github.com/db-tu-dresden/TSL/releases/latest/download/tsl.tar.gz" -o ${TMP_DIR}/tsl.tar.gz -LSCPU_FLAGS_STRING=$(LANG=en;lscpu | grep 'Flags:' | sed -E 's/Flags:\s*//g' | sed -E 's/\s/:/g') +curl -L "https://github.com/db-tu-dresden/TSL/releases/latest/download/detect_flags.sh" -o ${TMP_DIR}/detect_flags.sh +chmod +x ${TMP_DIR}/detect_flags.sh + #create array from flags string -AVAIL_FLAGS=(${LSCPU_FLAGS_STRING//:/ }) +# AVAIL_FLAGS=($(${TMP_DIR}/detect_flags.sh)) +IFS=' ' read -r -a AVAIL_FLAGS <<< "$(${TMP_DIR}/detect_flags.sh)" +unset IFS + + #unpack tsl.conf tar -xf ${TMP_DIR}/tsl.tar.gz -C ${TMP_DIR} ${TAR_PREFIX_TSL_DIR}/tsl.conf diff --git a/.github/workflows/release-tsl.yml b/.github/workflows/release-tsl.yml index 75c8eb0..b5128c3 100644 --- a/.github/workflows/release-tsl.yml +++ b/.github/workflows/release-tsl.yml @@ -158,6 +158,7 @@ jobs: files: | ${{ github.workspace }}/tsl.tar.gz ${{ github.workspace }}/.github/workflows/install_tsl.sh + ${{ github.workspace }}/detect_flags.sh ${{ github.workspace }}/${{ steps.rpm.outputs.out }}/${{ steps.rpm.outputs.name}} ${{ github.workspace }}/${{ steps.deb.outputs.out }}/${{ steps.deb.outputs.name}} tag_name: ${{ inputs.tag-name }} diff --git a/detect_flags.sh b/detect_flags.sh index fc27a60..fabcdb7 100755 --- a/detect_flags.sh +++ b/detect_flags.sh @@ -29,7 +29,7 @@ function parse_flags { fi } -lscpu_exe=$(which lscpu) +lscpu_exe=$(which lscpu 2>/dev/null) if [[ ! -z ${lscpu_exe} && -f $lscpu_exe && -x $lscpu_exe ]]; then flags=$(eval LANG=en;lscpu|grep -i flags | tr ' ' '\n' | grep -v -E '^Flags:|^$' | sort -d | tr '\n' ' ') echo "$flags"