commit e419ca484e62f2771766a87bfaedf75a5f99c2b1
parent b17411249b17133f35833c202e6c2e4bf43b3298
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date: Thu, 5 Sep 2024 10:17:39 +0200
Changed build options TYPE -> ARCH
Diffstat:
3 files changed, 19 insertions(+), 9 deletions(-)
diff --git 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
@@ -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
@@ -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";