This works with Clang 4.0. It is broken with Clang 3.8, as the LTO build
ignore -mno-sse and "optimises" SSE instructions back into the binary.
Unknown with any other compilers.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
COMMON_FLAGS := -pipe -I$(ROOT)/include -I$(ROOT)/arch/x86/include -MMD -MP
+# Experimental LTO support. `make ... lto=y`
+COMMON_CFLAGS-$(lto) := -flto
+LDFLAGS-$(lto) := -flto -B /usr/lib/gold-ld
+
COMMON_AFLAGS := $(COMMON_FLAGS) -D__ASSEMBLY__
-COMMON_CFLAGS := $(COMMON_FLAGS) -Wall -Wextra -Werror -std=gnu99 -Wstrict-prototypes -O3 -g
+COMMON_CFLAGS := $(COMMON_FLAGS) $(COMMON_CFLAGS-y)
+COMMON_CFLAGS += -Wall -Wextra -Werror -std=gnu99 -Wstrict-prototypes -O3 -g
COMMON_CFLAGS += -fno-common -fno-asynchronous-unwind-tables -fno-strict-aliasing
COMMON_CFLAGS += -fno-stack-protector -ffreestanding
COMMON_CFLAGS += -mno-red-zone -mno-sse