@@ -16,6 +16,28 @@ CFLAGS += -D DEFAULT_STACK_ADDR=0xFFFFE000
16
16
# Set the default args starting address
17
17
CFLAGS += -D DEFAULT_ARGS_ADDR=0xFFFFF000
18
18
19
+ # Enable link-time optimization (LTO)
20
+ ENABLE_LTO ?= 1
21
+ ifeq ($(call has, LTO) , 1)
22
+ ifeq ("$(CC_IS_CLANG )$(CC_IS_GCC ) ",)
23
+ $(warning LTO is only supported in clang and gcc.)
24
+ override ENABLE_LTO := 0
25
+ endif
26
+ endif
27
+ $(call set-feature, LTO)
28
+ ifeq ($(call has, LTO) , 1)
29
+ ifeq ("$(CC_IS_GCC ) ", "1")
30
+ CFLAGS += -flto
31
+ endif
32
+ ifeq ("$(CC_IS_CLANG ) ", "1")
33
+ CFLAGS += -flto=thin -fsplit-lto-unit
34
+ LDFLAGS += -flto=thin
35
+ endif
36
+ endif
37
+
38
+ # Disable Intel's Control-flow Enforcement Technology (CET)
39
+ CFLAGS += $(CFLAGS_NO_CET )
40
+
19
41
OBJS_EXT :=
20
42
21
43
# Control and Status Register (CSR)
90
112
91
113
# For tail-call elimination, we need a specific set of build flags applied.
92
114
# FIXME: On macOS + Apple Silicon, -fno-stack-protector might have a negative impact.
93
- $(OUT ) /emulate.o : CFLAGS += $( CFLAGS_NO_CET ) -foptimize-sibling-calls -fomit-frame-pointer -fno-stack-check -fno-stack-protector
115
+ $(OUT ) /emulate.o : CFLAGS += -foptimize-sibling-calls -fomit-frame-pointer -fno-stack-check -fno-stack-protector
94
116
95
117
# Clear the .DEFAULT_GOAL special variable, so that the following turns
96
118
# to the first target after .DEFAULT_GOAL is not set.
0 commit comments