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

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

Pull misc kbuild updates from Michal Marek:
"This is the less critical kbuild stuff for v3.18-rc1:

- make deb-pkg debuginfo fix, ppc64el support and warning fix for
recent dpkg tools
- make TAGS fixes
- new coccinelle patch
- kbuild documentation improvements"

* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
deb-pkg: remove obsolete -isp option to dpkg-gencontrol
coccinelle: misc: semantic patch to delete overly complex return code processing
deb-pkg: Add support for powerpc little endian
builddeb: put the dbg files into the correct directory
scripts/tags.sh: fix DEFINE_HASHTABLE in emacs case
scripts/tags.sh: remove *PCGFLAGS regular expressions
scripts/tags.sh: Don't specify kind-spec for emacs' ctags/etags
Documentation: kbuild: Improve grammar
Documentation: kbuild: Remove obsolete dtc_cpp section
Documentation: kbuild: Improve if_changed documentation
Documentation: kbuild: Remove obsolete include/asm symlink step

+228 -82
+35 -59
Documentation/kbuild/makefiles.txt
··· 174 174 175 175 --- 3.3 Loadable module goals - obj-m 176 176 177 - $(obj-m) specify object files which are built as loadable 177 + $(obj-m) specifies object files which are built as loadable 178 178 kernel modules. 179 179 180 180 A module may be built from one source file or several source ··· 277 277 down in the ext2 directory. 278 278 Kbuild only uses this information to decide that it needs to visit 279 279 the directory, it is the Makefile in the subdirectory that 280 - specifies what is modules and what is built-in. 280 + specifies what is modular and what is built-in. 281 281 282 282 It is good practice to use a CONFIG_ variable when assigning directory 283 283 names. This allows kbuild to totally skip the directory if the ··· 403 403 echoing information to user in a rule is often a good practice 404 404 but when execution "make -s" one does not expect to see any output 405 405 except for warnings/errors. 406 - To support this kbuild define $(kecho) which will echo out the 406 + To support this kbuild defines $(kecho) which will echo out the 407 407 text following $(kecho) to stdout except if "make -s" is used. 408 408 409 409 Example: ··· 417 417 418 418 The kernel may be built with several different versions of 419 419 $(CC), each supporting a unique set of features and options. 420 - kbuild provide basic support to check for valid options for $(CC). 420 + kbuild provides basic support to check for valid options for $(CC). 421 421 $(CC) is usually the gcc compiler, but other alternatives are 422 422 available. 423 423 ··· 456 456 Note: as-instr-option uses KBUILD_AFLAGS for $(AS) options 457 457 458 458 cc-option 459 - cc-option is used to check if $(CC) supports a given option, and not 460 - supported to use an optional second option. 459 + cc-option is used to check if $(CC) supports a given option, and if 460 + not supported to use an optional second option. 461 461 462 462 Example: 463 463 #arch/x86/Makefile ··· 557 557 false ; \ 558 558 fi 559 559 560 - In this example for a specific GCC version the build will error out explaining 561 - to the user why it stops. 560 + In this example for a specific GCC version the build will error out 561 + explaining to the user why it stops. 562 562 563 563 cc-cross-prefix 564 564 cc-cross-prefix is used to check if there exists a $(CC) in path with ··· 656 656 In the example above the executable is composed of the C++ file 657 657 qconf.cc - identified by $(qconf-cxxobjs). 658 658 659 - If qconf is composed by a mixture of .c and .cc files, then an 659 + If qconf is composed of a mixture of .c and .cc files, then an 660 660 additional line can be used to identify this. 661 661 662 662 Example: ··· 733 733 hostprogs-$(CONFIG_KALLSYMS) += kallsyms 734 734 735 735 Kbuild knows about both 'y' for built-in and 'm' for module. 736 - So if a config symbol evaluate to 'm', kbuild will still build 736 + So if a config symbol evaluates to 'm', kbuild will still build 737 737 the binary. In other words, Kbuild handles hostprogs-m exactly 738 738 like hostprogs-y. But only hostprogs-y is recommended to be used 739 739 when no CONFIG symbols are involved. ··· 754 754 #drivers/pci/Makefile 755 755 clean-files := devlist.h classlist.h 756 756 757 - When executing "make clean", the two files "devlist.h classlist.h" will 758 - be deleted. Kbuild will assume files to be in same relative directory as the 757 + When executing "make clean", the two files "devlist.h classlist.h" will be 758 + deleted. Kbuild will assume files to be in the same relative directory as the 759 759 Makefile except if an absolute path is specified (path starting with '/'). 760 760 761 761 To delete a directory hierarchy use: ··· 786 786 The above assignment instructs kbuild to descend down in the 787 787 directory compressed/ when "make clean" is executed. 788 788 789 - To support the clean infrastructure in the Makefiles that builds the 789 + To support the clean infrastructure in the Makefiles that build the 790 790 final bootimage there is an optional target named archclean: 791 791 792 792 Example: ··· 818 818 When kbuild executes, the following steps are followed (roughly): 819 819 1) Configuration of the kernel => produce .config 820 820 2) Store kernel version in include/linux/version.h 821 - 3) Symlink include/asm to include/asm-$(ARCH) 822 - 4) Updating all other prerequisites to the target prepare: 821 + 3) Updating all other prerequisites to the target prepare: 823 822 - Additional prerequisites are specified in arch/$(ARCH)/Makefile 824 - 5) Recursively descend down in all directories listed in 823 + 4) Recursively descend down in all directories listed in 825 824 init-* core* drivers-* net-* libs-* and build all targets. 826 825 - The values of the above variables are expanded in arch/$(ARCH)/Makefile. 827 - 6) All object files are then linked and the resulting file vmlinux is 826 + 5) All object files are then linked and the resulting file vmlinux is 828 827 located at the root of the obj tree. 829 828 The very first objects linked are listed in head-y, assigned by 830 829 arch/$(ARCH)/Makefile. 831 - 7) Finally, the architecture-specific part does any required post processing 830 + 6) Finally, the architecture-specific part does any required post processing 832 831 and builds the final bootimage. 833 832 - This includes building boot records 834 833 - Preparing initrd images and the like ··· 926 927 927 928 KBUILD_AFLAGS_MODULE Options for $(AS) when building modules 928 929 929 - $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that 930 + $(KBUILD_AFLAGS_MODULE) is used to add arch-specific options that 930 931 are used for $(AS). 931 932 From commandline AFLAGS_MODULE shall be used (see kbuild.txt). 932 933 ··· 937 938 938 939 KBUILD_CFLAGS_MODULE Options for $(CC) when building modules 939 940 940 - $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that 941 + $(KBUILD_CFLAGS_MODULE) is used to add arch-specific options that 941 942 are used for $(CC). 942 943 From commandline CFLAGS_MODULE shall be used (see kbuild.txt). 943 944 944 945 KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules 945 946 946 - $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options 947 + $(KBUILD_LDFLAGS_MODULE) is used to add arch-specific options 947 948 used when linking modules. This is often a linker script. 948 949 From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). 949 950 ··· 1065 1066 1066 1067 extra-y 1067 1068 1068 - extra-y specify additional targets created in the current 1069 + extra-y specifies additional targets created in the current 1069 1070 directory, in addition to any targets specified by obj-*. 1070 1071 1071 1072 Listing all targets in extra-y is required for two purposes: ··· 1092 1093 1093 1094 Usage: 1094 1095 target: source(s) FORCE 1095 - $(call if_changed,ld/objcopy/gzip) 1096 + $(call if_changed,ld/objcopy/gzip/...) 1096 1097 1097 1098 When the rule is evaluated, it is checked to see if any files 1098 1099 need an update, or the command line has changed since the last ··· 1110 1111 significant; for instance, the below will fail (note the extra space 1111 1112 after the comma): 1112 1113 target: source(s) FORCE 1113 - #WRONG!# $(call if_changed, ld/objcopy/gzip) 1114 + #WRONG!# $(call if_changed, ld/objcopy/gzip/...) 1114 1115 1115 1116 ld 1116 1117 Link target. Often, LDFLAGS_$@ is used to set specific options to ld. ··· 1141 1142 2) delete target during make clean 1142 1143 1143 1144 The ": %: %.o" part of the prerequisite is a shorthand that 1144 - free us from listing the setup.o and bootsect.o files. 1145 - Note: It is a common mistake to forget the "target :=" assignment, 1145 + frees us from listing the setup.o and bootsect.o files. 1146 + Note: It is a common mistake to forget the "targets :=" assignment, 1146 1147 resulting in the target file being recompiled for no 1147 1148 obvious reason. 1148 1149 ··· 1162 1163 targets += $(dtb-y) 1163 1164 clean-files += *.dtb 1164 1165 DTC_FLAGS ?= -p 1024 1165 - 1166 - dtc_cpp 1167 - This is just like dtc as describe above, except that the C pre- 1168 - processor is invoked upon the .dtsp file before compiling the result 1169 - with dtc. 1170 - 1171 - In order for build dependencies to work, all files compiled using 1172 - dtc_cpp must use the C pre-processor's #include functionality and not 1173 - dtc's /include/ functionality. 1174 - 1175 - Using the C pre-processor allows use of #define to create named 1176 - constants. In turn, the #defines will typically appear in a header 1177 - file, which may be shared with regular C code. Since the dtc language 1178 - represents a data structure rather than code in C syntax, similar 1179 - restrictions are placed on a header file included by a device tree 1180 - file as for a header file included by an assembly language file. 1181 - In particular, the C pre-processor is passed -x assembler-with-cpp, 1182 - which sets macro __ASSEMBLY__. __DTS__ is also set. These allow header 1183 - files to restrict their content to that compatible with device tree 1184 - source. 1185 - 1186 - A central rule exists to create $(obj)/%.dtb from $(src)/%.dtsp; 1187 - architecture Makefiles do no need to explicitly write out that rule. 1188 1166 1189 1167 --- 6.8 Custom kbuild commands 1190 1168 ··· 1213 1237 When building the *.lds target, kbuild uses the variables: 1214 1238 KBUILD_CPPFLAGS : Set in top-level Makefile 1215 1239 cppflags-y : May be set in the kbuild makefile 1216 - CPPFLAGS_$(@F) : Target specific flags. 1240 + CPPFLAGS_$(@F) : Target-specific flags. 1217 1241 Note that the full filename is used in this 1218 1242 assignment. 1219 1243 1220 - The kbuild infrastructure for *lds file are used in several 1244 + The kbuild infrastructure for *lds files is used in several 1221 1245 architecture-specific files. 1222 1246 1223 1247 --- 6.10 Generic header files ··· 1230 1254 1231 1255 === 7 Kbuild syntax for exported headers 1232 1256 1233 - The kernel include a set of headers that is exported to userspace. 1257 + The kernel includes a set of headers that is exported to userspace. 1234 1258 Many headers can be exported as-is but other headers require a 1235 1259 minimal pre-processing before they are ready for user-space. 1236 1260 The pre-processing does: 1237 - - drop kernel specific annotations 1261 + - drop kernel-specific annotations 1238 1262 - drop include of compiler.h 1239 1263 - drop all sections that are kernel internal (guarded by ifdef __KERNEL__) 1240 1264 ··· 1244 1268 1245 1269 --- 7.1 header-y 1246 1270 1247 - header-y specify header files to be exported. 1271 + header-y specifies header files to be exported. 1248 1272 1249 1273 Example: 1250 1274 #include/linux/Kbuild ··· 1254 1278 The convention is to list one file per line and 1255 1279 preferably in alphabetic order. 1256 1280 1257 - header-y also specify which subdirectories to visit. 1281 + header-y also specifies which subdirectories to visit. 1258 1282 A subdirectory is identified by a trailing '/' which 1259 1283 can be seen in the example above for the usb subdirectory. 1260 1284 ··· 1272 1296 1273 1297 --- 7.3 destination-y 1274 1298 1275 - When an architecture have a set of exported headers that needs to be 1299 + When an architecture has a set of exported headers that needs to be 1276 1300 exported to a different directory destination-y is used. 1277 - destination-y specify the destination directory for all exported 1301 + destination-y specifies the destination directory for all exported 1278 1302 headers in the file where it is present. 1279 1303 1280 1304 Example: ··· 1367 1391 1368 1392 INSTALL_MOD_STRIP 1369 1393 1370 - If this variable is specified, will cause modules to be stripped 1394 + If this variable is specified, it will cause modules to be stripped 1371 1395 after they are installed. If INSTALL_MOD_STRIP is '1', then the 1372 - default option --strip-debug will be used. Otherwise, 1396 + default option --strip-debug will be used. Otherwise, the 1373 1397 INSTALL_MOD_STRIP value will be used as the option(s) to the strip 1374 1398 command. 1375 1399
+180
scripts/coccinelle/misc/simple_return.cocci
··· 1 + /// Simplify a trivial if-return sequence. Possibly combine with a 2 + /// preceding function call. 3 + // 4 + // Confidence: High 5 + // Copyright: (C) 2014 Julia Lawall, INRIA/LIP6. GPLv2. 6 + // Copyright: (C) 2014 Gilles Muller, INRIA/LiP6. GPLv2. 7 + // URL: http://coccinelle.lip6.fr/ 8 + // Comments: 9 + // Options: --no-includes --include-headers 10 + 11 + virtual patch 12 + virtual context 13 + virtual org 14 + virtual report 15 + 16 + @r depends on patch@ 17 + local idexpression e; 18 + identifier i,f,fn; 19 + @@ 20 + 21 + fn(...) { <... 22 + - e@i = 23 + + return 24 + f(...); 25 + -if (i != 0) return i; 26 + -return 0; 27 + ...> } 28 + 29 + @depends on patch@ 30 + identifier r.i; 31 + type t; 32 + @@ 33 + 34 + -t i; 35 + ... when != i 36 + 37 + @depends on patch@ 38 + expression e; 39 + @@ 40 + 41 + -if (e != 0) 42 + return e; 43 + -return 0; 44 + 45 + // ----------------------------------------------------------------------- 46 + 47 + @s1 depends on context || org || report@ 48 + local idexpression e; 49 + identifier i,f,fn; 50 + position p,p1,p2; 51 + @@ 52 + 53 + fn(...) { <... 54 + * e@i@p = f(...); 55 + if (\(i@p1 != 0\|i@p2 < 0\)) 56 + return i; 57 + return 0; 58 + ...> } 59 + 60 + @s2 depends on context || org || report forall@ 61 + identifier s1.i; 62 + type t; 63 + position q,s1.p; 64 + expression e,f; 65 + @@ 66 + 67 + * t i@q; 68 + ... when != i 69 + e@p = f(...); 70 + 71 + @s3 depends on context || org || report@ 72 + expression e; 73 + position p1!=s1.p1; 74 + position p2!=s1.p2; 75 + @@ 76 + 77 + *if (\(e@p1 != 0\|e@p2 < 0\)) 78 + return e; 79 + return 0; 80 + 81 + // ----------------------------------------------------------------------- 82 + 83 + @script:python depends on org@ 84 + p << s1.p; 85 + p1 << s1.p1; 86 + q << s2.q; 87 + @@ 88 + 89 + cocci.print_main("decl",q) 90 + cocci.print_secs("use",p) 91 + cocci.include_match(False) 92 + 93 + @script:python depends on org@ 94 + p << s1.p; 95 + p2 << s1.p2; 96 + q << s2.q; 97 + @@ 98 + 99 + cocci.print_main("decl",q) 100 + cocci.print_secs("use with questionable test",p) 101 + cocci.include_match(False) 102 + 103 + @script:python depends on org@ 104 + p << s1.p; 105 + p1 << s1.p1; 106 + @@ 107 + 108 + cocci.print_main("use",p) 109 + 110 + @script:python depends on org@ 111 + p << s1.p; 112 + p2 << s1.p2; 113 + @@ 114 + 115 + cocci.print_main("use with questionable test",p) 116 + 117 + @script:python depends on org@ 118 + p << s3.p1; 119 + @@ 120 + 121 + cocci.print_main("test",p) 122 + 123 + @script:python depends on org@ 124 + p << s3.p2; 125 + @@ 126 + 127 + cocci.print_main("questionable test",p) 128 + 129 + // ----------------------------------------------------------------------- 130 + 131 + @script:python depends on report@ 132 + p << s1.p; 133 + p1 << s1.p1; 134 + q << s2.q; 135 + @@ 136 + 137 + msg = "WARNING: end returns can be simpified and declaration on line %s can be dropped" % (q[0].line) 138 + coccilib.report.print_report(p[0],msg) 139 + cocci.include_match(False) 140 + 141 + @script:python depends on report@ 142 + p << s1.p; 143 + p1 << s1.p1; 144 + q << s2.q 145 + ; 146 + @@ 147 + 148 + msg = "WARNING: end returns may be simpified if negative or 0 value and declaration on line %s can be dropped" % (q[0].line) 149 + coccilib.report.print_report(p[0],msg) 150 + cocci.include_match(False) 151 + 152 + @script:python depends on report@ 153 + p << s1.p; 154 + p1 << s1.p1; 155 + @@ 156 + 157 + msg = "WARNING: end returns can be simpified" 158 + coccilib.report.print_report(p[0],msg) 159 + 160 + @script:python depends on report@ 161 + p << s1.p; 162 + p2 << s1.p2; 163 + @@ 164 + 165 + msg = "WARNING: end returns can be simpified if negative or 0 value" 166 + coccilib.report.print_report(p[0],msg) 167 + 168 + @script:python depends on report@ 169 + p << s3.p1; 170 + @@ 171 + 172 + msg = "WARNING: end returns can be simpified" 173 + coccilib.report.print_report(p[0],msg) 174 + 175 + @script:python depends on report@ 176 + p << s3.p2; 177 + @@ 178 + 179 + msg = "WARNING: end returns can be simpified if tested value is negative or 0" 180 + coccilib.report.print_report(p[0],msg)
+12 -14
scripts/package/builddeb
··· 37 37 s390*) 38 38 debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;; 39 39 ppc*) 40 - debarch=powerpc ;; 40 + debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; 41 41 parisc*) 42 42 debarch=hppa ;; 43 43 mips*) ··· 64 64 fi 65 65 66 66 # Create the package 67 - dpkg-gencontrol -isp $forcearch -Vkernel:debarch="${debarch:-$(dpkg --print-architecture)}" -p$pname -P"$pdir" 67 + dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch:-$(dpkg --print-architecture)}" -p$pname -P"$pdir" 68 68 dpkg --build "$pdir" .. 69 69 } 70 70 ··· 152 152 rmdir "$tmpdir/lib/modules/$version" 153 153 fi 154 154 if [ -n "$BUILD_DEBUG" ] ; then 155 - ( 156 - cd $tmpdir 157 - for module in $(find lib/modules/ -name *.ko); do 158 - mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) 159 - # only keep debug symbols in the debug file 160 - $OBJCOPY --only-keep-debug $module $dbg_dir/usr/lib/debug/$module 161 - # strip original module from debug symbols 162 - $OBJCOPY --strip-debug $module 163 - # then add a link to those 164 - $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $module 165 - done 166 - ) 155 + for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do 156 + module=lib/modules/$module 157 + mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) 158 + # only keep debug symbols in the debug file 159 + $OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$module 160 + # strip original module from debug symbols 161 + $OBJCOPY --strip-debug $tmpdir/$module 162 + # then add a link to those 163 + $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $tmpdir/$module 164 + done 167 165 fi 168 166 fi 169 167
+1 -9
scripts/tags.sh
··· 193 193 --regex-c++='/TESTCLEARFLAG_FALSE\(([^,)]*).*/TestClearPage\1/' \ 194 194 --regex-c++='/__TESTCLEARFLAG_FALSE\(([^,)]*).*/__TestClearPage\1/' \ 195 195 --regex-c++='/_PE\(([^,)]*).*/PEVENT_ERRNO__\1/' \ 196 - --regex-c++='/TESTPCGFLAG\(([^,)]*).*/PageCgroup\1/' \ 197 - --regex-c++='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/' \ 198 - --regex-c++='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/' \ 199 - --regex-c++='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\1/' \ 200 196 --regex-c++='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \ 201 197 --regex-c++='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \ 202 198 --regex-c++='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/'\ ··· 255 259 --regex='/__CLEARPAGEFLAG_NOOP(\([^,)]*\).*/__ClearPage\1/' \ 256 260 --regex='/TESTCLEARFLAG_FALSE(\([^,)]*\).*/TestClearPage\1/' \ 257 261 --regex='/__TESTCLEARFLAG_FALSE(\([^,)]*\).*/__TestClearPage\1/' \ 258 - --regex='/TESTPCGFLAG\(([^,)]*).*/PageCgroup\1/' \ 259 - --regex='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/' \ 260 - --regex='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/' \ 261 - --regex='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\1/' \ 262 262 --regex='/TASK_PFA_TEST\([^,]*,\s*([^)]*)\)/task_\1/' \ 263 263 --regex='/TASK_PFA_SET\([^,]*,\s*([^)]*)\)/task_set_\1/' \ 264 264 --regex='/TASK_PFA_CLEAR\([^,]*,\s*([^)]*)\)/task_clear_\1/' \ 265 265 --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/' \ 266 266 --regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \ 267 267 --regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/'\ 268 - --regex='/DEFINE_HASHTABLE\((\w*)/\1/v/' 268 + --regex='/[^#]*DEFINE_HASHTABLE(\([^,)]*\)/\1/' 269 269 270 270 all_kconfigs | xargs $1 -a \ 271 271 --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'