-
Notifications
You must be signed in to change notification settings - Fork 1k
Pedantic fixes to build system (configure, Makefile)
#8933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
1e30a02
a3c48e1
f3b62f5
5b6c34d
5e0cff4
500eeec
c6aa5c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,12 +134,12 @@ check_command() | |
| name="$1" | ||
| shift 1 | ||
|
|
||
| echo -n "checking for $name... " | ||
| printf 'checking for %s... ' "${name}" >&2 | ||
| if "$@" >/dev/null 2>&1 </dev/null; then | ||
| echo 'found' | ||
| echo 'found' >&2 | ||
| return 0 | ||
| fi | ||
| echo 'not found' | ||
| echo 'not found' >&2 | ||
| return 1 | ||
| } | ||
|
|
||
|
|
@@ -170,10 +170,14 @@ set_defaults() | |
| # which matters since you might explicitly set of these blank. | ||
| PREFIX=${PREFIX:-/usr/local} | ||
| CC=${CC:-cc} | ||
| # A more compact way of setting the default value of a variable. | ||
| # Similar to the above, ":=" means assign if empty or unset; "=" means assign only if unset. | ||
| # The quotes suppress the globbing that would otherwise occur after variable expansion. | ||
| : "${CPPFLAGS=-std=gnu11}" | ||
| # Detect macOS and use appropriate debug flags for libbacktrace compatibility | ||
| if [ "$(uname -s)" = "Darwin" ]; then | ||
| # Always override to avoid DWARF 5 | ||
| CDEBUGFLAGS="-std=gnu11 -g -gdwarf-4 -fno-standalone-debug -fstack-protector-strong" | ||
| CDEBUGFLAGS="-g -gdwarf-4 -fno-standalone-debug -fstack-protector-strong" | ||
| # Set SDKROOT for macOS | ||
| SDKROOT="$(xcrun --sdk macosx --show-sdk-path)" | ||
|
|
||
|
|
@@ -182,7 +186,7 @@ set_defaults() | |
| echo "Warning: dsymutil not found. Install Xcode Command Line Tools for better debug support." | ||
| fi | ||
| else | ||
| CDEBUGFLAGS=${CDEBUGFLAGS--std=gnu11 -g -fstack-protector-strong} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some build systems put the |
||
| CDEBUGFLAGS=${CDEBUGFLAGS--g -fstack-protector-strong} | ||
| fi | ||
| DEBUGBUILD=${DEBUGBUILD:-0} | ||
| COMPAT=${COMPAT:-1} | ||
|
|
@@ -223,7 +227,7 @@ have_function_sections() | |
| TMPCFILE=$CONFIG_VAR_FILE.$$.c | ||
| TMPOBJFILE=$CONFIG_VAR_FILE.$$.o | ||
|
|
||
| echo "int foo(void); int foo(void) { return 0; }" > $TMPCFILE | ||
| echo "int main(void); int main(void) { return 0; }" > $TMPCFILE | ||
| # We *want* this to fail if we get a warning, hence use -Werror. | ||
| $1 $2 -Werror -ffunction-sections -Wl,--gc-sections $TMPCFILE -o $TMPOBJFILE | ||
| } | ||
|
|
@@ -236,8 +240,10 @@ usage() | |
| set_defaults | ||
| DEFAULT_COPTFLAGS="$(default_coptflags $DEBUGBUILD)" | ||
| # We assume we have a modern gcc. | ||
| DEFAULT_CWARNFLAGS="$(default_cwarnflags ""$DEFAULT_COPTFLAGS"" 1 1 ""$DEBUGBUILD"")" | ||
| DEFAULT_CWARNFLAGS="$(default_cwarnflags "$DEFAULT_COPTFLAGS" 1 1 "$DEBUGBUILD")" | ||
| usage_with_default "CC" "$CC" | ||
| usage_with_default "CPPFLAGS" "$CPPFLAGS" | ||
| usage_with_default "CFLAGS" "$CFLAGS" | ||
| usage_with_default "CWARNFLAGS" "$DEFAULT_CWARNFLAGS" | ||
| usage_with_default "COPTFLAGS" "$DEFAULT_COPTFLAGS" | ||
| usage_with_default "CDEBUGFLAGS" "$CDEBUGFLAGS" | ||
|
|
@@ -277,9 +283,9 @@ usage() | |
| add_var() | ||
| { | ||
| if [ -n "$2" ]; then | ||
| echo "Setting $1... $2" | ||
| echo "Setting $1... $2" >&2 | ||
| else | ||
| echo "$1 not found" | ||
| echo "$1 not found" >&2 | ||
| fi | ||
| echo "$1=$2" >> $CONFIG_VAR_FILE.$$ | ||
| [ -z "$3" ] || echo "#define $1 $2" >> "$3" | ||
|
|
@@ -311,6 +317,8 @@ for opt in "$@"; do | |
| ;; | ||
| CC=*) CC="${opt#CC=}";; | ||
| CONFIGURATOR_CC=*) CONFIGURATOR_CC="${opt#CONFIGURATOR_CC=}";; | ||
| CPPFLAGS=*) CPPFLAGS="${opt#CPPFLAGS=}";; | ||
| CFLAGS=*) CFLAGS="${opt#CFLAGS=}";; | ||
| CWARNFLAGS=*) CWARNFLAGS="${opt#CWARNFLAGS=}";; | ||
| CDEBUGFLAGS=*) CDEBUGFLAGS="${opt#CDEBUGFLAGS=}";; | ||
| COPTFLAGS=*) COPTFLAGS="${opt#COPTFLAGS=}";; | ||
|
|
@@ -334,10 +342,10 @@ for opt in "$@"; do | |
| --disable-fuzzing) FUZZING=0;; | ||
| --enable-rust) RUST=1;; | ||
| --disable-rust) RUST=0;; | ||
| --help|-h) usage;; | ||
| --help|-h) usage >&2;; | ||
| *) | ||
| echo "Unknown option '$opt'" >&2 | ||
| usage | ||
| usage >&2 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
@@ -347,7 +355,7 @@ set_defaults | |
|
|
||
| if [ "$ASAN" = "1" ]; then | ||
| if [ "$VALGRIND" = "1" ]; then | ||
| echo "Address sanitizer (ASAN) and valgrind cannot be enabled at the same time" | ||
| echo "Address sanitizer (ASAN) and valgrind cannot be enabled at the same time" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
|
|
@@ -381,16 +389,16 @@ else | |
| fi | ||
|
|
||
| # We assume warning flags don't affect congfigurator that much! | ||
| echo -n "Compiling $CONFIGURATOR..." | ||
| printf 'Compiling %s...' "${CONFIGURATOR}" >&2 | ||
| $CC ${CWARNFLAGS-$BASE_WARNFLAGS} $CDEBUGFLAGS $COPTFLAGS $LDFLAGS -o $CONFIGURATOR $CONFIGURATOR.c | ||
| echo "done" | ||
| echo "done" >&2 | ||
|
|
||
| if [ "$CLANG_COVERAGE" = "1" ]; then | ||
| case "$CC" in | ||
| (*"clang"*) | ||
| ;; | ||
| (*) | ||
| echo "Clang coverage requires building with CC=clang." | ||
| echo "Clang coverage requires building with CC=clang." >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
@@ -401,7 +409,7 @@ if [ "$FUZZING" = "1" ]; then | |
| (*"clang"*) | ||
| ;; | ||
| (*) | ||
| echo "Fuzzing is currently only supported with clang." | ||
| echo "Fuzzing is currently only supported with clang." >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
@@ -607,6 +615,8 @@ fi | |
| add_var PREFIX "$PREFIX" | ||
| add_var CC "$CC" | ||
| add_var CONFIGURATOR_CC "$CONFIGURATOR_CC" | ||
| add_var CPPFLAGS "$CPPFLAGS" | ||
| add_var CFLAGS "$CFLAGS" | ||
| add_var CWARNFLAGS "$CWARNFLAGS" | ||
| add_var CDEBUGFLAGS "$CDEBUGFLAGS" | ||
| add_var COPTFLAGS "$COPTFLAGS" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should also switch the
$(ALL_FUZZ_TARGETS):rule to$(LINK.c), or why fuzz targets should stay on $(LINK.o)? I mean$(ALL_FUZZ_TARGETS):rule still uses$(LINK.o).LINK.odoes not carry$(CFLAGS)/$(CPPFLAGS), whileLINK.cdoes. What do you think??There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. There was also one in
tools/Makefile. Fixed both in 1f9cc13.