1# SPDX-License-Identifier: GPL-2.0 2# 3# s390/Makefile 4# 5# This file is included by the global makefile so that you can add your own 6# architecture-specific flags and dependencies. 7# 8# Copyright (C) 1994 by Linus Torvalds 9# 10 11LD_BFD := elf64-s390 12KBUILD_LDFLAGS := -m elf64_s390 13KBUILD_AFLAGS_MODULE += -fPIC 14KBUILD_CFLAGS_MODULE += -fPIC 15KBUILD_CPPFLAGS += -m64 16KBUILD_CFLAGS += -fPIC 17LDFLAGS_vmlinux := $(call ld-option,-no-pie) 18extra_tools := relocs 19aflags_dwarf := -Wa,-gdwarf-2 20KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__ 21ifndef CONFIG_AS_IS_LLVM 22KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf)) 23endif 24KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack $(CC_FLAGS_DIALECT) 25KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY 26KBUILD_CFLAGS_DECOMPRESSOR += -D__DECOMPRESSOR 27KBUILD_CFLAGS_DECOMPRESSOR += -Wno-pointer-sign 28KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain 29KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables 30KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding 31KBUILD_CFLAGS_DECOMPRESSOR += -fno-stack-protector 32KBUILD_CFLAGS_DECOMPRESSOR += -fPIE 33KBUILD_CFLAGS_DECOMPRESSOR += $(call cc-disable-warning, address-of-packed-member) 34KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),-g) 35KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO_DWARF4), $(call cc-option, -gdwarf-4,)) 36KBUILD_CFLAGS_DECOMPRESSOR += $(if $(CONFIG_CC_NO_ARRAY_BOUNDS),-Wno-array-bounds) 37 38KBUILD_RUSTFLAGS += --target=s390x-unknown-none-softfloat -Zpacked-stack -Ctarget-feature=+backchain 39 40UTS_MACHINE := s390x 41STACK_SIZE := $(if $(CONFIG_KASAN),65536,$(if $(CONFIG_KMSAN),65536,16384)) 42CHECKFLAGS += -D__s390__ -D__s390x__ 43 44export LD_BFD 45 46march-name-$(CONFIG_MARCH_Z10) := z10 47march-name-$(CONFIG_MARCH_Z196) := z196 48march-name-$(CONFIG_MARCH_ZEC12) := zEC12 49march-name-$(CONFIG_MARCH_Z13) := z13 50march-name-$(CONFIG_MARCH_Z14) := z14 51march-name-$(CONFIG_MARCH_Z15) := z15 52march-name-$(CONFIG_MARCH_Z16) := z16 53march-name-$(CONFIG_MARCH_Z17) := z17 54 55mflags := -march=$(march-name-y) 56 57export CC_FLAGS_MARCH := $(mflags) 58 59aflags-y += $(mflags) 60cflags-y += $(mflags) 61 62KBUILD_RUSTFLAGS += -Ctarget-cpu=$(march-name-y) 63 64cflags-$(CONFIG_MARCH_Z10_TUNE) += -mtune=z10 65cflags-$(CONFIG_MARCH_Z196_TUNE) += -mtune=z196 66cflags-$(CONFIG_MARCH_ZEC12_TUNE) += -mtune=zEC12 67cflags-$(CONFIG_MARCH_Z13_TUNE) += -mtune=z13 68cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14 69cflags-$(CONFIG_MARCH_Z15_TUNE) += -mtune=z15 70cflags-$(CONFIG_MARCH_Z16_TUNE) += -mtune=z16 71cflags-$(CONFIG_MARCH_Z17_TUNE) += -mtune=z17 72 73cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include 74 75# 76# Prevent tail-call optimizations, to get clearer backtraces: 77# 78cflags-$(CONFIG_FRAME_POINTER) += -fno-optimize-sibling-calls 79 80KBUILD_AFLAGS_DECOMPRESSOR += $(aflags-y) 81KBUILD_CFLAGS_DECOMPRESSOR += $(cflags-y) 82 83ifdef CONFIG_EXPOLINE 84 ifdef CONFIG_EXPOLINE_EXTERN 85 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk-extern 86 CC_FLAGS_EXPOLINE += -mfunction-return=thunk-extern 87 else 88 CC_FLAGS_EXPOLINE := -mindirect-branch=thunk 89 CC_FLAGS_EXPOLINE += -mfunction-return=thunk 90 endif 91 CC_FLAGS_EXPOLINE += -mindirect-branch-table 92 export CC_FLAGS_EXPOLINE 93 cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE 94 aflags-y += -DCC_USING_EXPOLINE 95endif 96 97ifeq ($(CONFIG_STACKPROTECTOR),y) 98 KBUILD_CFLAGS += -mstack-protector-guard=global -mstack-protector-guard-record 99endif 100 101ifdef CONFIG_FUNCTION_TRACER 102 ifeq ($(call cc-option,-mfentry -mnop-mcount),) 103 # make use of hotpatch feature if the compiler supports it 104 cc_hotpatch := -mhotpatch=0,3 105 ifneq ($(call cc-option,$(cc_hotpatch)),) 106 CC_FLAGS_FTRACE := $(cc_hotpatch) 107 KBUILD_AFLAGS += -DCC_USING_HOTPATCH 108 KBUILD_CFLAGS += -DCC_USING_HOTPATCH 109 endif 110 endif 111endif 112 113# Test CFI features of binutils 114cfi := $(call as-instr,.cfi_startproc\n.cfi_val_offset 15$(comma)-160\n.cfi_endproc,-DCONFIG_AS_CFI_VAL_OFFSET=1) 115 116KBUILD_CFLAGS += -mpacked-stack -mbackchain -msoft-float $(cflags-y) 117KBUILD_CFLAGS += -pipe -Wno-sign-compare 118KBUILD_CFLAGS += -fno-asynchronous-unwind-tables $(cfi) 119KBUILD_AFLAGS += $(aflags-y) $(cfi) 120export KBUILD_AFLAGS_DECOMPRESSOR 121export KBUILD_CFLAGS_DECOMPRESSOR 122 123OBJCOPYFLAGS := -O binary 124 125libs-y += arch/s390/lib/ 126 127boot := arch/s390/boot 128syscalls := arch/s390/kernel/syscalls 129tools := arch/s390/tools 130 131all: bzImage 132 133#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg... 134KBUILD_IMAGE := $(boot)/bzImage 135 136install: 137 $(call cmd,install) 138 139bzImage: vmlinux 140 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 141 142zfcpdump: 143 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 144 145archheaders: 146 $(Q)$(MAKE) $(build)=$(syscalls) all 147 148archprepare: 149 $(Q)$(MAKE) $(build)=$(tools) kapi $(extra_tools) 150ifeq ($(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/vdso include/generated/vdso-offsets.h 160 161vdso-install-y += arch/s390/kernel/vdso/vdso.so.dbg 162 163endif 164 165# Don't use tabs in echo arguments 166define archhelp 167 echo '* bzImage - Kernel image for IPL ($(boot)/bzImage)' 168 echo ' install - Install kernel using' 169 echo ' (your) ~/bin/$(INSTALLKERNEL) or' 170 echo ' (distribution) /sbin/$(INSTALLKERNEL) or' 171 echo ' install to $$(INSTALL_PATH)' 172endef 173