xref: /linux/arch/s390/Makefile (revision a1ff5a7d78a036d6c2178ee5acd6ba4946243800)
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
1700cda11dSSumanth KorikkarKBUILD_CFLAGS	+= -fPIC
1800cda11dSSumanth KorikkarLDFLAGS_vmlinux	:= -no-pie --emit-relocs --discard-none
19778666dfSJosh Poimboeufextra_tools	:= relocs
20ee6d777dSVasily Gorbikaflags_dwarf	:= -Wa,-gdwarf-2
2196fb54a1SArnd BergmannKBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
22bb31074dSHeiko Carstensifndef CONFIG_AS_IS_LLVM
23ee6d777dSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
24bb31074dSHeiko Carstensendif
2542b01a55SVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack
2676bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
275f58bde7SHeiko CarstensKBUILD_CFLAGS_DECOMPRESSOR += -D__DECOMPRESSOR
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
32938f0c35SHeiko CarstensKBUILD_CFLAGS_DECOMPRESSOR += -fPIE
33f9364df3SHeiko CarstensKBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
34ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
35ee6d777dSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
36f0be87c4SLinus TorvaldsKBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds)
378b202ee2SSven Schnelle
381da177e4SLinus TorvaldsUTS_MACHINE	:= s390x
39*435dc41eSIlya LeoshkevichSTACK_SIZE	:= $(if $(CONFIG_KASAN),65536,$(if $(CONFIG_KMSAN),65536,16384))
4014516765SLuc Van OostenryckCHECKFLAGS	+= -D__s390__ -D__s390x__
411da177e4SLinus Torvalds
421844c9bcSMartin Schwidefskyexport LD_BFD
431844c9bcSMartin Schwidefsky
440f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z10)    := -march=z10
450f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_Z196)   := -march=z196
460f1b1ff5SHeiko Carstensmflags-$(CONFIG_MARCH_ZEC12)  := -march=zEC12
47f8b2dcbdSMartin Schwidefskymflags-$(CONFIG_MARCH_Z13)    := -march=z13
486997c323SMartin Schwidefskymflags-$(CONFIG_MARCH_Z14)    := -march=z14
49a0e22511SMartin Schwidefskymflags-$(CONFIG_MARCH_Z15)    := -march=z15
50e69a7ff8SHeiko Carstensmflags-$(CONFIG_MARCH_Z16)    := -march=z16
510f1b1ff5SHeiko Carstens
5222362a0eSMartin Schwidefskyexport CC_FLAGS_MARCH := $(mflags-y)
5322362a0eSMartin Schwidefsky
540f1b1ff5SHeiko Carstensaflags-y += $(mflags-y)
550f1b1ff5SHeiko Carstenscflags-y += $(mflags-y)
561da177e4SLinus Torvalds
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
63e69a7ff8SHeiko Carstenscflags-$(CONFIG_MARCH_Z16_TUNE)		+= -mtune=z16
641db9e051SHeiko Carstens
65c783b91eSMartin Schwidefskycflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
66c783b91eSMartin Schwidefsky
67cbbd1fa7SHeiko Carstens#
68cbbd1fa7SHeiko Carstens# Prevent tail-call optimizations, to get clearer backtraces:
69cbbd1fa7SHeiko Carstens#
70cbbd1fa7SHeiko Carstenscflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
71cbbd1fa7SHeiko Carstens
7276bf9d6cSVasily GorbikKBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
7376bf9d6cSVasily GorbikKBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
7476bf9d6cSVasily Gorbik
75ff00f64bSNick Desaulniersifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),)
7600b55eafSSven Schnelle  CC_FLAGS_CHECK_STACK := -mstack-size=$(STACK_SIZE)
77ff00f64bSNick Desaulniers  ifeq ($(call cc-option,-mstack-size=8192),)
7800b55eafSSven Schnelle    CC_FLAGS_CHECK_STACK += -mstack-guard=$(CONFIG_STACK_GUARD)
791da177e4SLinus Torvalds  endif
8000b55eafSSven Schnelle  export CC_FLAGS_CHECK_STACK
8100b55eafSSven Schnelle  cflags-$(CONFIG_CHECK_STACK) += $(CC_FLAGS_CHECK_STACK)
82be796285SMartin Schwidefskyendif
831da177e4SLinus Torvalds
84f19fbd5eSMartin Schwidefskyifdef CONFIG_EXPOLINE
851d2ad084SVasily Gorbik  ifdef CONFIG_EXPOLINE_EXTERN
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
1224562c9ffSMichael Holzheulibs-y		+= arch/s390/lib/
1231da177e4SLinus Torvalds
1244562c9ffSMichael Holzheuboot		:= arch/s390/boot
1255c75824dSHendrik Bruecknersyscalls	:= arch/s390/kernel/syscalls
126c30f6828SHeiko Carstenstools		:= arch/s390/tools
1271da177e4SLinus Torvalds
12800f2fb57SVasily Gorbikall: bzImage
1291da177e4SLinus Torvalds
130e0aa099cSVasily Gorbik#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
131e0aa099cSVasily GorbikKBUILD_IMAGE	:= $(boot)/bzImage
132e0aa099cSVasily Gorbik
13394e90f72SMasahiro Yamadainstall:
134f774f5bbSMasahiro Yamada	$(call cmd,install)
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
1425c75824dSHendrik Bruecknerarchheaders:
1435c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) uapi
1445c75824dSHendrik Brueckner
145c30f6828SHeiko Carstensarchprepare:
1465c75824dSHendrik Brueckner	$(Q)$(MAKE) $(build)=$(syscalls) kapi
147778666dfSJosh Poimboeuf	$(Q)$(MAKE) $(build)=$(tools) kapi $(extra_tools)
148779df224SSven Schnelleifeq ($(KBUILD_EXTMOD),)
149779df224SSven Schnelle# We need to generate vdso-offsets.h before compiling certain files in kernel/.
150779df224SSven Schnelle# In order to do that, we should use the archprepare target, but we can't since
151779df224SSven Schnelle# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
152779df224SSven Schnelle# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
153779df224SSven Schnelle# Therefore we need to generate the header after prepare0 has been made, hence
154779df224SSven Schnelle# this hack.
155779df224SSven Schnelleprepare: vdso_prepare
156779df224SSven Schnellevdso_prepare: prepare0
157779df224SSven Schnelle	$(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h
158779df224SSven Schnelle	$(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
159779df224SSven Schnelle		$(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h)
160c4e78957SVasily Gorbik
16156769ba4SMasahiro Yamadavdso-install-y			+= arch/s390/kernel/vdso64/vdso64.so.dbg
16256769ba4SMasahiro Yamadavdso-install-$(CONFIG_COMPAT)	+= arch/s390/kernel/vdso32/vdso32.so.dbg
16356769ba4SMasahiro Yamada
164779df224SSven Schnelleendif
1651da177e4SLinus Torvalds
1661da177e4SLinus Torvalds# Don't use tabs in echo arguments
1671da177e4SLinus Torvaldsdefine archhelp
16800f2fb57SVasily Gorbik  echo	'* bzImage         - Kernel image for IPL ($(boot)/bzImage)'
169b8eecf36SMichael Holzheu  echo	'  install         - Install kernel using'
170b8eecf36SMichael Holzheu  echo	'                    (your) ~/bin/$(INSTALLKERNEL) or'
171b8eecf36SMichael Holzheu  echo	'                    (distribution) /sbin/$(INSTALLKERNEL) or'
172b8eecf36SMichael Holzheu  echo	'                    install to $$(INSTALL_PATH)'
1731da177e4SLinus Torvaldsendef
174