Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm, cris, mips, sparc, powerpc, um, xtensa: fix build with bash 4.0

Albin Tonnerre <albin.tonnerre@free-electrons.com> reported:

Bash 4 filters out variables which contain a dot in them.
This happends to be the case of CPPFLAGS_vmlinux.lds.
This is rather unfortunate, as it now causes
build failures when using SHELL=/bin/bash to compile,
or when bash happens to be used by make (eg when it's /bin/sh)

Remove the common definition of CPPFLAGS_vmlinux.lds by
pushing relevant stuff to either Makefile.build or the
arch specific kernel/Makefile where we build the linker script.

This is also nice cleanup as we move the information out where
it is used.

Notes for the different architectures touched:

arm - we use an already exported symbol
cris - we use a config symbol aleady available
[Not build tested]
mips - the jiffies complexity has moved to vmlinux.lds.S where we need it.
Added a few variables to CPPFLAGS - they are only used by
the linker script.
[Not build tested]
powerpc - removed assignment that is not needed
[not build tested]
sparc - simplified it using $(BITS)
um - introduced a few new exported variables to deal with this
xtensa - added options to CPP invocation
[not build tested]

Cc: Albin Tonnerre <albin.tonnerre@free-electrons.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Mikael Starvik <starvik@axis.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

+37 -49
-5
Makefile
··· 1027 1027 # All the preparing.. 1028 1028 prepare: prepare0 1029 1029 1030 - # Leave this as default for preprocessing vmlinux.lds.S, which is now 1031 - # done in arch/$(ARCH)/kernel/Makefile 1032 - 1033 - export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) 1034 - 1035 1030 # The asm symlink changes when $(ARCH) changes. 1036 1031 # Detect this and ask user to run make mrproper 1037 1032 # If asm is a stale symlink (point to dir that does not exist) remove it
+1 -1
arch/arm/Makefile
··· 14 14 ifeq ($(CONFIG_CPU_ENDIAN_BE8),y) 15 15 LDFLAGS_vmlinux += --be8 16 16 endif 17 - CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET) 17 + 18 18 OBJCOPYFLAGS :=-O binary -R .note -R .note.gnu.build-id -R .comment -S 19 19 GZFLAGS :=-9 20 20 #KBUILD_CFLAGS +=-pipe
+2 -1
arch/arm/kernel/Makefile
··· 2 2 # Makefile for the linux kernel. 3 3 # 4 4 5 - AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 5 + CPPFLAGS_vmlinux.lds := -DTEXT_OFFSET=$(TEXT_OFFSET) 6 + AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 6 7 7 8 ifdef CONFIG_DYNAMIC_FTRACE 8 9 CFLAGS_REMOVE_ftrace.o = -pg
-2
arch/cris/Makefile
··· 42 42 43 43 OBJCOPYFLAGS := -O binary -R .note -R .comment -S 44 44 45 - CPPFLAGS_vmlinux.lds = -DDRAM_VIRTUAL_BASE=0x$(CONFIG_ETRAX_DRAM_VIRTUAL_BASE) 46 - 47 45 KBUILD_AFLAGS += -mlinux -march=$(arch-y) $(inc) 48 46 KBUILD_CFLAGS += -mlinux -march=$(arch-y) -pipe $(inc) 49 47 KBUILD_CPPFLAGS += $(inc)
+1
arch/cris/kernel/Makefile
··· 3 3 # Makefile for the linux kernel. 4 4 # 5 5 6 + CPPFLAGS_vmlinux.lds := -DDRAM_VIRTUAL_BASE=0x$(CONFIG_ETRAX_DRAM_VIRTUAL_BASE) 6 7 extra-y := vmlinux.lds 7 8 8 9 obj-y := process.o traps.o irq.o ptrace.o setup.o time.o sys_cris.o
+3 -24
arch/mips/Makefile
··· 627 627 cflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic 628 628 drivers-$(CONFIG_PCI) += arch/mips/pci/ 629 629 630 - ifdef CONFIG_32BIT 631 - ifdef CONFIG_CPU_LITTLE_ENDIAN 632 - JIFFIES = jiffies_64 633 - else 634 - JIFFIES = jiffies_64 + 4 635 - endif 636 - else 637 - JIFFIES = jiffies_64 638 - endif 639 - 640 630 # 641 631 # Automatically detect the build format. By default we choose 642 632 # the elf format according to the load address. ··· 650 660 endif 651 661 652 662 KBUILD_AFLAGS += $(cflags-y) 653 - KBUILD_CFLAGS += $(cflags-y) \ 654 - -D"VMLINUX_LOAD_ADDRESS=$(load-y)" 663 + KBUILD_CFLAGS += $(cflags-y) 664 + KBUILD_CPPFLAGS += -D"VMLINUX_LOAD_ADDRESS=$(load-y)" 665 + KBUILD_CPPFLAGS += -D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)" 655 666 656 667 LDFLAGS += -m $(ld-emul) 657 668 ··· 666 675 endif 667 676 668 677 OBJCOPYFLAGS += --remove-section=.reginfo 669 - 670 - # 671 - # Choosing incompatible machines durings configuration will result in 672 - # error messages during linking. Select a default linkscript if 673 - # none has been choosen above. 674 - # 675 - 676 - CPPFLAGS_vmlinux.lds := \ 677 - $(KBUILD_CFLAGS) \ 678 - -D"LOADADDR=$(load-y)" \ 679 - -D"JIFFIES=$(JIFFIES)" \ 680 - -D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)" 681 678 682 679 head-y := arch/mips/kernel/head.o arch/mips/kernel/init_task.o 683 680
+11 -2
arch/mips/kernel/vmlinux.lds.S
··· 10 10 text PT_LOAD FLAGS(7); /* RWX */ 11 11 note PT_NOTE FLAGS(4); /* R__ */ 12 12 } 13 - jiffies = JIFFIES; 13 + 14 + ifdef CONFIG_32BIT 15 + ifdef CONFIG_CPU_LITTLE_ENDIAN 16 + jiffies = jiffies_64; 17 + else 18 + jiffies = jiffies_64 + 4; 19 + endif 20 + else 21 + jiffies = jiffies_64; 22 + endif 14 23 15 24 SECTIONS 16 25 { ··· 38 29 /* . = 0xa800000000300000; */ 39 30 . = 0xffffffff80300000; 40 31 #endif 41 - . = LOADADDR; 32 + . = VMLINUX_LOAD_ADDRESS; 42 33 /* read-only */ 43 34 _text = .; /* Text and read-only data */ 44 35 .text : {
-2
arch/powerpc/Makefile
··· 158 158 # Default to zImage, override when needed 159 159 all: zImage 160 160 161 - CPPFLAGS_vmlinux.lds := -Upowerpc 162 - 163 161 BOOT_TARGETS = zImage zImage.initrd uImage zImage% dtbImage% treeImage.% cuImage.% simpleImage.% 164 162 165 163 PHONY += $(BOOT_TARGETS)
-4
arch/sparc/Makefile
··· 31 31 #KBUILD_CFLAGS += -g -pipe -fcall-used-g5 -fcall-used-g7 32 32 KBUILD_CFLAGS += -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 33 33 KBUILD_AFLAGS += -m32 34 - CPPFLAGS_vmlinux.lds += -m32 35 34 36 35 #LDFLAGS_vmlinux = -N -Ttext 0xf0004000 37 36 # Since 2.5.40, the first stage is left not btfix-ed. ··· 44 45 45 46 CHECKFLAGS += -D__sparc__ -D__sparc_v9__ -D__arch64__ -m64 46 47 47 - # Undefine sparc when processing vmlinux.lds - it is used 48 - # And teach CPP we are doing 64 bit builds (for this case) 49 - CPPFLAGS_vmlinux.lds += -m64 -Usparc 50 48 LDFLAGS := -m elf64_sparc 51 49 export BITS := 64 52 50
+5 -1
arch/sparc/kernel/Makefile
··· 7 7 8 8 extra-y := head_$(BITS).o 9 9 extra-y += init_task.o 10 - extra-y += vmlinux.lds 10 + 11 + # Undefine sparc when processing vmlinux.lds - it is used 12 + # And teach CPP we are doing $(BITS) builds (for this case) 13 + CPPFLAGS_vmlinux.lds := -Usparc -m$(BITS) 14 + extra-y += vmlinux.lds 11 15 12 16 obj-$(CONFIG_SPARC32) += entry.o wof.o wuf.o 13 17 obj-$(CONFIG_SPARC32) += etrap_32.o
+4 -5
arch/um/Makefile
··· 96 96 $(call cc-option, -fno-stack-protector,) \ 97 97 $(call cc-option, -fno-stack-protector-all,) 98 98 99 - CONFIG_KERNEL_STACK_ORDER ?= 2 100 - STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] ) 101 - 102 - CPPFLAGS_vmlinux.lds = -U$(SUBARCH) -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \ 103 - -DELF_FORMAT="$(ELF_FORMAT)" -DKERNEL_STACK_SIZE=$(STACK_SIZE) 99 + # Options used by linker script 100 + export LDS_START := $(START) 101 + export LDS_ELF_ARCH := $(ELF_ARCH) 102 + export LDS_ELF_FORMAT := $(ELF_FORMAT) 104 103 105 104 # The wrappers will select whether using "malloc" or the kernel allocator. 106 105 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
+3
arch/um/kernel/Makefile
··· 3 3 # Licensed under the GPL 4 4 # 5 5 6 + CPPFLAGS_vmlinux.lds := -U$(SUBARCH) -DSTART=$(LDS_START) \ 7 + -DELF_ARCH=$(LDS_ELF_ARCH) \ 8 + -DELF_FORMAT=$(LDS_ELF_FORMAT) 6 9 extra-y := vmlinux.lds 7 10 clean-files := 8 11
+3
arch/um/kernel/vmlinux.lds.S
··· 1 + 2 + KERNEL_STACK_SIZE = 4096 * (1 << CONFIG_KERNEL_STACK_ORDER); 3 + 1 4 #ifdef CONFIG_LD_SCRIPT_STATIC 2 5 #include "uml.lds.S" 3 6 #else
+2 -1
arch/xtensa/kernel/Makefile
··· 27 27 -e 's/(\(\.text\.[a-z]*\))/(\1.literal \1)/g' 28 28 29 29 quiet_cmd__cpp_lds_S = LDS $@ 30 - cmd__cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ $< | sed $(sed-y) >$@ 30 + cmd__cpp_lds_S = $(CPP) $(cpp_flags) -P -C -Uxtensa -D__ASSEMBLY__ $< \ 31 + | sed $(sed-y) >$@ 31 32 32 33 $(obj)/vmlinux.lds: $(src)/vmlinux.lds.S FORCE 33 34 $(call if_changed_dep,_cpp_lds_S)
+2 -1
scripts/Makefile.build
··· 270 270 # Linker scripts preprocessor (.lds.S -> .lds) 271 271 # --------------------------------------------------------------------------- 272 272 quiet_cmd_cpp_lds_S = LDS $@ 273 - cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $< 273 + cmd_cpp_lds_S = $(CPP) $(cpp_flags) -P -C -U$(ARCH) \ 274 + -D__ASSEMBLY__ -o $@ $< 274 275 275 276 $(obj)/%.lds: $(src)/%.lds.S FORCE 276 277 $(call if_changed_dep,cpp_lds_S)