Makefile.aarch64 revision 1.21.2.1 1 # $NetBSD: Makefile.aarch64,v 1.21.2.1 2021/04/03 22:28:13 thorpej Exp $
2
3 # Makefile for NetBSD
4 #
5 # This makefile is constructed from a machine description:
6 # config machineid
7 # Most changes should be made in the machine description
8 # /sys/arch/<arch>/conf/``machineid''
9 # after which you should do
10 # config machineid
11 # Machine generic makefile changes should be made in
12 # /sys/arch/arm/conf/Makefile.arm
13 # after which config should be rerun for all machines of that type.
14 #
15 # To specify debugging, add the config line: makeoptions DEBUG="-g"
16 # A better way is to specify -g only for a few files.
17 #
18 # makeoptions DEBUGLIST="uvm* trap if_*"
19
20 USETOOLS?= no
21 NEED_OWN_INSTALL_TARGET?=no
22 .include <bsd.own.mk>
23
24 ##
25 ## (1) port identification
26 ##
27 THISARM= $S/arch/${MACHINE}
28 ARM= $S/arch/aarch64
29 GENASSYM_CONF= ${ARM}/aarch64/genassym.cf
30 .-include "$S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc"
31
32 ##
33 ## (2) compile settings
34 ##
35 # CPPFLAGS set by platform-specific Makefile fragment.
36 CFLAGS+= -march=armv8-a+nofp+nosimd
37 #CFLAGS+= -fomit-frame-pointer
38 CFLAGS+= -fno-omit-frame-pointer
39 CFLAGS+= -mno-omit-leaf-frame-pointer
40 #CFLAGS+= -mno-unaligned-access
41
42 .if defined(PROF) && ${HAVE_GCC:U0} > 0
43 # For accurate profiling, it is better to suppress the tail call.
44 CFLAGS+= -fno-optimize-sibling-calls
45 .endif
46
47 .if ${HAVE_LLVM:Uno} == "yes"
48 .if ${ARMV83_PAC:U0} > 0 && ${ARMV85_BTI:U0} > 0
49 CFLAGS+= -mbranch-protection=pac-ret+bti
50 .else
51 .if ${ARMV83_PAC:U0} > 0
52 CFLAGS+= -mbranch-protection=pac-ret
53 .endif
54 .if ${ARMV85_BTI:U0} > 0
55 CFLAGS+= -mbranch-protection=bti
56 .endif
57 .endif
58 .endif
59
60 .if ${HAVE_GCC:U0} > 0
61 .if ${ARMV83_PAC:U0} > 0
62 CFLAGS+= -msign-return-address=all
63 .endif
64 .if ${ARMV85_BTI:U0} > 0
65 # XXX: notyet for gcc
66 .endif
67 .endif
68
69 .if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
70 KASANFLAGS= -fsanitize=kernel-address \
71 --param asan-globals=1 --param asan-stack=1 \
72 --param asan-instrument-allocas=1 \
73 -fsanitize-address-use-after-scope \
74 -fasan-shadow-offset=0xDFFF600000000000
75 .for f in subr_asan.c
76 KASANFLAGS.${f}= # empty
77 .endfor
78 CFLAGS+= ${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
79 .endif
80
81 ##
82 ## (3) libkern and compat
83 ##
84 OPT_MODULAR= %MODULAR%
85
86 ##
87 ## (4) local objects, compile rules, and dependencies
88 ##
89 MD_OBJS+= ${SYSTEM_FIRST_OBJ} locore.o
90 MD_CFILES+=
91 MD_SFILES+= ${SYSTEM_FIRST_SFILE} ${ARM}/aarch64/locore.S
92
93 .if defined(SYSTEM_FIRST_OBJ)
94 ${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
95 ${NORMAL_S}
96 .endif
97
98 locore.o: ${ARM}/aarch64/locore.S assym.h
99 ${NORMAL_S}
100
101 ##
102 ## (5) link settings
103 ##
104 KERNLDSCRIPT?= ${ARM}/conf/kern.ldscript
105 LOADADDRESS?= 0xffffc00000000000
106 LINKFLAGS_NORMAL= -X
107
108 # Strip AArch64 mapping symbols from the kernel image, as they interfere
109 # with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
110 .if !defined(DEBUG) || empty(DEBUG:M-g*)
111 SYSTEM_LD_TAIL?= ${OBJCOPY} -w --strip-symbol='[$$][dx]' \
112 --strip-symbol='[$$][dx]\.*' $@ ;\
113 ${SIZE} $@; chmod 755 $@
114 .else
115 STRIPFLAGS=-g --strip-symbol='$$x' --strip-symbol='$$d'
116 .endif
117
118 ##
119 ## (6) port specific target dependencies
120 ##
121
122 # depend on DIAGNOSTIC etc.
123 cpuswitch.o fault.o machdep.o: Makefile
124
125 # various assembly files that depend on assym.h
126 atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
127 exception.o sigcode.o: assym.h
128 spl.o vectors.o: assym.h
129
130 ##
131 ## (7) misc settings
132 ##
133
134 # define .MAIN _before_ the make() check, so that implicit target
135 # would be defined
136 .MAIN: all
137
138 .if !make(obj) && !make(clean) && !make(cleandir)
139 .BEGIN::
140 -@rm -f arm && \
141 ln -s $S/arch/arm/include arm
142 .endif
143
144 ##
145 ## (8) config(8) generated machinery
146 ##
147 %INCLUDES
148
149 %OBJS
150
151 %CFILES
152
153 %SFILES
154
155 %LOAD
156
157 %RULES
158
159 ##
160 ## (9) after the config file is inserted
161 ##
162
163 ##
164 ## (10) port independent kernel machinery
165 ##
166
167 .include "$S/conf/Makefile.kern.inc"
168
169 ##
170 ## (11) Appending make options.
171 ##
172 %MAKEOPTIONSAPPEND
173