xref: /netbsd/sys/arch/amd64/conf/Makefile.amd64 (revision 094a424d)
1*094a424dSchristos#	$NetBSD: Makefile.amd64,v 1.86 2023/01/06 15:35:06 christos Exp $
281918bf8Sfvdl
381918bf8Sfvdl# Makefile for NetBSD
481918bf8Sfvdl#
581918bf8Sfvdl# This makefile is constructed from a machine description:
681918bf8Sfvdl#	config machineid
781918bf8Sfvdl# Most changes should be made in the machine description
881918bf8Sfvdl#	/sys/arch/amd64/conf/``machineid''
981918bf8Sfvdl# after which you should do
1081918bf8Sfvdl#	config machineid
1181918bf8Sfvdl# Machine generic makefile changes should be made in
1281918bf8Sfvdl#	/sys/arch/amd64/conf/Makefile.amd64
1381918bf8Sfvdl# after which config should be rerun for all machines of that type.
1481918bf8Sfvdl#
1581918bf8Sfvdl# To specify debugging, add the config line: makeoptions DEBUG="-g"
1681918bf8Sfvdl# A better way is to specify -g only for a few files.
1781918bf8Sfvdl#
1881918bf8Sfvdl#	makeoptions DEBUGLIST="uvm* trap if_*"
1981918bf8Sfvdl
2081918bf8SfvdlMACHINE_ARCH=x86_64
2181918bf8SfvdlUSETOOLS?=	no
2281918bf8SfvdlNEED_OWN_INSTALL_TARGET?=no
239fa350d2SchristosNOSANITIZER=
249fa350d2Schristos.include <bsd.init.mk>
2581918bf8Sfvdl
2673950688StronUSE_SSP?=	yes
2773950688Stron
2881918bf8Sfvdl##
2981918bf8Sfvdl## (1) port identification
3081918bf8Sfvdl##
3181918bf8SfvdlAMD64=		$S/arch/amd64
32f6b4c20fSchristosGENASSYM_CONF=	${AMD64}/amd64/genassym.cf
3381918bf8Sfvdl
3481918bf8Sfvdl##
3581918bf8Sfvdl## (2) compile settings
3681918bf8Sfvdl##
37a4cdc791SjakllschDEFCOPTS=	-O2 -fno-omit-frame-pointer
3881918bf8SfvdlCPPFLAGS+=	-Damd64 -Dx86_64
3916f7d07eSmaxvCFLAGS+=	-mcmodel=kernel
408e4cbbd3Sdsl# -mno-sse implies -mno-sse2 (etc), explicitly disable avx to be extra sure
41d74c3e3bSdslCFLAGS+=	-mno-red-zone -mno-mmx -mno-sse -mno-avx
42d74c3e3bSdsl# make absolutely sure we don't get x87 registers used as well
438e4cbbd3SdslCFLAGS+=	-msoft-float
448e4cbbd3Sdsl# For gcc we might need this, but other compilers barf
458e4cbbd3Sdsl# CFLAGS+=	-mno-fp-ret-in-387
4681918bf8Sfvdl
47092a90abSjoerg.if ${SPECTRE_V2_GCC_MITIGATION:U0} > 0
48092a90abSjoergCFLAGS+=	${${ACTIVE_CC} == "gcc" :? -mindirect-branch=thunk :}
49092a90abSjoergCFLAGS+=	${${ACTIVE_CC} == "gcc" :? -mindirect-branch-register :}
5091fc8e9cSmrg.endif
5191fc8e9cSmrg
52c8d588d6Smaxv.if ${KASAN:U0} > 0
53c8d588d6Smaxv.if ${HAVE_GCC:U0} > 0
541903813cSmaxvKASANFLAGS=	-fsanitize=kernel-address \
551903813cSmaxv		--param asan-globals=1 --param asan-stack=1 \
56b6812645Smaxv		--param asan-instrument-allocas=1 \
574921525dSmaxv		-fsanitize-address-use-after-scope \
581903813cSmaxv		-fasan-shadow-offset=0xDFFF900000000000
59c8d588d6Smaxv.elif ${HAVE_LLVM:Uno} == "yes"
60c8d588d6SmaxvKASANFLAGS=	-fsanitize=kernel-address \
61c8d588d6Smaxv		-mllvm -asan-globals=1 -mllvm -asan-stack=1 \
62c8d588d6Smaxv		-mllvm -asan-instrument-dynamic-allocas=1 \
63c8d588d6Smaxv		-mllvm -asan-use-after-scope=1 \
64c8d588d6Smaxv		-mllvm -asan-instrumentation-with-call-threshold=0 \
65c8d588d6Smaxv		-mllvm -asan-mapping-offset=0xDFFF900000000000
66c8d588d6Smaxv.endif
67d0778080Smaxv.for f in subr_asan.c subr_kcov.c
681903813cSmaxvKASANFLAGS.${f}=	# empty
691903813cSmaxv.endfor
701903813cSmaxvCFLAGS+=	${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
71f8e4d06fSmaxv.endif
72f8e4d06fSmaxv
730d935a37Smaxv.if ${KCSAN:U0} > 0 && ${HAVE_GCC:U0} > 0
740d935a37SmaxvKCSANFLAGS=	-fsanitize=thread
75d0778080Smaxv.for f in subr_csan.c subr_kcov.c clock.c lapic.c
760d935a37SmaxvKCSANFLAGS.${f}=	# empty
770d935a37Smaxv.endfor
780d935a37SmaxvCFLAGS+=	${KCSANFLAGS.${.IMPSRC:T}:U${KCSANFLAGS}}
790d935a37Smaxv.endif
800d935a37Smaxv
815fa591c0Smaxv.if ${KMSAN:U0} > 0 && ${HAVE_LLVM:Uno} == "yes"
825fa591c0SmaxvKMSANFLAGS=	-fsanitize=kernel-memory
835fa591c0Smaxv.for f in subr_msan.c
845fa591c0SmaxvKMSANFLAGS.${f}=	# empty
855fa591c0Smaxv.endfor
865fa591c0SmaxvCFLAGS+=	${KMSANFLAGS.${.IMPSRC:T}:U${KMSANFLAGS}}
875fa591c0Smaxv.endif
885fa591c0Smaxv
8922e594a0SbouyerEXTRA_INCLUDES= -I$S/external/mit/xen-include-public/dist/
9022e594a0Sbouyer
9181918bf8Sfvdl##
9281918bf8Sfvdl## (3) libkern and compat
9381918bf8Sfvdl##
943c479c5aSchristosOPT_MODULAR=	%MODULAR%
9581918bf8Sfvdl
9681918bf8Sfvdl##
9781918bf8Sfvdl## (4) local objects, compile rules, and dependencies
9881918bf8Sfvdl##
9981918bf8Sfvdl
10081918bf8Sfvdl##
10181918bf8Sfvdl## (5) link settings
10281918bf8Sfvdl##
1037276bb8bSmaxvTEXTADDR?=	0xffffffff80200000
10470dee003Smaxv.if defined(KASLR)
10527958a79SmaxvEXTRA_LINKFLAGS=	--split-by-file=0x100000 -r -d
10616deffebSmaxvKERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript.kaslr
10770dee003Smaxv.else
108e5b5f123SmaxvEXTRA_LINKFLAGS=	-z max-page-size=0x200000
10916deffebSmaxvKERNLDSCRIPT?= ${AMD64}/conf/kern.ldscript
11070dee003Smaxv.endif
11181918bf8SfvdlLINKFLAGS_NORMAL=	-X
112*094a424dSchristosEXTRA_LINKFLAGS+=	-z noseparate-code
11381918bf8Sfvdl
11481918bf8Sfvdl##
11581918bf8Sfvdl## (6) port specific target dependencies
11681918bf8Sfvdl##
11781918bf8Sfvdl
11881918bf8Sfvdl# depend on CPU configuration
11981918bf8Sfvdllocore.o machdep.o: Makefile
12081918bf8Sfvdl
121c8c6265eSmaxvacpi_wakeup_low.o busfunc.o cpufunc.o cpu_in_cksum.o: assym.h
122681da605Smaxvlinux_sigcode.o linux32_sigcode.o lock_stubs.o mptramp.o: assym.h
12377a5d439Sjoergnetbsd32_sigcode.o: assym.h
12481918bf8Sfvdl
12581918bf8Sfvdl##
12681918bf8Sfvdl## (7) misc settings
12781918bf8Sfvdl##
12881918bf8Sfvdl
12981918bf8Sfvdl##
13081918bf8Sfvdl## (8) config(8) generated machinery
13181918bf8Sfvdl##
13281918bf8Sfvdl%INCLUDES
13381918bf8Sfvdl
13481918bf8Sfvdl%OBJS
13581918bf8Sfvdl
13681918bf8Sfvdl%CFILES
13781918bf8Sfvdl
13881918bf8Sfvdl%SFILES
13981918bf8Sfvdl
14081918bf8Sfvdl%LOAD
14181918bf8Sfvdl
14281918bf8Sfvdl%RULES
14331f44cb2Salc
14481918bf8Sfvdl##
14581918bf8Sfvdl## (9) port independent kernel machinery
14681918bf8Sfvdl##
14781918bf8Sfvdl.include "$S/conf/Makefile.kern.inc"
148e33c2bb5Sthorpej
1491b91baa7Schristos## Include rules for ACPI wakecode
1501b91baa7Schristos.include "$S/arch/x86/acpi/Makefile.wakecode.inc"
1511b91baa7Schristos
152e33c2bb5Sthorpej##
153e33c2bb5Sthorpej## (10) Appending make options.
154e33c2bb5Sthorpej##
155e33c2bb5Sthorpej%MAKEOPTIONSAPPEND
156