~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/riscv/Makefile

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 # This file is included by the global makefile so that you can add your own
  2 # architecture-specific flags and dependencies.
  3 #
  4 # This file is subject to the terms and conditions of the GNU General Public
  5 # License.  See the file "COPYING" in the main directory of this archive
  6 # for more details.
  7 #
  8 
  9 LDFLAGS_vmlinux := -z norelro
 10 ifeq ($(CONFIG_RELOCATABLE),y)
 11         LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs
 12         KBUILD_CFLAGS += -fPIE
 13 endif
 14 ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
 15         LDFLAGS_vmlinux += --no-relax
 16         KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
 17 ifeq ($(CONFIG_RISCV_ISA_C),y)
 18         CC_FLAGS_FTRACE := -fpatchable-function-entry=4
 19 else
 20         CC_FLAGS_FTRACE := -fpatchable-function-entry=2
 21 endif
 22 endif
 23 
 24 ifeq ($(CONFIG_CMODEL_MEDLOW),y)
 25 KBUILD_CFLAGS_MODULE += -mcmodel=medany
 26 endif
 27 
 28 export BITS
 29 ifeq ($(CONFIG_ARCH_RV64I),y)
 30         BITS := 64
 31         UTS_MACHINE := riscv64
 32 
 33         KBUILD_CFLAGS += -mabi=lp64
 34         KBUILD_AFLAGS += -mabi=lp64
 35 
 36         KBUILD_LDFLAGS += -melf64lriscv
 37 
 38         KBUILD_RUSTFLAGS += -Ctarget-cpu=generic-rv64 --target=riscv64imac-unknown-none-elf \
 39                             -Cno-redzone
 40 else
 41         BITS := 32
 42         UTS_MACHINE := riscv32
 43 
 44         KBUILD_CFLAGS += -mabi=ilp32
 45         KBUILD_AFLAGS += -mabi=ilp32
 46         KBUILD_LDFLAGS += -melf32lriscv
 47 endif
 48 
 49 ifndef CONFIG_RISCV_USE_LINKER_RELAXATION
 50         KBUILD_CFLAGS += -mno-relax
 51         KBUILD_AFLAGS += -mno-relax
 52 ifndef CONFIG_AS_IS_LLVM
 53         KBUILD_CFLAGS += -Wa,-mno-relax
 54         KBUILD_AFLAGS += -Wa,-mno-relax
 55 endif
 56 # LLVM has an issue with target-features and LTO: https://github.com/llvm/llvm-project/issues/59350
 57 # Ensure it is aware of linker relaxation with LTO, otherwise relocations may
 58 # be incorrect: https://github.com/llvm/llvm-project/issues/65090
 59 else ifeq ($(CONFIG_LTO_CLANG),y)
 60         KBUILD_LDFLAGS += -mllvm -mattr=+c -mllvm -mattr=+relax
 61 endif
 62 
 63 ifeq ($(CONFIG_SHADOW_CALL_STACK),y)
 64         KBUILD_LDFLAGS += --no-relax-gp
 65 endif
 66 
 67 # ISA string setting
 68 riscv-march-$(CONFIG_ARCH_RV32I)        := rv32ima
 69 riscv-march-$(CONFIG_ARCH_RV64I)        := rv64ima
 70 riscv-march-$(CONFIG_FPU)               := $(riscv-march-y)fd
 71 riscv-march-$(CONFIG_RISCV_ISA_C)       := $(riscv-march-y)c
 72 riscv-march-$(CONFIG_RISCV_ISA_V)       := $(riscv-march-y)v
 73 
 74 ifneq ($(CONFIG_RISCV_ISA_C),y)
 75         KBUILD_RUSTFLAGS += -Ctarget-feature=-c
 76 endif
 77 
 78 ifdef CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC
 79 KBUILD_CFLAGS += -Wa,-misa-spec=2.2
 80 KBUILD_AFLAGS += -Wa,-misa-spec=2.2
 81 else
 82 riscv-march-$(CONFIG_TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI) := $(riscv-march-y)_zicsr_zifencei
 83 endif
 84 
 85 # Remove F,D,V from isa string for all. Keep extensions between "fd" and "v" by
 86 # matching non-v and non-multi-letter extensions out with the filter ([^v_]*)
 87 KBUILD_CFLAGS += -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)fd([^v_]*)v?/\1\2/')
 88 
 89 KBUILD_AFLAGS += -march=$(riscv-march-y)
 90 
 91 # For C code built with floating-point support, exclude V but keep F and D.
 92 CC_FLAGS_FPU  := -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)([^v_]*)v?/\1\2/')
 93 
 94 KBUILD_CFLAGS += -mno-save-restore
 95 KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET)
 96 
 97 ifeq ($(CONFIG_CMODEL_MEDLOW),y)
 98         KBUILD_CFLAGS += -mcmodel=medlow
 99 endif
