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

Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild

Pull kbuild updates from Michal Marek.

Fixed up nontrivial merge conflict in Makefile as per Stephen Rothwell
and linux-next (and trivial arch/sparc/Makefile changes due to removed
sparc32 logic).

* 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
mips: Fix KBUILD_CPPFLAGS definition
kbuild: fix ia64 link
kbuild: document KBUILD_LDS, KBUILD_VMLINUX_{INIT,MAIN} and LDFLAGS_vmlinux
kbuild: link of vmlinux moved to a script
kbuild: refactor final link of sparc32
kbuild: drop unused KBUILD_VMLINUX_OBJS from top-level Makefile
kbuild: Makefile: remove unnecessary check for m68knommu ARCH

+259 -227
+19
Documentation/kbuild/kbuild.txt
··· 50 50 -------------------------------------------------- 51 51 Additional options used for $(LD) when linking modules. 52 52 53 + LDFLAGS_vmlinux 54 + -------------------------------------------------- 55 + Additional options passed to final link of vmlinux. 56 + 53 57 KBUILD_VERBOSE 54 58 -------------------------------------------------- 55 59 Set the kbuild verbosity. Can be assigned same values as "V=...". ··· 218 214 These two variables allow to override the user@host string displayed during 219 215 boot and in /proc/version. The default value is the output of the commands 220 216 whoami and host, respectively. 217 + 218 + KBUILD_LDS 219 + -------------------------------------------------- 220 + The linker script with full path. Assigned by the top-level Makefile. 221 + 222 + KBUILD_VMLINUX_INIT 223 + -------------------------------------------------- 224 + All object files for the init (first) part of vmlinux. 225 + Files specified with KBUILD_VMLINUX_INIT are linked first. 226 + 227 + KBUILD_VMLINUX_MAIN 228 + -------------------------------------------------- 229 + All object files for the main part of vmlinux. 230 + KBUILD_VMLINUX_INIT and KBUILD_VMLINUX_MAIN together specify 231 + all the object files used to link vmlinux.
+15 -216
Makefile
··· 231 231 # Where to locate arch specific headers 232 232 hdr-arch := $(SRCARCH) 233 233 234 - ifeq ($(ARCH),m68knommu) 235 - hdr-arch := m68k 236 - endif 237 - 238 234 KCONFIG_CONFIG ?= .config 239 235 export KCONFIG_CONFIG 240 236 ··· 337 341 GENKSYMS = scripts/genksyms/genksyms 338 342 INSTALLKERNEL := installkernel 339 343 DEPMOD = /sbin/depmod 340 - KALLSYMS = scripts/kallsyms 341 344 PERL = perl 342 345 CHECK = sparse 343 346 ··· 734 739 libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y)) 735 740 libs-y := $(libs-y1) $(libs-y2) 736 741 737 - # Build vmlinux 738 - # --------------------------------------------------------------------------- 739 - # vmlinux is built from the objects selected by $(vmlinux-init) and 740 - # $(vmlinux-main). Most are built-in.o files from top-level directories 741 - # in the kernel tree, others are specified in arch/$(ARCH)/Makefile. 742 - # Ordering when linking is important, and $(vmlinux-init) must be first. 743 - # 744 - # vmlinux 745 - # ^ 746 - # | 747 - # +-< $(vmlinux-init) 748 - # | +--< init/version.o + more 749 - # | 750 - # +--< $(vmlinux-main) 751 - # | +--< driver/built-in.o mm/built-in.o + more 752 - # | 753 - # +-< kallsyms.o (see description in CONFIG_KALLSYMS section) 754 - # 755 - # vmlinux version (uname -v) cannot be updated during normal 756 - # descending-into-subdirs phase since we do not yet know if we need to 757 - # update vmlinux. 758 - # Therefore this step is delayed until just before final link of vmlinux - 759 - # except in the kallsyms case where it is done just before adding the 760 - # symbols to the kernel. 761 - # 762 - # System.map is generated to document addresses of all kernel symbols 742 + # Externally visible symbols (used by link-vmlinux.sh) 743 + export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) 744 + export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y) 745 + export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds 746 + export LDFLAGS_vmlinux 763 747 764 - vmlinux-init := $(head-y) $(init-y) 765 - vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) 766 - vmlinux-all := $(vmlinux-init) $(vmlinux-main) 767 - vmlinux-lds := arch/$(SRCARCH)/kernel/vmlinux.lds 768 - export KBUILD_VMLINUX_OBJS := $(vmlinux-all) 748 + vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) 769 749 770 - # Rule to link vmlinux - also used during CONFIG_KALLSYMS 771 - # May be overridden by arch/$(ARCH)/Makefile 772 - quiet_cmd_vmlinux__ ?= LD $@ 773 - cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \ 774 - -T $(vmlinux-lds) $(vmlinux-init) \ 775 - --start-group $(vmlinux-main) --end-group \ 776 - $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o FORCE ,$^) 750 + # Final link of vmlinux 751 + cmd_link-vmlinux = $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) 752 + quiet_cmd_link-vmlinux = LINK $@ 777 753 778 - # Generate new vmlinux version 779 - quiet_cmd_vmlinux_version = GEN .version 780 - cmd_vmlinux_version = set -e; \ 781 - if [ ! -r .version ]; then \ 782 - rm -f .version; \ 783 - echo 1 >.version; \ 784 - else \ 785 - mv .version .old_version; \ 786 - expr 0$$(cat .old_version) + 1 >.version; \ 787 - fi; \ 788 - $(MAKE) $(build)=init 789 - 790 - # Generate System.map 791 - quiet_cmd_sysmap = SYSMAP 792 - cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap 793 - 794 - # Sort exception table at build time 795 - quiet_cmd_sortextable = SORTEX 796 - cmd_sortextable = $(objtree)/scripts/sortextable 797 - 798 - # Link of vmlinux 799 - # If CONFIG_KALLSYMS is set .version is already updated 800 - # Generate System.map and verify that the content is consistent 801 - # Use + in front of the vmlinux_version rule to silent warning with make -j2 802 - # First command is ':' to allow us to use + in front of the rule 803 - define rule_vmlinux__ 804 - : 805 - $(if $(CONFIG_KALLSYMS),,+$(call cmd,vmlinux_version)) 806 - 807 - $(call cmd,vmlinux__) 808 - $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd 809 - 810 - $(if $(CONFIG_BUILDTIME_EXTABLE_SORT), \ 811 - $(Q)$(if $($(quiet)cmd_sortextable), \ 812 - echo ' $($(quiet)cmd_sortextable) vmlinux' &&) \ 813 - $(cmd_sortextable) vmlinux) 814 - 815 - 816 - $(Q)$(if $($(quiet)cmd_sysmap), \ 817 - echo ' $($(quiet)cmd_sysmap) System.map' &&) \ 818 - $(cmd_sysmap) $@ System.map; \ 819 - if [ $$? -ne 0 ]; then \ 820 - rm -f $@; \ 821 - /bin/false; \ 822 - fi; 823 - $(verify_kallsyms) 824 - endef 825 - 826 - 827 - ifdef CONFIG_KALLSYMS 828 - # Generate section listing all symbols and add it into vmlinux $(kallsyms.o) 829 - # It's a three stage process: 830 - # o .tmp_vmlinux1 has all symbols and sections, but __kallsyms is 831 - # empty 832 - # Running kallsyms on that gives us .tmp_kallsyms1.o with 833 - # the right size - vmlinux version (uname -v) is updated during this step 834 - # o .tmp_vmlinux2 now has a __kallsyms section of the right size, 835 - # but due to the added section, some addresses have shifted. 836 - # From here, we generate a correct .tmp_kallsyms2.o 837 - # o The correct .tmp_kallsyms2.o is linked into the final vmlinux. 838 - # o Verify that the System.map from vmlinux matches the map from 839 - # .tmp_vmlinux2, just in case we did not generate kallsyms correctly. 840 - # o If 'make KALLSYMS_EXTRA_PASS=1" was used, do an extra pass using 841 - # .tmp_vmlinux3 and .tmp_kallsyms3.o. This is only meant as a 842 - # temporary bypass to allow the kernel to be built while the 843 - # maintainers work out what went wrong with kallsyms. 844 - 845 - last_kallsyms := 2 846 - 847 - ifdef KALLSYMS_EXTRA_PASS 848 - ifneq ($(KALLSYMS_EXTRA_PASS),0) 849 - last_kallsyms := 3 850 - endif 851 - endif 852 - 853 - kallsyms.o := .tmp_kallsyms$(last_kallsyms).o 854 - 855 - define verify_kallsyms 856 - $(Q)$(if $($(quiet)cmd_sysmap), \ 857 - echo ' $($(quiet)cmd_sysmap) .tmp_System.map' &&) \ 858 - $(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map 859 - $(Q)cmp -s System.map .tmp_System.map || \ 860 - (echo Inconsistent kallsyms data; \ 861 - echo This is a bug - please report about it; \ 862 - echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround; \ 863 - rm .tmp_kallsyms* ; /bin/false ) 864 - endef 865 - 866 - # Update vmlinux version before link 867 - # Use + in front of this rule to silent warning about make -j1 868 - # First command is ':' to allow us to use + in front of this rule 869 - cmd_ksym_ld = $(cmd_vmlinux__) 870 - define rule_ksym_ld 871 - : 872 - +$(call cmd,vmlinux_version) 873 - $(call cmd,vmlinux__) 874 - $(Q)echo 'cmd_$@ := $(cmd_vmlinux__)' > $(@D)/.$(@F).cmd 875 - endef 876 - 877 - # Generate .S file with all kernel symbols 878 - quiet_cmd_kallsyms = KSYM $@ 879 - cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \ 880 - $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@ 881 - 882 - .tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE 883 - $(call if_changed_dep,as_o_S) 884 - 885 - .tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS) 886 - $(call cmd,kallsyms) 887 - 888 - # .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version 889 - .tmp_vmlinux1: $(vmlinux-lds) $(vmlinux-all) FORCE 890 - $(call if_changed_rule,ksym_ld) 891 - 892 - .tmp_vmlinux2: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms1.o FORCE 893 - $(call if_changed,vmlinux__) 894 - 895 - .tmp_vmlinux3: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms2.o FORCE 896 - $(call if_changed,vmlinux__) 897 - 898 - # Needs to visit scripts/ before $(KALLSYMS) can be used. 899 - $(KALLSYMS): scripts ; 900 - 901 - # Generate some data for debugging strange kallsyms problems 902 - debug_kallsyms: .tmp_map$(last_kallsyms) 903 - 904 - .tmp_map%: .tmp_vmlinux% FORCE 905 - ($(OBJDUMP) -h $< | $(AWK) '/^ +[0-9]/{print $$4 " 0 " $$2}'; $(NM) $<) | sort > $@ 906 - 907 - .tmp_map3: .tmp_map2 908 - 909 - .tmp_map2: .tmp_map1 910 - 911 - endif # ifdef CONFIG_KALLSYMS 912 - 913 - # Do modpost on a prelinked vmlinux. The finally linked vmlinux has 914 - # relevant sections renamed as per the linker script. 915 - quiet_cmd_vmlinux-modpost = LD $@ 916 - cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \ 917 - $(vmlinux-init) --start-group $(vmlinux-main) --end-group \ 918 - $(filter-out $(vmlinux-init) $(vmlinux-main) FORCE ,$^) 919 - define rule_vmlinux-modpost 920 - : 921 - +$(call cmd,vmlinux-modpost) 922 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@ 923 - $(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd 924 - endef 925 - 926 - # vmlinux image - including updated kernel symbols 927 - vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCE 754 + # Include targets which we want to 755 + # execute if the rest of the kernel build went well. 756 + vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE 928 757 ifdef CONFIG_HEADERS_CHECK 929 758 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 930 759 endif ··· 758 939 ifdef CONFIG_BUILD_DOCSRC 759 940 $(Q)$(MAKE) $(build)=Documentation 760 941 endif 761 - $(call vmlinux-modpost) 762 - $(call if_changed_rule,vmlinux__) 763 - $(Q)rm -f .old_version 764 - 765 - # build vmlinux.o first to catch section mismatch errors early 766 - ifdef CONFIG_KALLSYMS 767 - .tmp_vmlinux1: vmlinux.o 768 - endif 769 - 770 - modpost-init := $(filter-out init/built-in.o, $(vmlinux-init)) 771 - vmlinux.o: $(modpost-init) $(vmlinux-main) FORCE 772 - $(call if_changed_rule,vmlinux-modpost) 942 + +$(call if_changed,link-vmlinux) 773 943 774 944 # The actual objects are generated when descending, 775 945 # make sure no implicit rule kicks in 776 - $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ; 946 + $(sort $(vmlinux-deps)): $(vmlinux-dirs) ; 777 947 778 948 # Handle descending into subdirectories listed in $(vmlinux-dirs) 779 949 # Preset locale variables to speed up the build process. Limit locale ··· 989 1181 990 1182 # Directories & files removed with 'make clean' 991 1183 CLEAN_DIRS += $(MODVERDIR) 992 - CLEAN_FILES += vmlinux System.map \ 993 - .tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map 994 1184 995 1185 # Directories & files removed with 'make mrproper' 996 1186 MRPROPER_DIRS += include/config usr/include include/generated \ ··· 1234 1428 endif # KBUILD_EXTMOD 1235 1429 1236 1430 clean: $(clean-dirs) 1431 + $(Q)$(CONFIG_SHELL) $(srctree)/scripts/link-vmlinux.sh clean 1237 1432 $(call cmd,rmdirs) 1238 1433 $(call cmd,rmfiles) 1239 1434 @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ ··· 1374 1567 # clean it up only when building all modules 1375 1568 cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ 1376 1569 $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) 1377 - 1378 - a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \ 1379 - $(KBUILD_AFLAGS_KERNEL) \ 1380 - $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \ 1381 - $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o) 1382 - 1383 - quiet_cmd_as_o_S = AS $@ 1384 - cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 1385 1570 1386 1571 # read all saved command lines 1387 1572
+2 -2
arch/mips/Makefile
··· 219 219 220 220 KBUILD_AFLAGS += $(cflags-y) 221 221 KBUILD_CFLAGS += $(cflags-y) 222 - KBUILD_CPPFLAGS += -D"VMLINUX_LOAD_ADDRESS=$(load-y)" 223 - KBUILD_CPPFLAGS += -D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)" 222 + KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) 223 + KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0) 224 224 225 225 LDFLAGS += -m $(ld-emul) 226 226
+2 -9
arch/um/Makefile
··· 121 121 122 122 LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) 123 123 124 - CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) 125 - define cmd_vmlinux__ 126 - $(CC) $(CFLAGS_vmlinux) -o $@ \ 127 - -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \ 128 - -Wl,--start-group $(vmlinux-main) -Wl,--end-group \ 129 - -lutil \ 130 - $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \ 131 - FORCE ,$^) ; rm -f linux 132 - endef 124 + # Used by link-vmlinux.sh which has special support for um link 125 + export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) 133 126 134 127 # When cleaning we don't include .config, so we don't include 135 128 # TT or skas makefiles and don't clean skas_ptregs.h.