xref: /linux/arch/s390/Makefile (revision 42b01a553a56d9bc7c75b700fd274f1ec4a3763f)
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__
23ee6d777dSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
24*42b01a55SVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack
2576bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
268977ab65SVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
2776bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
28685969e0SMasahiro YamadaKBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
2942e8d652SFabrice FontaineKBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
30f9364df3SHeiko CarstensKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
31ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
32ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
331da177e4SLinus TorvaldsUTS_MACHINE	:= s390x
349fed920eSVasily GorbikSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,16384)
3514516765SLuc Van OostenryckCHECKFLAGS	+= -D__s390__ -D__s390x__
361da177e4SLinus Torvalds
371844c9bcSMartin Schwidefskyexport LD_BFD
381844c9bcSMartin Schwidefsky
390f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z900)   := -march=z900
400f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z990)   := -march=z990
410f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z9_109) := -march=z9-109
420f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z10)    := -march=z10
430f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z196)   := -march=z196
440f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
45f8b2dcbdSMartin Schwidefskymflags-$(CONFIG_MARCH_Z13)    := -march=z13
466997c323SMartin Schwidefskymflags-$(CONFIG_MARCH_Z14)    := -march=z14
47a0e22511SMartin Schwidefskymflags-$(CONFIG_MARCH_Z15)    := -march=z15
480f1b1ff5SHeiko Carstens
4922362a0eSMartin Schwidefskyexport CC_FLAGS_MARCH := $(mflags-y)
5022362a0eSMartin Schwidefsky
510f1b1ff5SHeiko Carstensaflags-y += $(mflags-y)
520f1b1ff5SHeiko Carstenscflags-y += $(mflags-y)
531da177e4SLinus Torvalds
541db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z900_TUNE)	+= -mtune=z900
551db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z990_TUNE)	+= -mtune=z990
561db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z9_109_TUNE)	+= -mtune=z9-109
571db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z10_TUNE)		+= -mtune=z10
581db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_Z196_TUNE)	+= -mtune=z196
591db9e051SHeiko Carstenscflags-$(CONFIG_MARCH_ZEC12_TUNE)	+= -mtune=zEC12
60f8b2dcbdSMartin Schwidefskycflags-$(CONFIG_MARCH_Z13_TUNE)		+= -mtune=z13
616997c323SMartin Schwidefskycflags-$(CONFIG_MARCH_Z14_TUNE)		+= -mtune=z14
62a0e22511SMartin Schwidefskycflags-$(CONFIG_MARCH_Z15_TUNE)		+= -mtune=z15
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
84ff00f64bSNick Desaulniers  ifneq ($(call cc-option,$(CC_FLAGS_MARCH) -mindirect-branch=thunk),)
85f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
86f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mfunction-return=thunk
87f19fbd5eSMartin Schwidefsky    CC_FLAGS_EXPOLINE += -mindirect-branch-table
88f19fbd5eSMartin Schwidefsky    export CC_FLAGS_EXPOLINE
896e179d64SMartin Schwidefsky    cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
90157484abSVasily Gorbik    aflags-y += -DCC_USING_EXPOLINE
91f19fbd5eSMartin Schwidefsky  endif
92f19fbd5eSMartin Schwidefskyendif
93f19fbd5eSMartin Schwidefsky
94e6d60b36SHeiko Carstensifdef CONFIG_FUNCTION_TRACER
95ff00f64bSNick Desaulniers  ifeq ($(call cc-option,-mfentry -mnop-mcount),)
96e6d60b36SHeiko Carstens    # make use of hotpatch feature if the compiler supports it
97e6d60b36SHeiko Carstens    cc_hotpatch	:= -mhotpatch=0,3
98ff00f64bSNick Desaulniers    ifneq ($(call cc-option,$(cc_hotpatch)),)
99e6d60b36SHeiko Carstens      CC_FLAGS_FTRACE := $(cc_hotpatch)
100e6d60b36SHeiko Carstens      KBUILD_AFLAGS	+= -DCC_USING_HOTPATCH
101e6d60b36SHeiko Carstens      KBUILD_CFLAGS	+= -DCC_USING_HOTPATCH
102e6d60b36SHeiko Carstens    endif
103e6d60b36SHeiko Carstens  endif
104d983c89cSVasily Gorbikendif
105e6d60b36SHeiko Carstens
1067bceec4eSHendrik Brueckner# Test CFI features of binutils
1077bceec4eSHendrik Bruecknercfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
1087bceec4eSHendrik Brueckner
109*42b01a55SVasily GorbikKBUILD_CFLAGS	+= -mpacked-stack -mbackchain -msoft-float $(cflags-y)
110c1afcaecSArnd BergmannKBUILD_CFLAGS	+= -pipe -Wno-sign-compare
1117bceec4eSHendrik BruecknerKBUILD_CFLAGS	+= -fno-asynchronous-unwind-tables $(cfi)
1127bceec4eSHendrik BruecknerKBUILD_AFLAGS	+= $(aflags-y) $(cfi)
11376bf9d6cSVasily Gorbikexport KBUILD_AFLAGS_DECOMPRESSOR
11476bf9d6cSVasily Gorbikexport KBUILD_CFLAGS_DECOMPRESSOR
1151da177e4SLinus Torvalds
1161da177e4SLinus TorvaldsOBJCOPYFLAGS	:= -O binary
1171da177e4SLinus Torvalds
1188282cd64SVasily Gorbikhead-y		:= arch/s390/kernel/head64.o
1191da177e4SLinus Torvalds
1204562c9ffSMichael Holzheulibs-y		+= arch/s390/lib/
1211da177e4SLinus Torvaldsdrivers-y	+= drivers/s390/
1221da177e4SLinus Torvalds
1234562c9ffSMichael Holzheuboot		:= arch/s390/boot
1245c75824dSHendrik Bruecknersyscalls	:= arch/s390/kernel/syscalls
125c30f6828SHeiko Carstenstools		:= arch/s390/tools
1261da177e4SLinus Torvalds
12700f2fb57SVasily Gorbikall: bzImage
1281da177e4SLinus Torvalds
129e0aa099cSVasily Gorbik#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
130e0aa099cSVasily GorbikKBUILD_IMAGE	:= $(boot)/bzImage
131e0aa099cSVasily Gorbik
13294e90f72SMasahiro Yamadainstall:
133d80d3ea6SMasahiro Yamada	sh -x $(srctree)/$(boot)/install.sh $(KERNELRELEASE) $(KBUILD_IMAGE) \
134d80d3ea6SMasahiro Yamada	      System.map "$(INSTALL_PATH)"
1351da177e4SLinus Torvalds
13600f2fb57SVasily GorbikbzImage: vmlinux
1371da177e4SLinus Torvalds	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
1381da177e4SLinus Torvalds
139411ed322SMichael Holzheuzfcpdump:
140411ed322SMichael Holzheu	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
141411ed322SMichael Holzheu
142f3cb31e4SHendrik Bruecknervdso_install:
143f3cb31e4SHendrik Brueckner	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
144f3cb31e4SHendrik Brueckner
1455c75824dSHendrik Bruecknerarchheaders:
1465c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1475c75824dSHendrik Brueckner
148c30f6828SHeiko Carstensarchprepare:
1495c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) kapi
1507fbf8315SHendrik Brueckner	$(Q)$(MAKE) $(build)=$(tools) kapi
151779df224SSven Schnelleifeq ($(KBUILD_EXTMOD),)
152779df224SSven Schnelle# We need to generate vdso-offsets.h before compiling certain files in kernel/.
153779df224SSven Schnelle# In order to do that, we should use the archprepare target, but we can't since
154779df224SSven Schnelle# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
155779df224SSven Schnelle# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
156779df224SSven Schnelle# Therefore we need to generate the header after prepare0 has been made, hence
157779df224SSven Schnelle# this hack.
158779df224SSven Schnelleprepare: vdso_prepare
159779df224SSven Schnellevdso_prepare: prepare0
160779df224SSven Schnelle	$(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h
161779df224SSven Schnelle	$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
162779df224SSven Schnelle		$(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h)
163779df224SSven Schnelleendif
1641da177e4SLinus Torvalds
1651da177e4SLinus Torvalds# Don't use tabs in echo arguments
1661da177e4SLinus Torvaldsdefine archhelp
16700f2fb57SVasily Gorbik  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
168b8eecf36SMichael Holzheu  echo	'  install         - Install kernel using'
169b8eecf36SMichael Holzheu  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
170b8eecf36SMichael Holzheu  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
171b8eecf36SMichael Holzheu  echo	'                    install to $$(INSTALL_PATH)'
1721da177e4SLinus Torvaldsendef
173