100 ifeq ($(CONFIG_CMODEL_MEDANY),y)
101         KBUILD_CFLAGS += -mcmodel=medany
102 endif
103 
104 # Avoid generating .eh_frame sections.
105 KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables
106 
107 # The RISC-V attributes frequently cause compatibility issues and provide no
108 # information, so just turn them off.
109 KBUILD_CFLAGS += $(call cc-option,-mno-riscv-attribute)
110 KBUILD_AFLAGS += $(call cc-option,-mno-riscv-attribute)
111 KBUILD_CFLAGS += $(call as-option,-Wa$(comma)-mno-arch-attr)
112 KBUILD_AFLAGS += $(call as-option,-Wa$(comma)-mno-arch-attr)
113 
114 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
115 KBUILD_AFLAGS_MODULE += $(call as-option,-Wa$(comma)-mno-relax)
116 
117 # GCC versions that support the "-mstrict-align" option default to allowing
118 # unaligned accesses.  While unaligned accesses are explicitly allowed in the
119 # RISC-V ISA, they're emulated by machine mode traps on all extant
120 # architectures.  It's faster to have GCC emit only aligned accesses.
121 ifneq ($(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS),y)
122 KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
123 endif
124 
125 ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y)
126 prepare: stack_protector_prepare
127 stack_protector_prepare: prepare0
128         $(eval KBUILD_CFLAGS += -mstack-protector-guard=tls               \
129                                 -mstack-protector-guard-reg=tp            \
130                                 -mstack-protector-guard-offset=$(shell    \
131                         awk '{if ($$2 == "TSK_STACK_CANARY") print $$3;}' \
132                                         include/generated/asm-offsets.h))
133 endif
134 
135 # arch specific predefines for sparse
136 CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
137 
138 # Default target when executing plain make
139 boot            := arch/riscv/boot
140 ifeq ($(CONFIG_XIP_KERNEL),y)
141 KBUILD_IMAGE := $(boot)/xipImage
142 else
143 ifeq ($(CONFIG_RISCV_M_MODE)$(CONFIG_SOC_CANAAN_K210),yy)
144 KBUILD_IMAGE := $(boot)/loader.bin
145 else
146 ifeq ($(CONFIG_EFI_ZBOOT),)
147 KBUILD_IMAGE    := $(boot)/Image.gz
148 else
149 KBUILD_IMAGE := $(boot)/vmlinuz.efi
150 endif
151 endif
152 endif
153 
154 boot                                    := arch/riscv/boot
155 boot-image-y                            := Image
156 boot-image-$(CONFIG_KERNEL_BZIP2)       := Image.bz2
157 boot-image-$(CONFIG_KERNEL_GZIP)        := Image.gz
158 boot-image-$(CONFIG_KERNEL_LZ4)         := Image.lz4
159 boot-image-$(CONFIG_KERNEL_LZMA)        := Image.lzma
160 boot-image-$(CONFIG_KERNEL_LZO)         := Image.lzo
161 boot-image-$(CONFIG_KERNEL_ZSTD)        := Image.zst
162 boot-image-$(CONFIG_KERNEL_XZ)          := Image.xz
163 ifdef CONFIG_RISCV_M_MODE
164 boot-image-$(CONFIG_ARCH_CANAAN)        := loader.bin
165 endif
166 boot-image-$(CONFIG_EFI_ZBOOT)          := vmlinuz.efi
167 boot-image-$(CONFIG_XIP_KERNEL)         := xipImage
168 KBUILD_IMAGE                            := $(boot)/$(boot-image-y)
169 
170 libs-y += arch/riscv/lib/
171 libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a
172 
173 ifeq ($(KBUILD_EXTMOD),)
174 ifeq ($(CONFIG_MMU),y)
175 prepare: vdso_prepare
176 vdso_prepare: prepare0
177         $(Q)$(MAKE) $(build)=arch/riscv/kernel/vdso include/generated/vdso-offsets.h
178         $(if $(CONFIG_COMPAT),$(Q)$(MAKE) \
179                 $(build)=arch/riscv/kernel/compat_vdso include/generated/compat_vdso-offsets.h)
180 
181 endif
182 endif
183 
184 vdso-install-y                  += arch/riscv/kernel/vdso/vdso.so.dbg
185 vdso-install-$(CONFIG_COMPAT)   += arch/riscv/kernel/compat_vdso/compat_vdso.so.dbg
186 
187 BOOT_TARGETS := Image Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst Image.xz loader loader.bin xipImage vmlinuz.efi
188 
189 all:    $(notdir $(KBUILD_IMAGE))
190 
191 loader.bin: loader
192 Image.gz Image.bz2 Image.lz4 Image.lzma Image.lzo Image.zst Image.xz loader xipImage vmlinuz.efi: Image
193 
194 $(BOOT_TARGETS): vmlinux
195         $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
196         @$(kecho) '  Kernel: $(boot)/$@ is ready'
197 
198 # the install target always installs KBUILD_IMAGE (which may be compressed)
199 # but keep the zinstall target for compatibility with older releases
200 install zinstall:
201         $(call cmd,install)
202 
203 PHONY += rv32_randconfig
204 rv32_randconfig:
205         $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/riscv/configs/32-bit.config \
206                 -f $(srctree)/Makefile randconfig
207 
208 PHONY += rv64_randconfig
209 rv64_randconfig:
210         $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/riscv/configs/64-bit.config \
211                 -f $(srctree)/Makefile randconfig
212 
213 PHONY += rv32_defconfig
214 rv32_defconfig:
215         $(Q)$(MAKE) -f $(srctree)/Makefile defconfig 32-bit.config
216 
217 PHONY += rv32_nommu_virt_defconfig
218 rv32_nommu_virt_defconfig:
219         $(Q)$(MAKE) -f $(srctree)/Makefile nommu_virt_defconfig 32-bit.config
220 
221 define archhelp
222   echo  '  Image                - Uncompressed kernel image (arch/riscv/boot/Image)'
223   echo  '  Image.gz     - Compressed kernel image (arch/riscv/boot/Image.gz)'
224   echo  '  Image.bz2    - Compressed kernel image (arch/riscv/boot/Image.bz2)'
225   echo  '  Image.lz4    - Compressed kernel image (arch/riscv/boot/Image.lz4)'
226   echo  '  Image.lzma   - Compressed kernel image (arch/riscv/boot/Image.lzma)'
227   echo  '  Image.lzo    - Compressed kernel image (arch/riscv/boot/Image.lzo)'
228   echo  '  Image.zst    - Compressed kernel image (arch/riscv/boot/Image.zst)'
229   echo  '  Image.xz     - Compressed kernel image (arch/riscv/boot/Image.xz)'
230   echo  '  vmlinuz.efi  - Compressed EFI kernel image (arch/riscv/boot/vmlinuz.efi)'
231   echo  '                 Default when CONFIG_EFI_ZBOOT=y'
232   echo  '  xipImage     - Execute-in-place kernel image (arch/riscv/boot/xipImage)'
233   echo  '                 Default when CONFIG_XIP_KERNEL=y'
234   echo  '  install      - Install kernel using (your) ~/bin/$(INSTALLKERNEL) or'
235   echo  '                 (distribution) /sbin/$(INSTALLKERNEL) or install to '
236   echo  '                 $$(INSTALL_PATH)'
237 endef

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php