xref: /linux/arch/s390/Makefile (revision f0be87c42cbd341d436d06da4792e6b0c83c3aeb)
10b73214fSGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
21da177e4SLinus Torvalds#
31da177e4SLinus Torvalds# s390/Makefile
41da177e4SLinus Torvalds#
51da177e4SLinus Torvalds# This file is included by the global makefile so that you can add your own
68212f898SMasahiro Yamada# architecture-specific flags and dependencies.
71da177e4SLinus Torvalds#
81da177e4SLinus Torvalds# Copyright (C) 1994 by Linus Torvalds
91da177e4SLinus Torvalds#
101da177e4SLinus Torvalds
111844c9bcSMartin SchwidefskyLD_BFD		:= elf64-s390
12d503ac53SMasahiro YamadaKBUILD_LDFLAGS	:= -m elf64_s390
137bdc229fSMartin SchwidefskyKBUILD_AFLAGS_MODULE += -fPIC
147bdc229fSMartin SchwidefskyKBUILD_CFLAGS_MODULE += -fPIC
15222d394dSSam RavnborgKBUILD_AFLAGS	+= -m64
1676bf9d6cSVasily GorbikKBUILD_CFLAGS	+= -m64
17805bc0bcSGerald Schaeferifeq ($(CONFIG_RELOCATABLE),y)
18805bc0bcSGerald SchaeferKBUILD_CFLAGS	+= -fPIE
19805bc0bcSGerald SchaeferLDFLAGS_vmlinux	:= -pie
20805bc0bcSGerald Schaeferendif
21ee6d777dSVasily Gorbikaflags_dwarf	:= -Wa,-gdwarf-2
2296fb54a1SArnd BergmannKBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
23bb31074dSHeiko Carstensifndef CONFIG_AS_IS_LLVM
24ee6d777dSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
25bb31074dSHeiko Carstensendif
2642b01a55SVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack
2776bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
288977ab65SVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
2976bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
30685969e0SMasahiro YamadaKBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
3142e8d652SFabrice FontaineKBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
32f9364df3SHeiko CarstensKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
33ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
34ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
35*f0be87c4SLinus TorvaldsKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds)
368b202ee2SSven Schnelle
371da177e4SLinus TorvaldsUTS_MACHINE	:= s390x
389fed920eSVasily GorbikSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,16384)
3914516765SLuc Van OostenryckCHECKFLAGS	+= -D__s390__ -D__s390x__
401da177e4SLinus Torvalds
411844c9bcSMartin Schwidefskyexport LD_BFD
421844c9bcSMartin Schwidefsky
430f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z10)    := -march=z10
440f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z196)   := -march=z196
450f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
46f8b2dcbdSMartin Schwidefskymflags-$(CONFIG_MARCH_Z13)    := -march=z13
476997c323SMartin Schwidefskymflags-$(CONFIG_MARCH_Z14)    := -march=z14
48a0e22511SMartin Schwidefskymflags-$(CONFIG_MARCH_Z15)    := -march=z15
49e69a7ff8SHeiko Carstensmflags-$(CONFIG_MARCH_Z16)    := -march=z16
500f1b1ff5SHeiko Carstens
5122362a0eSMartin Schwidefskyexport CC_FLAGS_MARCH := $(mflags-y)
5222362a0eSMartin Schwidefsky
530f1b1ff5SHeiko Carstensaflags-y += $(mflags-y)
540f1b1ff5SHeiko Carstenscflags-y += $(mflags-y)
551da177e4SLinus Torvalds
561db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
571db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
581db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
59f8b2dcbdSMartin Schwidefskycflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
606997c323SMartin Schwidefskycflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
61a0e22511SMartin Schwidefskycflags-$(CONFIG_MARCH_Z15_TUNE)		+= -mtune=z15
62e69a7ff8SHeiko Carstenscflags-$(CONFIG_MARCH_Z16_TUNE)		+= -mtune=z16
631db9e051SHeiko Carstens
64c783b91eSMartin Schwidefskycflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
65c783b91eSMartin Schwidefsky
66cbbd1fa7SHeiko Carstens#
67cbbd1fa7SHeiko Carstens# Prevent tail-call optimizations, to get clearer backtraces:
68cbbd1fa7SHeiko Carstens#
69cbbd1fa7SHeiko Carstenscflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
70cbbd1fa7SHeiko Carstens
7176bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7276bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7376bf9d6cSVasily Gorbik
74ff00f64bSNick Desaulniersifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),)
7500b55eafSSven Schnelle  CC_FLAGS_CHECK_STACK := -mstack-size=$(STACK_SIZE)
76ff00f64bSNick Desaulniers  ifeq ($(call cc-option,-mstack-size=8192),)
7700b55eafSSven Schnelle    CC_FLAGS_CHECK_STACK += -mstack-guard=$(CONFIG_STACK_GUARD)
781da177e4SLinus Torvalds  endif
7900b55eafSSven Schnelle  export CC_FLAGS_CHECK_STACK
8000b55eafSSven Schnelle  cflags-$(CONFIG_CHECK_STACK) += $(CC_FLAGS_CHECK_STACK)
81be796285SMartin Schwidefskyendif
821da177e4SLinus Torvalds
83f19fbd5eSMartin Schwidefskyifdef CONFIG_EXPOLINE
841d2ad084SVasily Gorbik  ifdef CONFIG_EXPOLINE_EXTERN
851d2ad084SVasily Gorbik    KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline.o
861d2ad084SVasily Gorbik    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern
871d2ad084SVasily Gorbik    CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern
881d2ad084SVasily Gorbik  else
89f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
90f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
911d2ad084SVasily Gorbik  endif
92f19fbd5eSMartin Schwidefsky  CC_FLAGS_EXPOLINE += -mindirect-branch-table
93f19fbd5eSMartin Schwidefsky  export CC_FLAGS_EXPOLINE
946e179d64SMartin Schwidefsky  cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
95157484abSVasily Gorbik  aflags-y += -DCC_USING_EXPOLINE
96f19fbd5eSMartin Schwidefskyendif
97f19fbd5eSMartin Schwidefsky
98e6d60b36SHeiko Carstensifdef CONFIG_FUNCTION_TRACER
99ff00f64bSNick Desaulniers  ifeq ($(call cc-option,-mfentry -mnop-mcount),)
100e6d60b36SHeiko Carstens    # make use of hotpatch feature if the compiler supports it
101e6d60b36SHeiko Carstens    cc_hotpatch	:= -mhotpatch=0,3
102ff00f64bSNick Desaulniers    ifneq ($(call cc-option,$(cc_hotpatch)),)
103e6d60b36SHeiko Carstens      CC_FLAGS_FTRACE := $(cc_hotpatch)
104e6d60b36SHeiko Carstens      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
105e6d60b36SHeiko Carstens      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
106e6d60b36SHeiko Carstens    endif
107e6d60b36SHeiko Carstens  endif
108d983c89cSVasily Gorbikendif
109e6d60b36SHeiko Carstens
1107bceec4eSHendrik Brueckner# Test CFI features of binutils
1117bceec4eSHendrik Bruecknercfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
1127bceec4eSHendrik Brueckner
11342b01a55SVasily GorbikKBUILD_CFLAGS	+= -mpacked-stack -mbackchain -msoft-float $(cflags-y)
114c1afcaecSArnd BergmannKBUILD_CFLAGS	+= -pipe -Wno-sign-compare
1157bceec4eSHendrik BruecknerKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
1167bceec4eSHendrik BruecknerKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
11776bf9d6cSVasily Gorbikexport KBUILD_AFLAGS_DECOMPRESSOR
11876bf9d6cSVasily Gorbikexport KBUILD_CFLAGS_DECOMPRESSOR
1191da177e4SLinus Torvalds
1201da177e4SLinus TorvaldsOBJCOPYFLAGS	:= -O binary
1211da177e4SLinus Torvalds
1228282cd64SVasily Gorbikhead-y		:= arch/s390/kernel/head64.o
1231da177e4SLinus Torvalds
1244562c9ffSMichael Holzheulibs-y		+= arch/s390/lib/
1251da177e4SLinus Torvaldsdrivers-y	+= drivers/s390/
1261da177e4SLinus Torvalds
1274562c9ffSMichael Holzheuboot		:= arch/s390/boot
1285c75824dSHendrik Bruecknersyscalls	:= arch/s390/kernel/syscalls
129c30f6828SHeiko Carstenstools		:= arch/s390/tools
1301da177e4SLinus Torvalds
13100f2fb57SVasily Gorbikall: bzImage
1321da177e4SLinus Torvalds
133e0aa099cSVasily Gorbik#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
134e0aa099cSVasily GorbikKBUILD_IMAGE	:= $(boot)/bzImage
135e0aa099cSVasily Gorbik
13694e90f72SMasahiro Yamadainstall:
137f774f5bbSMasahiro Yamada	$(call cmd,install)
1381da177e4SLinus Torvalds
13900f2fb57SVasily GorbikbzImage: vmlinux
1401da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1411da177e4SLinus Torvalds
142411ed322SMichael Holzheuzfcpdump:
143411ed322SMichael Holzheu	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
144411ed322SMichael Holzheu
145f3cb31e4SHendrik Bruecknervdso_install:
146f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
147f3cb31e4SHendrik Brueckner
1485c75824dSHendrik Bruecknerarchheaders:
1495c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1505c75824dSHendrik Brueckner
151c30f6828SHeiko Carstensarchprepare:
1525c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) kapi
1537fbf8315SHendrik Brueckner	$(Q)$(MAKE) $(build)=$(tools) kapi
154779df224SSven Schnelleifeq ($(KBUILD_EXTMOD),)
155779df224SSven Schnelle# We need to generate vdso-offsets.h before compiling certain files in kernel/.
156779df224SSven Schnelle# In order to do that, we should use the archprepare target, but we can't since
157779df224SSven Schnelle# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
158779df224SSven Schnelle# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
159779df224SSven Schnelle# Therefore we need to generate the header after prepare0 has been made, hence
160779df224SSven Schnelle# this hack.
161779df224SSven Schnelleprepare: vdso_prepare
162779df224SSven Schnellevdso_prepare: prepare0
163779df224SSven Schnelle	$(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h
164779df224SSven Schnelle	$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
165779df224SSven Schnelle		$(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h)
166779df224SSven Schnelleendif
1671da177e4SLinus Torvalds
1681da177e4SLinus Torvalds# Don't use tabs in echo arguments
1691da177e4SLinus Torvaldsdefine archhelp
17000f2fb57SVasily Gorbik  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
171b8eecf36SMichael Holzheu  echo	'  install         - Install kernel using'
172b8eecf36SMichael Holzheu  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
173b8eecf36SMichael Holzheu  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
174b8eecf36SMichael Holzheu  echo	'                    install to $$(INSTALL_PATH)'
1751da177e4SLinus Torvaldsendef
176