diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-18 22:30:53 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-18 22:31:14 +0200 |
| commit | 8bc74cde8f6bfb4b264bb3399681e7e04ec1e703 (patch) | |
| tree | 3ce96d4760a5500b52755c8bfa062e233ec76c38 /configure.sh | |
| parent | 9f3fde47cd1a5a8881f7cbcf15218f2c3c875341 (diff) | |
| download | nissy-core-8bc74cde8f6bfb4b264bb3399681e7e04ec1e703.tar.gz nissy-core-8bc74cde8f6bfb4b264bb3399681e7e04ec1e703.zip | |
Update to configuration script; C99 -> C11
Diffstat (limited to '')
| -rwxr-xr-x | configure.sh | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/configure.sh b/configure.sh index fcf2dce..e61a163 100755 --- a/configure.sh +++ b/configure.sh | |||
| @@ -1,5 +1,40 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # The following environment variables can be used to configure the build: | ||
| 4 | # | ||
| 5 | # CC="compiler" | ||
| 6 | # Specify the compiler to use. | ||
| 7 | # By default, cc will be used. | ||
| 8 | # The string "compiler" must be the name of an executable in $PATH. | ||
| 9 | # | ||
| 10 | # ARCH="architecture" | ||
| 11 | # You can use this variable to build for a different architecture, for example | ||
| 12 | # if you want to cross-compile or to use the portable version. | ||
| 13 | # By default, the build script will detect which architecture it is running on. | ||
| 14 | # The string "architecture" must be one of "AVX2", "NEON" or "PORTABLE". | ||
| 15 | # | ||
| 16 | # THREADS=n | ||
| 17 | # Choose how many threads to use for multi-threaded oerations. | ||
| 18 | # By default, 16 threads will be used (TODO: in the future this will be | ||
| 19 | # determined base on the system). | ||
| 20 | # The number n must be between 1 and 128. | ||
| 21 | # | ||
| 22 | # SANITIZE="option1,option2,..." | ||
| 23 | # Add the options "-fsanitize=option1", "-fsanitize=option2", ... to the | ||
| 24 | # compilation command when compiling in debug mode. | ||
| 25 | # By default, "-fsanitize=address" and "-fsanitize=undefined" will be used, | ||
| 26 | # if available. If this variable is set, the default is overridden. | ||
| 27 | # No check is performed on the given sanitizers, make sure that the ones you | ||
| 28 | # choose are available on your system and compatible with each other. | ||
| 29 | # | ||
| 30 | # Examples | ||
| 31 | # | ||
| 32 | # 1. Build using clang and 8 threads | ||
| 33 | # CC=clang THREADS=8 ./configure.sh && make | ||
| 34 | # | ||
| 35 | # 2. Build using thread and undefined behavior sanitizers when in debug mode | ||
| 36 | # SANITIZE="thread,undefined" ./configures && make | ||
| 37 | |||
| 3 | greparch() { | 38 | greparch() { |
| 4 | $CC -march=native -dM -E - </dev/null 2>/dev/null | grep "$1" | 39 | $CC -march=native -dM -E - </dev/null 2>/dev/null | grep "$1" |
| 5 | } | 40 | } |
| @@ -53,23 +88,33 @@ validatecc | |||
| 53 | validatethreads | 88 | validatethreads |
| 54 | validatearch | 89 | validatearch |
| 55 | 90 | ||
| 56 | STD="-std=c99" | 91 | STD="-std=c11" |
| 57 | WFLAGS="-pedantic -Wall -Wextra" | 92 | WFLAGS="-pedantic -Wall -Wextra" |
| 58 | WNOFLAGS="-Wno-unused-parameter -Wno-unused-function -Wno-unknown-pragmas" | 93 | WNOFLAGS="-Wno-unused-parameter -Wno-unused-function -Wno-unknown-pragmas" |
| 59 | 94 | ||
| 60 | [ "$ARCH" = "AVX2" ] && AVX="-mavx2" | 95 | [ "$ARCH" = "AVX2" ] && AVX="-mavx2" |
| 61 | [ -n "$(grepsan address)" ] && ADDR="-fsanitize=address" | 96 | |
| 62 | [ -n "$(grepsan undefined)" ] && UNDEF="-fsanitize=undefined" | 97 | if [ -n "$SANITIZE" ]; then |
| 63 | SAN="$ADDR $UNDEF" | 98 | # Use the user-specified comma-separated sanitizers |
| 99 | for san in $(echo "$SANITIZE" | tr ',' '\n'); do | ||
| 100 | SAN="$SAN -fsanitize=$san" | ||
| 101 | done | ||
| 102 | else | ||
| 103 | # No sanitizer specified, use "address" and "undefined" if present | ||
| 104 | [ -n "$(grepsan address)" ] && ADDR="-fsanitize=address" | ||
| 105 | [ -n "$(grepsan undefined)" ] && UNDEF="-fsanitize=undefined" | ||
| 106 | SAN="$ADDR $UNDEF" | ||
| 107 | fi | ||
| 64 | LIBS="-lpthread" | 108 | LIBS="-lpthread" |
| 65 | 109 | ||
| 66 | CFLAGS="$STD $LIBS $WFLAGS $WNOFLAGS $AVX -O3" | 110 | CFLAGS="$STD $LIBS $WFLAGS $WNOFLAGS $AVX -O3" |
| 67 | DBGFLAGS="$STD $LIBS $WFLAGS $WNOFLAGS $SAN $AVX -g3 -DDEBUG" | 111 | DBGFLAGS="$STD $LIBS $WFLAGS $WNOFLAGS $SAN $AVX -g3 -DDEBUG" |
| 68 | MACROS="-DTHREADS=$THREADS -D$ARCH" | 112 | MACROS="-DTHREADS=$THREADS -D$ARCH" |
| 69 | 113 | ||
| 114 | echo "Compiler: $CC" | ||
| 70 | echo "Selected architecture: $ARCH" | 115 | echo "Selected architecture: $ARCH" |
| 71 | echo "Number of threads: $THREADS" | 116 | echo "Number of threads: $THREADS" |
| 72 | echo "Compiler: $CC" | 117 | echo "Sanitizer options (debug build only): $SAN" |
| 73 | 118 | ||
| 74 | { | 119 | { |
| 75 | echo "ARCH = $ARCH"; | 120 | echo "ARCH = $ARCH"; |
