From 479df41f06606ff72ec5e4013cf021fdbf8c052b Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Tue, 6 Feb 2024 12:45:27 +0100 Subject: [PATCH 1/6] e9compile: fix colors --- e9compile.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e9compile.sh b/e9compile.sh index 0f2e3b3..be0999f 100755 --- a/e9compile.sh +++ b/e9compile.sh @@ -17,11 +17,11 @@ if [ -t 1 ] then - RED="\033[31m" - GREEN="\033[32m" - YELLOW="\033[33m" - BOLD="\033[1m" - OFF="\033[0m" + RED=$'\033[31m' + GREEN=$'\033[32m' + YELLOW=$'\033[33m' + BOLD=$'\033[1m' + OFF=$'\033[0m' else RED= GREEN= From 371c34ff8fc52548b0b7cfc0c00adccd6ec8bb28 Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Tue, 6 Feb 2024 12:44:43 +0100 Subject: [PATCH 2/6] e9compile: use string arrays --- e9compile.sh | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/e9compile.sh b/e9compile.sh index be0999f..aaf057a 100755 --- a/e9compile.sh +++ b/e9compile.sh @@ -61,15 +61,17 @@ DIRNAME=`dirname $1` shift -CFLAGS="-fno-stack-protector -fno-builtin -fno-exceptions \ - -fpie -O2 -Wno-unused-function -U_FORTIFY_SOURCE \ - -mno-mmx -mno-sse -mno-avx -mno-avx2 -mno-avx512f -msoft-float \ - -mstringop-strategy=loop -fno-tree-vectorize -fomit-frame-pointer \ - -I examples/" -COMPILE="$CC $CFLAGS -c -Wall $@ \"$DIRNAME/$BASENAME.$EXTENSION\"" +CFLAGS=( + -fno-stack-protector -fno-builtin -fno-exceptions + -fpie -O2 -Wno-unused-function -U_FORTIFY_SOURCE + -mno-mmx -mno-sse -mno-avx -mno-avx2 -mno-avx512f -msoft-float + -mstringop-strategy=loop -fno-tree-vectorize -fomit-frame-pointer + -I examples/ +) +COMPILE=("$CC" "${CFLAGS[@]}" -c -Wall "$@" "$DIRNAME/$BASENAME.$EXTENSION") -echo "$COMPILE" | xargs -if ! eval "$COMPILE" +echo "${COMPILE[@]}" +if ! "${COMPILE[@]}" then echo >&2 echo "${RED}error${OFF}: compilation of (${YELLOW}$BASENAME${OFF}) failed" >&2 @@ -77,17 +79,19 @@ then exit 1 fi -CFLAGS="-pie -nostdlib \ - -Wl,-z -Wl,max-page-size=4096 \ - -Wl,-z -Wl,norelro \ - -Wl,-z -Wl,stack-size=0 \ - -Wl,--export-dynamic \ - -Wl,--entry=0x0 \ - -Wl,--strip-all" -COMPILE="$CC \"$BASENAME.o\" -o \"$BASENAME\" $CFLAGS" +CFLAGS=( + -pie -nostdlib + -Wl,-z -Wl,max-page-size=4096 + -Wl,-z -Wl,norelro + -Wl,-z -Wl,stack-size=0 + -Wl,--export-dynamic + -Wl,--entry=0x0 + -Wl,--strip-all +) +COMPILE=("$CC" "$BASENAME.o" -o "$BASENAME" "${CFLAGS[@]}") -echo "$COMPILE" | xargs -if ! eval "$COMPILE" +echo "${COMPILE[@]}" +if ! "${COMPILE[@]}" then echo >&2 echo "${RED}error${OFF}: linking (${YELLOW}$BASENAME${OFF}) failed" >&2 From 473d978d26a141236b341e85e5a6ec09c5eed8a9 Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Tue, 6 Feb 2024 13:06:22 +0100 Subject: [PATCH 3/6] e9compile: use $(...) --- e9compile.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e9compile.sh b/e9compile.sh index aaf057a..bfdc11a 100755 --- a/e9compile.sh +++ b/e9compile.sh @@ -56,8 +56,8 @@ case "$1" in exit 1 ;; esac -BASENAME=`basename $1 .$EXTENSION` -DIRNAME=`dirname $1` +BASENAME="$(basename "$1" .$EXTENSION)" +DIRNAME="$(dirname "$1")" shift @@ -99,7 +99,7 @@ then exit 1 fi -RELOCS=`readelf -r "$BASENAME" | head -n 10 | grep 'R_X86_64_'` +RELOCS=$(readelf -r "$BASENAME" | head -n 10 | grep 'R_X86_64_') if [ ! -z "$RELOCS" ] then echo >&2 @@ -126,7 +126,7 @@ fi if [ "$NO_SIMD_CHECK" = "" ] then - SIMD=`objdump -d "$BASENAME" | grep -E '%(x|y|z)mm[0-9]' | head -n 10` + SIMD=$(objdump -d "$BASENAME" | grep -E '%(x|y|z)mm[0-9]' | head -n 10) if [ ! -z "$SIMD" ] then echo >&2 From ad87eba11db595f56f27d1f469ed7ac35e613b14 Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Tue, 6 Feb 2024 13:06:49 +0100 Subject: [PATCH 4/6] e9compile: fix vars --- e9compile.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/e9compile.sh b/e9compile.sh index bfdc11a..918f651 100755 --- a/e9compile.sh +++ b/e9compile.sh @@ -51,11 +51,12 @@ case "$1" in ;; *) echo >&2 - echo "${RED}error${OFF}: file $1 must have a .c/.cpp/.s extension" >&2 + echo "${RED}error${OFF}: file ${1@Q} must have a .c/.cpp/.s extension" >&2 echo >&2 exit 1 ;; esac +SOURCE="$1" BASENAME="$(basename "$1" .$EXTENSION)" DIRNAME="$(dirname "$1")" @@ -68,7 +69,7 @@ CFLAGS=( -mstringop-strategy=loop -fno-tree-vectorize -fomit-frame-pointer -I examples/ ) -COMPILE=("$CC" "${CFLAGS[@]}" -c -Wall "$@" "$DIRNAME/$BASENAME.$EXTENSION") +COMPILE=("$CC" "${CFLAGS[@]}" -c -Wall "$@" "$SOURCE") echo "${COMPILE[@]}" if ! "${COMPILE[@]}" From 6048a213a7ac608fc26a8abec2ebf308215fab34 Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Tue, 6 Feb 2024 13:12:40 +0100 Subject: [PATCH 5/6] e9compile: add var include_examples_path --- e9compile.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/e9compile.sh b/e9compile.sh index 918f651..43d4f18 100755 --- a/e9compile.sh +++ b/e9compile.sh @@ -15,6 +15,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +include_examples_path="examples/" + if [ -t 1 ] then RED=$'\033[31m' @@ -67,7 +69,7 @@ CFLAGS=( -fpie -O2 -Wno-unused-function -U_FORTIFY_SOURCE -mno-mmx -mno-sse -mno-avx -mno-avx2 -mno-avx512f -msoft-float -mstringop-strategy=loop -fno-tree-vectorize -fomit-frame-pointer - -I examples/ + -I "$include_examples_path" ) COMPILE=("$CC" "${CFLAGS[@]}" -c -Wall "$@" "$SOURCE") From f79badefe4fc12a14571604c70b681acc2786248 Mon Sep 17 00:00:00 2001 From: Milan Hauth Date: Tue, 6 Feb 2024 14:06:47 +0100 Subject: [PATCH 6/6] e9compile: remove include_examples_path [FIXUP] --- e9compile.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/e9compile.sh b/e9compile.sh index 43d4f18..d749d1a 100755 --- a/e9compile.sh +++ b/e9compile.sh @@ -15,8 +15,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -include_examples_path="examples/" - if [ -t 1 ] then RED=$'\033[31m' @@ -69,7 +67,6 @@ CFLAGS=( -fpie -O2 -Wno-unused-function -U_FORTIFY_SOURCE -mno-mmx -mno-sse -mno-avx -mno-avx2 -mno-avx512f -msoft-float -mstringop-strategy=loop -fno-tree-vectorize -fomit-frame-pointer - -I "$include_examples_path" ) COMPILE=("$CC" "${CFLAGS[@]}" -c -Wall "$@" "$SOURCE")