From e419ca484e62f2771766a87bfaedf75a5f99c2b1 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Thu, 5 Sep 2024 10:17:39 +0200 Subject: Changed build options TYPE -> ARCH --- Makefile | 8 ++++---- README.md | 2 +- configure.sh | 18 ++++++++++++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 0b7204e..8ec635c 100644 --- a/Makefile +++ b/Makefile @@ -3,19 +3,19 @@ include config.mk all: cube.o debugcube.o cube.s: clean - ${CC} -D${CUBETYPE} ${CFLAGS} -c -S -o cube.s src/nissy.c + ${CC} -D${ARCH} ${CFLAGS} -c -S -o cube.s src/nissy.c cube.o: clean - ${CC} -D${CUBETYPE} ${CFLAGS} -c -o cube.o src/nissy.c + ${CC} -D${ARCH} ${CFLAGS} -c -o cube.o src/nissy.c debugcube.o: clean - ${CC} -D${CUBETYPE} ${DBGFLAGS} -c -o debugcube.o src/nissy.c + ${CC} -D${ARCH} ${DBGFLAGS} -c -o debugcube.o src/nissy.c clean: rm -rf *.o run test: debugcube.o - CC="${CC} -D${CUBETYPE} ${DBGFLAGS}" ./test/test.sh + CC="${CC} -D${ARCH} ${DBGFLAGS}" ./test/test.sh tool: cube.o mkdir -p tools/results diff --git a/README.md b/README.md index 049c31d..d0ab136 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ incomplete. To compile correctly on these processors (e.g. Mac M1/M2/M3) you need to manually disable optimizations: ``` -$ TYPE="" ./configure.sh # Can be combined with CC=... +$ ARCH="PORTABLE" ./configure.sh # Can be combined with CC=... ``` Once the configuration is done, you can build with make diff --git a/configure.sh b/configure.sh index e12dc06..2b68478 100755 --- a/configure.sh +++ b/configure.sh @@ -12,15 +12,25 @@ detectsan() { [ -n "$(detectarch __AVX2__)" ] && detected="AVX2" [ -n "$(detectarch __ARM_NEON)" ] && detected="NEON" +[ -z "$detected" ] && detected="PORTABLE" -TYPE=${TYPE-"$detected"} +ARCH=${ARCH-"$detected"} + +case "$ARCH" in +AVX2|NEON|PORTABLE) + ;; +*) + echo "Error: architecture $ARCH not supported" + exit 1 + ;; +esac STD="-std=c99" WFLAGS="-pedantic -Wall -Wextra" # -Wstringop-overflow seems to be causing problems when combined with -O3 # Someone else complained here: https://access.redhat.com/solutions/6755371 WNOFLAGS="-Wno-unused-parameter -Wno-unused-function -Wno-stringop-overflow" -[ "$TYPE" = "AVX2" ] && AVX="-mavx2" +[ "$ARCH" = "AVX2" ] && AVX="-mavx2" [ -n "$(detectsan address)" ] && ADDR="-fsanitize=address" [ -n "$(detectsan undefined)" ] && UNDEF="-fsanitize=undefined" SAN="$ADDR $UNDEF" @@ -29,11 +39,11 @@ LIBS="-lpthread" CFLAGS="$STD $LIBS $WFLAGS $WNOFLAGS $AVX -O3" DBGFLAGS="$STD $LIBS $WFLAGS $WNOFLAGS $SAN $AVX -g3 -DDEBUG" -echo "Cube type: CUBE_$TYPE" +echo "Selected architecture: $ARCH" echo "Compiler: ${CC:-cc}" { -echo "CUBETYPE = CUBE_$TYPE"; +echo "ARCH = $ARCH"; echo ""; echo "CFLAGS = $CFLAGS"; echo "DBGFLAGS = $DBGFLAGS"; -- cgit v1.3