forked from unikraft/unikraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.uk
123 lines (100 loc) · 4.65 KB
/
Makefile.uk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
################################################################################
#
# Global Unikraft definitions
#
################################################################################
COMPFLAGS += -nostdlib
COMPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__ -nostdinc
COMPFLAGS-$(call have_gcc) += -fno-tree-sra -fno-split-stack
ifneq ($(HAVE_STACKPROTECTOR),y)
COMPFLAGS += -fno-stack-protector
endif
COMPFLAGS-$(call gcc_version_ge,8,0) += -fcf-protection=none
COMPFLAGS-$(call have_clang) += -fcf-protection=none
COMPFLAGS += -Wall -Wextra
COMPFLAGS-$(call have_clang) += -Wdocumentation -Wdocumentation-pedantic
ASFLAGS += -D__ASSEMBLY__
ASINCLUDES += -I$(CONFIG_UK_BASE)/include
CINCLUDES += -I$(CONFIG_UK_BASE)/include
CXXINCLUDES += -I$(CONFIG_UK_BASE)/include
GOCINCLUDES += -I$(CONFIG_UK_BASE)/include
RUSTCFLAGS-y += --emit=obj --crate-type=rlib --edition=2018 \
-Cpanic=abort -Cembed-bitcode=n \
-Zbinary_dep_depinfo=y -Csymbol-mangling-version=v0 \
-Cforce-unwind-tables=n -Ccodegen-units=1 \
-Dunsafe_op_in_unsafe_fn -Drust_2018_idioms
RUSTCFLAGS-$(CONFIG_OPTIMIZE_NONE) += -Copt-level="0"
RUSTCFLAGS-$(CONFIG_OPTIMIZE_SIZE) += -Copt-level="s"
RUSTCFLAGS-$(CONFIG_OPTIMIZE_PERF) += -Copt-level="2"
RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0) += -Cdebuginfo=0
RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1) += -Cdebuginfo=1
RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL2) += -Cdebuginfo=2
# NOTE: There is not level 3 in rustc
RUSTCFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL3) += -Cdebuginfo=2
# NOTE: rustc supports LTO only with clang
ifeq ($(call have_clang),y)
RUSTCFLAGS-$(CONFIG_OPTIMIZE_LTO) += -Clinker-plugin-lto
else
RUSTCFLAGS-y += -Cembed-bitcode=n -Clto=n
endif
LIBLDFLAGS += -nostdlib -Wl,-r -Wl,-d -Wl,--build-id=none -no-pie
LIBLDFLAGS-$(call have_gcc) += -nostdinc
LDFLAGS += -nostdlib -Wl,--build-id=none
LDFLAGS-$(call have_gcc) += -nostdinc
COMPFLAGS-$(CONFIG_OPTIMIZE_NONE) += -O0 -fno-optimize-sibling-calls -fno-tree-vectorize
COMPFLAGS-$(CONFIG_OPTIMIZE_SIZE) += -Os
COMPFLAGS-$(CONFIG_OPTIMIZE_PERF) += -O2
ifeq ($(CONFIG_OPTIMIZE_NOOMITFP),y)
COMPFLAGS-y += -fno-omit-frame-pointer
else
COMPFLAGS-y += -fomit-frame-pointer -D __OMIT_FRAMEPOINTER__
endif
COMPFLAGS-$(CONFIG_OPTIMIZE_DEADELIM) += -fdata-sections -ffunction-sections
LDFLAGS-$(CONFIG_OPTIMIZE_DEADELIM) += -Wl,--gc-sections
# LTO requires the compiler flags to be handed over also for linking
COMPFLAGS-$(CONFIG_OPTIMIZE_LTO) += -flto
LIBLDFLAGS-$(CONFIG_OPTIMIZE_LTO) += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y)
LDFLAGS-$(CONFIG_OPTIMIZE_LTO) += $(COMPFLAGS) $(COMPFLAGS-y) $(ARCHFLAGS) $(ARCHFLAGS-y)
COMPFLAGS-$(CONFIG_OPTIMIZE_WARNISERROR) += -Werror
DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL0) += -g0
DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL1) += -g1
DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL2) += -g2
DBGFLAGS-$(CONFIG_DEBUG_SYMBOLS_LVL3) += -g3
COMPFLAGS += -D __Unikraft__ -DUK_CODENAME="$(UK_CODENAME)"
COMPFLAGS += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION)
COMPFLAGS += -DUK_FULLVERSION=$(UK_FULLVERSION)
ISR_ARCHFLAGS += -D__INTERRUPTSAFE__
M4FLAGS += -D __Unikraft__ -DUK_CODENAME="$(UK_CODENAME)"
M4FLAGS += -DUK_VERSION=$(UK_VERSION).$(UK_SUBVERSION)
# If GCC supports "-no-pie" flag, we will add this flag to link flags to
# override "pie" option, because some distributions will set
# "--enable-default-pie" by default.
ifeq ($(CONFIG_OPTIMIZE_PIE),y)
ifeq ($(call have_gcc),y)
$(call error_if_gcc_version_lt,7,0)
endif
COMPFLAGS-$(call gcc_version_ge,7,0) += -fPIE
LDFLAGS-$(call gcc_version_ge,7,0) += -static-pie
LDFLAGS-$(call gcc_version_ge,7,0) += -Wl,--no-dynamic-linker
LDFLAGS-$(call gcc_version_ge,7,0) += -z notext -z norelro
COMPFLAGS-$(call have_clang) += -fPIE
LDFLAGS-$(call have_clang) += -static-pie
LDFLAGS-$(call have_clang) += -Wl,--no-dynamic-linker
LDFLAGS-$(call have_clang) += -z notext -z norelro
SECT_STRIP_FLAGS-$(CONFIG_OPTIMIZE_PIE) += -R .dynamic
SECT_STRIP_FLAGS-$(CONFIG_OPTIMIZE_PIE) += -R .dynsym
SECT_STRIP_FLAGS-$(CONFIG_OPTIMIZE_PIE) += -R .dynstr
SECT_STRIP_FLAGS-$(CONFIG_OPTIMIZE_PIE) += -R .rela.dyn
else
COMPFLAGS-$(call gcc_version_ge,6,1) += -fno-PIC
LDFLAGS-$(call gcc_version_ge,6,1) += -no-pie
COMPFLAGS-$(call have_clang) += -fno-PIC
LDFLAGS-$(call have_clang) += -no-pie
endif
ifeq ($(call gcc_version_ge,10,0),y)
COMPFLAGS-y += -fno-tree-loop-distribute-patterns
LIBLDFLAGS-$(CONFIG_OPTIMIZE_LTO) += -flinker-output=nolto-rel
LDFLAGS-$(CONFIG_OPTIMIZE_LTO) += -flinker-output=nolto-rel
endif
ASFLAGS-$(call have_clang) += -mllvm -asm-macro-max-nesting-depth=1000
COMPFLAGS-$(call have_clang) += -fno-builtin