X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=Makefile.flags;h=65021de25ffb3d7c2600d2be7fd3f57e4a8622b8;hb=f4d0f4e7a9715375bfa4bcfb7ce26a967c78ca9e;hp=e77c0e5277ea81ea126160de3d0170ef5970e716;hpb=9b80b903c7fd2120a72de287fe6b0920e6d3c8ff;p=oweals%2Fbusybox.git diff --git a/Makefile.flags b/Makefile.flags index e77c0e527..65021de25 100644 --- a/Makefile.flags +++ b/Makefile.flags @@ -56,6 +56,9 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 # 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,) +# No automatic printf->puts,putchar conversions +# (try disabling this and comparing assembly, it's instructive) +CFLAGS += $(call cc-option,-fno-builtin-printf,) # FIXME: These warnings are at least partially to be concerned about and should # be fixed.. @@ -72,12 +75,23 @@ 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 ARCH_FPIE ?= -fpie ARCH_PIE ?= -pie +# Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES)) +define pkg_check_modules +$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2)) +$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2)) +endef + ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y) # on i386: 14% smaller libbusybox.so # (code itself is 9% bigger, we save on relocs/PLT/GOT) @@ -89,6 +103,7 @@ endif ifeq ($(CONFIG_STATIC),y) CFLAGS_busybox += -static +PKG_CONFIG_FLAGS += --static endif ifeq ($(CONFIG_PIE),y) @@ -119,19 +134,26 @@ else LDLIBS += m endif +# libpam may use libpthread, libdl and/or libaudit. +# On some platforms that requires an explicit -lpthread, -ldl, -laudit. +# However, on *other platforms* it fails when some of those flags +# given needlessly. On some systems, crypt needs pthread. +# +# I even had a system where a runtime test for pthread +# (similar to CRYPT_AVAILABLE test above) was not reliable. +# +# Do not propagate this mess by adding libraries to CONFIG_PAM/CRYPT_AVAILABLE blocks. +# Add libraries you need to CONFIG_EXTRA_LDLIBS instead. + ifeq ($(CONFIG_PAM),y) -# libpam uses libpthread, so for static builds busybox must be linked to -# libpthread. On some platforms that requires an explicit -lpthread, so -# it should be in LDLIBS. For non-static builds, scripts/trylink will -# take care of removing -lpthread if possible. (Not bothering to check -# CONFIG_STATIC because even in a non-static build it could be that the -# only libpam available is libpam.a, so -lpthread could still be -# needed.) -LDLIBS += pam pam_misc pthread +LDLIBS += pam pam_misc endif ifeq ($(CONFIG_SELINUX),y) -LDLIBS += selinux sepol +SELINUX_PC_MODULES = libselinux libsepol +$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES))) +CPPFLAGS += $(SELINUX_CFLAGS) +LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%)) endif ifeq ($(CONFIG_EFENCE),y) @@ -153,7 +175,7 @@ SKIP_STRIP = y endif ifneq ($(CONFIG_EXTRA_LDFLAGS),) -EXTRA_LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS))) +LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS))) #")) endif