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