linux内核配置裁减问题

内核下载地址:可能需要
www.kernel.org

1、执行make menuconfig过程中会遇到的问题,可以根据提示安装对应缺少的软件包;本人遇到过的有如下三点:

*** Unable to find the ncurses libraries or the
*** required header files.
*** 'make menuconfig' requires the ncurses libraries.
*** Install ncurses (ncurses-devel) and try again.

sudo apt-get install ncurses-dev

/bin/sh: 1: flex: not found
scripts/Makefile.lib:194: recipe for target 'scripts/kconfig/lexer.lex.c' failed
make[1]: *** [scripts/kconfig/lexer.lex.c] Error 127
Makefile:552: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2

sudo apt-get install flex

  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.h
/bin/sh: 1: bison: not found
scripts/Makefile.lib:208: recipe for target 'scripts/kconfig/parser.tab.h' failed
make[1]: *** [scripts/kconfig/parser.tab.h] Error 127
Makefile:552: recipe for target 'menuconfig' failed
make: *** [menuconfig] Error 2

sudo apt-get install bison

scripts/sign-file.c:25:10: fatal error: openssl/opensslv.h: 没有那个文件或目录
 #include 
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
scripts/Makefile.host:92: recipe for target 'scripts/sign-file' failed
make[1]: *** [scripts/sign-file] Error 1
Makefile:1065: recipe for target 'scripts' failed
make: *** [scripts] Error 2

sudo apt-get install libssl-dev

Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
/home/howe/iTop4412_Kernel_3.0/kernel/Makefile:140: recipe for target 'kernel/timeconst.h' failed
make[1]: *** [kernel/timeconst.h] Error 255
Makefile:954: recipe for target 'kernel' failed
make: *** [kernel] Error 2

