randomconfig fixes
[oweals/busybox.git] / Makefile.flags
index 9f77674baa1966fce1e5aee5d2ae8868bad55ae1..cff935ff57decab7435bc5eb10574abc2f714dc5 100644 (file)
@@ -15,7 +15,7 @@ CPPFLAGS += \
        -include include/autoconf.h \
        -D_GNU_SOURCE -DNDEBUG \
        $(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
-       -D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
+       -DBB_VER=$(squote)$(quote)$(BB_VER)$(quote)$(squote)
 
 CFLAGS += $(call cc-option,-Wall,)
 CFLAGS += $(call cc-option,-Wshadow,)
@@ -47,12 +47,28 @@ endif
 # gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
 CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
 
-CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
+ifneq ($(CC),clang)
+# "clang-9: warning: optimization flag '-finline-limit=0' is not supported
+CFLAGS += $(call cc-option,-finline-limit=0,)
+endif
+
+CFLAGS += $(call cc-option,-fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections,)
 # -fno-guess-branch-probability: prohibit pseudo-random guessing
 # of branch probabilities (hopefully makes bloatcheck more stable):
 CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
-CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
-CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
+CFLAGS += $(call cc-option,-funsigned-char,)
+
+ifneq ($(CC),clang)
+# "clang-9: warning: argument unused during compilation: '-static-libgcc'"
+CFLAGS += $(call cc-option,-static-libgcc,)
+endif
+
+CFLAGS += $(call cc-option,-falign-functions=1,)
+ifneq ($(CC),clang)
+# "clang-9: warning: optimization flag '-falign-jumps=1' is not supported" (and same for other two)
+CFLAGS += $(call cc-option,-falign-jumps=1 -falign-labels=1 -falign-loops=1,)
+endif
+
 # Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller busybox binary):
 CFLAGS += $(call cc-option,-fno-unwind-tables,)
 CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
@@ -60,6 +76,11 @@ CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
 # (try disabling this and comparing assembly, it's instructive)
 CFLAGS += $(call cc-option,-fno-builtin-printf,)
 
+# clang-9 does not like "str" + N and "if (CONFIG_ITEM && cond)" constructs
+ifeq ($(CC),clang)
+CFLAGS += $(call cc-option,-Wno-string-plus-int -Wno-constant-logical-operand)
+endif
+
 # FIXME: These warnings are at least partially to be concerned about and should
 # be fixed..
 #CFLAGS += $(call cc-option,-Wconversion,)
@@ -75,6 +96,11 @@ else
 CFLAGS += $(call cc-option,-Os,$(call cc-option,-O2,))
 endif
 endif
+ifeq ($(CONFIG_DEBUG_SANITIZE),y)
+CFLAGS += $(call cc-option,-fsanitize=address,)
+CFLAGS += $(call cc-option,-fsanitize=leak,)
+CFLAGS += $(call cc-option,-fsanitize=undefined,)
+endif
 
 # If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
 ARCH_FPIC ?= -fpic
@@ -124,10 +150,12 @@ endif
 # fall back to using a temp file:
 CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >crypttest.c; $(CC) $(CFLAGS) -lcrypt -o /dev/null crypttest.c >/dev/null 2>&1 && echo "y"; rm crypttest.c)
 ifeq ($(CRYPT_AVAILABLE),y)
-LDLIBS += m crypt
+LDLIBS += m rt crypt
 else
-LDLIBS += m
+LDLIBS += m rt
 endif
+# libm may be needed for dc, awk, ntpd
+# librt may be needed for clock_gettime()
 
 # libpam may use libpthread, libdl and/or libaudit.
 # On some platforms that requires an explicit -lpthread, -ldl, -laudit.
@@ -151,6 +179,10 @@ CPPFLAGS += $(SELINUX_CFLAGS)
 LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
 endif
 
+ifeq ($(CONFIG_FEATURE_NSLOOKUP_BIG),y)
+LDLIBS += resolv
+endif
+
 ifeq ($(CONFIG_EFENCE),y)
 LDLIBS += efence
 endif