blob: ed646c583e4fe694e1678d9e54356d370c67d7f8 [file] [log] [blame]
Greg Kroah-Hartman0b732142017-11-24 15:00:38 +01001# SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#
3# s390/Makefile
4#
5# This file is included by the global makefile so that you can add your own
Masahiro Yamada8212f892021-10-13 15:36:22 +09006# architecture-specific flags and dependencies.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#
Linus Torvalds1da177e2005-04-16 15:20:36 -07008# Copyright (C) 1994 by Linus Torvalds
9#
10
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010011LD_BFD := elf64-s390
Masahiro Yamadad503ac52018-08-24 08:20:39 +090012KBUILD_LDFLAGS := -m elf64_s390
Martin Schwidefsky7bdc2292013-01-11 15:26:01 +010013KBUILD_AFLAGS_MODULE += -fPIC
14KBUILD_CFLAGS_MODULE += -fPIC
Sam Ravnborg222d3942007-10-15 21:59:31 +020015KBUILD_AFLAGS += -m64
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020016KBUILD_CFLAGS += -m64
Gerald Schaefer805bc0b2019-02-03 21:35:45 +010017KBUILD_CFLAGS += -fPIE
18LDFLAGS_vmlinux := -pie
Vasily Gorbikee6d7772018-06-28 19:22:21 +020019aflags_dwarf := -Wa,-gdwarf-2
Arnd Bergmann96fb54a2019-04-15 10:35:52 +020020KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__
Heiko Carstensbb310742022-05-11 14:05:31 +020021ifndef CONFIG_AS_IS_LLVM
Vasily Gorbikee6d7772018-06-28 19:22:21 +020022KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
Heiko Carstensbb310742022-05-11 14:05:31 +020023endif
Vasily Gorbik42b01a52022-01-29 00:34:13 +010024KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020025KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
Vasily Gorbik8977ab62020-11-10 17:05:35 +010026KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020027KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
Masahiro Yamada685969e2020-06-27 03:59:13 +090028KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding
Fabrice Fontaine42e8d652021-05-10 07:31:33 +020029KBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector
Heiko Carstensf9364df2019-06-04 13:10:51 +020030KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member)
Vasily Gorbikee6d7772018-06-28 19:22:21 +020031KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g)
32KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,))
Linus Torvaldsf0be87c2022-06-09 10:11:12 -070033KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds)
Sven Schnelle8b202ee2022-04-25 14:17:42 +020034
Linus Torvalds1da177e2005-04-16 15:20:36 -070035UTS_MACHINE := s390x
Vasily Gorbik9fed9202018-10-26 15:29:59 +020036STACK_SIZE := $(if $(CONFIG_KASAN),65536,16384)
Luc Van Oostenryck145167652018-05-28 20:27:35 +020037CHECKFLAGS += -D__s390__ -D__s390x__
Linus Torvalds1da177e2005-04-16 15:20:36 -070038
Martin Schwidefsky1844c9b2010-02-26 22:37:53 +010039export LD_BFD
40
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020041mflags-$(CONFIG_MARCH_Z10) := -march=z10
42mflags-$(CONFIG_MARCH_Z196) := -march=z196
43mflags-$(CONFIG_MARCH_ZEC12) := -march=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020044mflags-$(CONFIG_MARCH_Z13) := -march=z13
45mflags-$(CONFIG_MARCH_Z14) := -march=z14
Martin Schwidefskya0e22512019-02-06 08:22:11 +010046mflags-$(CONFIG_MARCH_Z15) := -march=z15
Heiko Carstense69a7ff2021-07-20 14:28:08 +020047mflags-$(CONFIG_MARCH_Z16) := -march=z16
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020048
Martin Schwidefsky22362a02015-07-08 10:20:04 +020049export CC_FLAGS_MARCH := $(mflags-y)
50
Heiko Carstens0f1b1ff2014-08-14 16:06:02 +020051aflags-y += $(mflags-y)
52cflags-y += $(mflags-y)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
Heiko Carstens1db9e052013-10-30 12:12:50 +010054cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10
55cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196
56cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12
Martin Schwidefsky6997c322017-04-12 14:17:25 +020057cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13
58cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14
Martin Schwidefskya0e22512019-02-06 08:22:11 +010059cflags-$(CONFIG_MARCH_Z15_TUNE) += -mtune=z15
Heiko Carstense69a7ff2021-07-20 14:28:08 +020060cflags-$(CONFIG_MARCH_Z16_TUNE) += -mtune=z16
Heiko Carstens1db9e052013-10-30 12:12:50 +010061
Martin Schwidefskyc783b91e2016-09-06 10:46:36 +020062cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
63
Heiko Carstenscbbd1fa2006-07-03 00:24:38 -070064#
65# Prevent tail-call optimizations, to get clearer backtraces:
66#
67cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls
68
Vasily Gorbik76bf9d62018-06-15 12:28:05 +020069KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y)
70KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y)
71
Nick Desaulniersff00f642021-08-16 17:21:04 -070072ifneq ($(call cc-option,-mstack-size=8192 -mstack-guard=128),)
Sven Schnelle00b55ea2021-11-11 10:58:26 +010073 CC_FLAGS_CHECK_STACK := -mstack-size=$(STACK_SIZE)
74 ifeq ($(call cc-option,-mstack-size=8192),)
75 CC_FLAGS_CHECK_STACK += -mstack-guard=$(CONFIG_STACK_GUARD)
76 endif
77 export CC_FLAGS_CHECK_STACK
78 cflags-$(CONFIG_CHECK_STACK) += $(CC_FLAGS_CHECK_STACK)
Martin Schwidefskybe796282007-04-27 16:01:46 +020079endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010081ifdef CONFIG_EXPOLINE
Vasily Gorbik1d2ad082022-03-06 20:56:07 +010082 ifdef CONFIG_EXPOLINE_EXTERN
Vasily Gorbikc4e78952022-06-27 14:50:53 +020083 KBUILD_LDFLAGS_MODULE += arch/s390/lib/expoline/expoline.o
Vasily Gorbik1d2ad082022-03-06 20:56:07 +010084 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern
85 CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern
86 else
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010087 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk
88 CC_FLAGS_EXPOLINE += -mfunction-return=thunk
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010089 endif
Vasily Gorbik1d2ad082022-03-06 20:56:07 +010090 CC_FLAGS_EXPOLINE += -mindirect-branch-table
91 export CC_FLAGS_EXPOLINE
92 cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
93 aflags-y += -DCC_USING_EXPOLINE
Martin Schwidefskyf19fbd52018-01-26 12:46:47 +010094endif
95
Heiko Carstense6d60b32015-01-09 13:08:28 +010096ifdef CONFIG_FUNCTION_TRACER
Nick Desaulniersff00f642021-08-16 17:21:04 -070097 ifeq ($(call cc-option,-mfentry -mnop-mcount),)
Vasily Gorbikd983c892018-08-06 15:17:47 +020098 # make use of hotpatch feature if the compiler supports it
99 cc_hotpatch := -mhotpatch=0,3
Nick Desaulniersff00f642021-08-16 17:21:04 -0700100 ifneq ($(call cc-option,$(cc_hotpatch)),)
Vasily Gorbikd983c892018-08-06 15:17:47 +0200101 CC_FLAGS_FTRACE := $(cc_hotpatch)
102 KBUILD_AFLAGS += -DCC_USING_HOTPATCH
103 KBUILD_CFLAGS += -DCC_USING_HOTPATCH
104 endif
105 endif
Heiko Carstense6d60b32015-01-09 13:08:28 +0100106endif
107
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100108# Test CFI features of binutils
109cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1)
110
Vasily Gorbik42b01a52022-01-29 00:34:13 +0100111KBUILD_CFLAGS += -mpacked-stack -mbackchain -msoft-float $(cflags-y)
Arnd Bergmannc1afcae2019-04-08 23:26:14 +0200112KBUILD_CFLAGS += -pipe -Wno-sign-compare
Hendrik Brueckner7bceec42017-11-20 11:46:13 +0100113KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi)
114KBUILD_AFLAGS += $(aflags-y) $(cfi)
Vasily Gorbik76bf9d62018-06-15 12:28:05 +0200115export KBUILD_AFLAGS_DECOMPRESSOR
116export KBUILD_CFLAGS_DECOMPRESSOR
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118OBJCOPYFLAGS := -O binary
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100120libs-y += arch/s390/lib/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121drivers-y += drivers/s390/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
Michael Holzheu4562c9f2007-02-21 10:55:46 +0100123boot := arch/s390/boot
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100124syscalls := arch/s390/kernel/syscalls
Heiko Carstensc30f6822015-02-02 07:08:44 +0100125tools := arch/s390/tools
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200127all: bzImage
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
Vasily Gorbike0aa0992018-02-20 11:31:34 +0100129#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
130KBUILD_IMAGE := $(boot)/bzImage
131
Masahiro Yamada94e90f72020-02-16 23:48:29 +0900132install:
Masahiro Yamadaf774f5b2022-05-03 11:47:16 +0900133 $(call cmd,install)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200135bzImage: vmlinux
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
137
Michael Holzheu411ed322007-04-27 16:01:49 +0200138zfcpdump:
139 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
140
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200141vdso_install:
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200142 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
Hendrik Bruecknerf3cb31e2010-05-17 10:00:09 +0200143
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100144archheaders:
145 $(Q)$(MAKE) $(build)=$(syscalls) uapi
146
Heiko Carstensc30f6822015-02-02 07:08:44 +0100147archprepare:
Hendrik Brueckner5c758242017-12-11 14:54:08 +0100148 $(Q)$(MAKE) $(build)=$(syscalls) kapi
Hendrik Brueckner7fbf8312018-01-11 12:13:18 +0100149 $(Q)$(MAKE) $(build)=$(tools) kapi
Sven Schnelle779df222021-06-25 14:50:08 +0200150ifeq ($(KBUILD_EXTMOD),)
151# We need to generate vdso-offsets.h before compiling certain files in kernel/.
152# In order to do that, we should use the archprepare target, but we can't since
153# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
154# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
155# Therefore we need to generate the header after prepare0 has been made, hence
156# this hack.
157prepare: vdso_prepare
158vdso_prepare: prepare0
159 $(Q)$(MAKE) $(build)=arch/s390/kernel/vdso64 include/generated/vdso64-offsets.h
160 $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
161 $(build)=arch/s390/kernel/vdso32 include/generated/vdso32-offsets.h)
Vasily Gorbikc4e78952022-06-27 14:50:53 +0200162
163ifdef CONFIG_EXPOLINE_EXTERN
164modules_prepare: expoline_prepare
Jiri Slaby (SUSE)7bb21072023-03-16 12:28:09 +0100165expoline_prepare: scripts
Vasily Gorbikc4e78952022-06-27 14:50:53 +0200166 $(Q)$(MAKE) $(build)=arch/s390/lib/expoline arch/s390/lib/expoline/expoline.o
167endif
Sven Schnelle779df222021-06-25 14:50:08 +0200168endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170# Don't use tabs in echo arguments
171define archhelp
Vasily Gorbik00f2fb52018-06-11 14:35:01 +0200172 echo '* bzImage - Kernel image for IPL ($(boot)/bzImage)'
Michael Holzheub8eecf32015-11-25 11:54:36 +0100173 echo ' install - Install kernel using'
174 echo ' (your) ~/bin/$(INSTALLKERNEL) or'
175 echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
176 echo ' install to $$(INSTALL_PATH)'
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177endef