解决方法:https://blog.csdn.net/abc87891842/article/details/55051042
参考:编译kernel perl版本bug
最近升级了一下MAC系统,突然发现android的Linux kernel无法编译通过了,报了如下错误:
Can’t use ‘!defined(@array)’ (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
其实,提示的错误信息已经明确告诉你了,你应该省略defined().
这里,我们打开 kernel/timeconst.pl
@val = @{KaTeX parse error: Expected '}', got 'EOF' at end of input: canned_values{hz}};
if (!defined(@val)) {
@val = compute_values(KaTeX parse error: Expected 'EOF', got '}' at position 6: hz); }̲ output(hz, @val);
将if (!defined(@val)) 改为if (!(@val)),再次编译就可以通过了。
查了一下更新,发现其中有一项是perl版本升级到了 v5.22.1,然后查了perl官方文档,发现官网因为一个bug,该版本将defined(@array)去掉了。可以直接使用数组判断非空。

kernel 3.0
警告1:

fs/cifs/cifssmb.c: In function ‘CIFSSMBSetFileInfo’:
fs/cifs/cifssmb.c:5318:8: warning: array subscript is above array bounds [-Warray-bounds]
  memcpy(data_offset, data, sizeof(FILE_BASIC_INFO));
        ^
fs/cifs/cifssmb.c: In function ‘CIFSSMBUnixSetFileInfo’:
fs/cifs/cifssmb.c:5608:25: warning: array subscript is above array bounds [-Warray-bounds]
  cifs_fill_unix_set_info(data_offset, args);

警告2:

fs/xfs/xfs_dir2_block.c: In function ‘xfs_dir2_sf_to_block’:
fs/xfs/xfs_dir2_block.c:1151:26: warning: array subscript is above array bounds [-Warray-bounds]
  dep->name[0] = dep->name[1] = '.';
                          ^
  CC [M]  fs/xfs/xfs_dir2_data.o
  CC [M]  fs/xfs/xfs_dir2_leaf.o
fs/xfs/xfs_dir2_leaf.c: In function ‘xfs_dir2_leaf_compact’:
fs/xfs/xfs_dir2_leaf.c:622:31: warning: array subscript is above array bounds [-Warray-bounds]
    leaf->ents[to] = leaf->ents[from];
                               ^

警告3:

In file included from /home/howe/iTop4412_Kernel_3.0/arch/arm/include/asm/xor.h:10:0,
                 from crypto/xor.c:24:
include/asm-generic/xor.h:696:34: warning: ‘xor_block_8regs_p’ defined but not used [-Wunused-variable]
 static struct xor_block_template xor_block_8regs_p = {
                                  ^
include/asm-generic/xor.h:704:34: warning: ‘xor_block_32regs_p’ defined but not used [-Wunused-variable]
 static struct xor_block_template xor_block_32regs_p = {
                                  ^

警告4:

drivers/ata/sata_sil.c: In function ‘sil_interrupt’:
drivers/ata/sata_sil.c:453:14: warning: ‘serror’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (serror & SERR_PHYRDY_CHG) {
              ^
drivers/ata/sata_sil.c:441:7: note: ‘serror’ was declared here
   u32 serror;
       ^

警告5:

drivers/atm/ambassador.c: In function ‘do_loader_command’:
drivers/atm/ambassador.c:1765:3: warning: passing argument 1 of ‘virt_to_bus’ discards ‘volatile’ qualifier from pointer target type [enabled by default]
   wr_mem (dev, offsetof(amb_mem, doorbell), virt_to_bus (lb) & ~onegigmask);
   ^
In file included from /home/howe/iTop4412_Kernel_3.0/arch/arm/include/asm/system.h:165:0,
                 from /home/howe/iTop4412_Kernel_3.0/arch/arm/include/asm/bitops.h:27,
                 from include/linux/bitops.h:22,
                 from include/linux/kernel.h:17,
                 from include/linux/cache.h:4,
                 from include/linux/time.h:7,
                 from include/linux/stat.h:60,
                 from include/linux/module.h:10,
                 from drivers/atm/ambassador.c:25:
/home/howe/iTop4412_Kernel_3.0/arch/arm/include/asm/memory.h:264:42: note: expected ‘void *’ but argument is of type ‘volatile struct loader_block *’
 static inline __deprecated unsigned long virt_to_bus(void *x)
                                          ^
drivers/atm/ambassador.c: In function ‘amb_probe’:
drivers/atm/ambassador.c:1975:19: warning: ‘fw’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   release_firmware(fw);
                   ^
drivers/atm/ambassador.c:1926:26: note: ‘fw’ was declared here
   const struct firmware *fw;
                          ^

警告6:

drivers/block/DAC960.c: In function ‘DAC960_V2_ProcessCompletedCommand’:
drivers/block/DAC960.c:5095:30: warning: comparison between ‘DAC960_V2_IOCTL_Opcode_T’ and ‘enum ’ [-Wenum-compare]
       else if (CommandOpcode == DAC960_V2_SCSI_10_Passthru)
                              ^
In file included from include/linux/bio.h:29:0,
                 from include/linux/blkdev.h:16,
                 from drivers/block/DAC960.c:27:
drivers/block/DAC960.c: In function ‘DAC960_V1_EnableMemoryMailboxInterface’:
/home/howe/iTop4412_Kernel_3.0/arch/arm/include/asm/io.h:50:43: warning: ‘CommandMailbox.Bytes[12]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile unsigned char __force  *)(a) = (v))
                                           ^
drivers/block/DAC960.c:1175:30: note: ‘CommandMailbox.Bytes[12]’ was declared here
   DAC960_V1_CommandMailbox_T CommandMailbox;
                              ^

警告7:

drivers/block/drbd/drbd_main.c: In function ‘drbd_buildtag’:
drivers/block/drbd/drbd_main.c:4187:19: warning: the comparison will always evaluate as ‘true’ for the address of ‘__this_module’ will never be NULL [-Waddress]
   if (THIS_MODULE != NULL)
                   ^

警告8:

drivers/char/tpm/tpm_tis.c:96:12: warning: ‘is_itpm’ defined but not used [-Wunused-function]
 static int is_itpm(struct pnp_dev *dev)
            ^

linux kernel 5.1
警告1:

warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel

警告2:

arch/x86/hyperv/hv_apic.c: In function ‘__send_ipi_one’:
arch/x86/hyperv/hv_apic.c:196:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^
arch/x86/hyperv/hv_apic.c: In function ‘hv_send_ipi_mask_allbutself’:
arch/x86/hyperv/hv_apic.c:221:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^

警告3:

arch/x86/kernel/kvm.c: In function ‘kvm_send_ipi_mask_allbutself’:
arch/x86/kernel/kvm.c:519:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^

警告4:

mm/memcontrol.c: In function ‘memcg_stat_show’:
mm/memcontrol.c:3485:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^
mm/memcontrol.c: In function ‘memory_stat_show’:
mm/memcontrol.c:5638:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^

警告5:

fs/jffs2/xattr.c: In function ‘jffs2_build_xattr_subsystem’:
fs/jffs2/xattr.c:887:1: warning: the frame size of 1120 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^

警告6:

drivers/cpufreq/cpufreq_ondemand.c: In function ‘od_set_powersave_bias’:
drivers/cpufreq/cpufreq_ondemand.c:449:1: warning: the frame size of 1032 bytes is larger than 1024 bytes [-Wframe-larger-than=]
 }
 ^

2、menuconfig菜单栏的说明
menuconfig界面的运行脚本在内核目录下的scripts文件夹下,而界面相关都与内核文件夹下的Kconfig文件有关,可自行查看,比如菜单、选择栏等,需要链接到其他文件夹下的Kconfig,则通过source来实现。
配置完menuconfig之后,会在内核根目录下生成一个.config文件,给编译内核时使用。

3、make编译内核说明
编译过程,是调用各个文件夹下的makefile文件,而makefile文件依赖于.config中的宏定义。

你可能感兴趣的:(linux内核配置裁减问题)