mirror of
https://github.com/pi-hole/FTL.git
synced 2024-10-26 16:52:18 +02:00
Make Makefile a bit more readable, rearrange gcc-8 extra warning description to where they belong (inside the if)
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -29,6 +29,7 @@ GIT_TAG := $(shell git describe --tags --abbrev=0)
|
||||
# Is compiler at least gcc version 8? We cannot do ifgt in Makefile, so we use the shell expr command
|
||||
GCCVERSION8 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 8)
|
||||
|
||||
# Code hardening and debugging improvements
|
||||
# -fstack-protector-strong: The program will be resistant to having its stack overflowed
|
||||
# -Wp,-D_FORTIFY_SOURCE=2 and -O1 or higher: This causes certain unsafe glibc functions to be replaced with their safer counterparts
|
||||
# -Wl,-z,relro: reduces the possible areas of memory in a program that can be used by an attacker that performs a successful memory corruption exploit
|
||||
@@ -43,15 +44,18 @@ GCCVERSION8 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 8)
|
||||
# -Wl,-z,relro: Read-only segments after relocation
|
||||
HARDENING_FLAGS=-fstack-protector-strong -Wp,-D_FORTIFY_SOURCE=2 -O3 -Wl,-z,relro,-z,now -pie -fPIE -fexceptions -fasynchronous-unwind-tables -Wl,-z,defs -Wl,-z,now -Wl,-z,relro
|
||||
DEBUG_FLAGS=-rdynamic -fno-omit-frame-pointer
|
||||
|
||||
# -DSQLITE_OMIT_LOAD_EXTENSION: This option omits the entire extension loading mechanism from SQLite, including sqlite3_enable_load_extension() and sqlite3_load_extension() interfaces. (needs -ldl linking option, otherwise)
|
||||
# -DSQLITE_DEFAULT_MEMSTATUS=0: This setting causes the sqlite3_status() interfaces that track memory usage to be disabled. This helps the sqlite3_malloc() routines run much faster, and since SQLite uses sqlite3_malloc() internally, this helps to make the entire library faster.
|
||||
# -DSQLITE_OMIT_DEPRECATED: Omitting deprecated interfaces and features will not help SQLite to run any faster. It will reduce the library footprint, however. And it is the right thing to do.
|
||||
# -DSQLITE_OMIT_PROGRESS_CALLBACK: The progress handler callback counter must be checked in the inner loop of the bytecode engine. By omitting this interface, a single conditional is removed from the inner loop of the bytecode engine, helping SQL statements to run slightly faster.
|
||||
SQLITEFLAGS=-DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_MEMORYDB
|
||||
|
||||
# -Wall: This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros. This also enables some language-specific warnings described in C++ Dialect Options and Objective-C and Objective-C++ Dialect Options.
|
||||
# -Wextra: This enables some extra warning flags that are not enabled by -Wall.
|
||||
# -Wno-unused-parameter: Disable warning for unused parameters. For threads that don't need arguments, we still have to provide a void* args which is then unused.
|
||||
WARNFLAGS=-Wall -Wextra -Wno-unused-parameter
|
||||
|
||||
# Extra warning flags we apply only to the FTL part of the code (used not for foreign code such as dnsmasq and SQLite3)
|
||||
# -Werror: Halt on any warnings, useful for enforcing clean code without any warnings (we use it only for our code part)
|
||||
# -Waddress: Warn about suspicious uses of memory addresses
|
||||
@@ -76,18 +80,20 @@ WARNFLAGS=-Wall -Wextra -Wno-unused-parameter
|
||||
# -Wredundant-decls: Warn if anything is declared more than once in the same scope
|
||||
# -Winline: Warn if a function that is declared as inline cannot be inlined
|
||||
ifeq "$(GCCVERSION8)" "1"
|
||||
# -Wduplicated-cond: Warn about duplicated conditions in an if-else-if chain
|
||||
# -Wduplicated-branches: Warn when an if-else has identical branches
|
||||
# -Wcast-align=strict: Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" is cast to an "int *" regardless of the target machine.
|
||||
# -Wlogical-not-parentheses: Warn about logical not used on the left hand side operand of a comparison
|
||||
EXTRAWARNGCC8=-Wduplicated-cond -Wduplicated-branches -Wcast-align=strict -Wlogical-not-parentheses -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn -Wsuggest-attribute=malloc -Wsuggest-attribute=format -Wsuggest-attribute=cold
|
||||
else
|
||||
EXTRAWARNGCC8=
|
||||
endif
|
||||
# -Wduplicated-cond: Warn about duplicated conditions in an if-else-if chain
|
||||
# -Wduplicated-branches: Warn when an if-else has identical branches
|
||||
# -Wcast-align=strict: Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" is cast to an "int *" regardless of the target machine.
|
||||
# -Wlogical-not-parentheses: Warn about logical not used on the left hand side operand of a comparison
|
||||
EXTRAWARN=-Werror -Waddress -Wlogical-op -Wmissing-field-initializers -Woverlength-strings -Wformat -Wformat-nonliteral -Wuninitialized -Wswitch-enum -Wshadow \
|
||||
-Wfloat-equal -Wunsafe-loop-optimizations -funsafe-loop-optimizations -Wbad-function-cast -Wwrite-strings -Wparentheses -Wlogical-op -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Winline $(EXTRAWARNGCC8)
|
||||
|
||||
# -FILE_OFFSET_BITS=64: used by stat(). Avoids problems with files > 2 GB on 32bit machines
|
||||
CCFLAGS=-std=gnu11 -I$(IDIR) $(WARNFLAGS) -D_FILE_OFFSET_BITS=64 $(HARDENING_FLAGS) $(DEBUG_FLAGS) $(CFLAGS) $(SQLITEFLAGS)
|
||||
|
||||
# for FTL we need the pthread library
|
||||
# for dnsmasq we need the nettle crypto library and the gmp maths library
|
||||
# We link the two libraries statically. Although this increases the binary file size by about 1 MB, it saves about 5 MB of shared libraries and makes deployment easier
|
||||
|
||||
Reference in New Issue
Block a user