构建 Linux 内核 2.4.36.1 时如何修复此错误?

构建 Linux 内核 2.4.36.1 时如何修复此错误?

我想从源代码构建 Linux Kernel 2.4.36.1。但是出现以下错误。我在 Windows 11 上使用 WSL Ubuntu,看到以下信息:

dingjun@G02515:~/Linux_kernel_build/src/linux-2.4.36.1$ uname -a
Linux G02515 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux


dingjun@G02515:~/Linux_kernel_build/src/linux-2.4.36.1$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

错误信息如下:

dingjun@G02515:~/Linux_kernel_build/src/linux-2.4.36.1$ make
gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/mkdep scripts/mkdep.c
make[1]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
make[1]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/boot'
make[1]: Nothing to be done for 'dep'.
make[1]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/boot'
rm -f .depend .hdepend
make _sfdep_arch/x86_64/tools _sfdep_kernel _sfdep_drivers _sfdep_mm _sfdep_fs _sfdep_net _sfdep_ipc _sfdep_lib _sfdep_crypto _sfdep_arch/x86_64/kernel _sfdep_arch/x86_64/mm _sfdep_arch/x86_64/lib _sfdep_arch/x86_64/ia32 _FASTDEP_ALL_SUB_DIRS="arch/x86_64/tools kernel drivers mm fs net ipc lib crypto arch/x86_64/kernel arch/x86_64/mm arch/x86_64/lib arch/x86_64/ia32"
make[1]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1'
make -C arch/x86_64/tools fastdep
make[2]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
gcc -D__KERNEL__ -I/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fno-builtin-strpbrk -fno-builtin-sprintf -fomit-frame-pointer -Wno-pointer-sign -mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-unit-at-a-time -march=nocona -S -o offset.tmp offset.c
cc1: error: code model kernel does not support PIC mode
make[2]: *** [Makefile:18: offset.h] Error 1
make[2]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
make[1]: *** [Rules.make:136: _sfdep_arch/x86_64/tools] Error 2
make[1]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1'
make: *** [Makefile:506: dep-files] Error 2
dingjun@G02515:~/Linux_kernel_build/src/linux-2.4.36.1$ make defconfig
make: *** No rule to make target 'defconfig'.  Stop.
dingjun@G02515:~/Linux_kernel_build/src/linux-2.4.36.1$ make
make[1]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
make[1]: Nothing to be done for 'all'.
make[1]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
make[1]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/boot'
make[1]: Nothing to be done for 'dep'.
make[1]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/boot'
rm -f .depend .hdepend
make _sfdep_arch/x86_64/tools _sfdep_kernel _sfdep_drivers _sfdep_mm _sfdep_fs _sfdep_net _sfdep_ipc _sfdep_lib _sfdep_crypto _sfdep_arch/x86_64/kernel _sfdep_arch/x86_64/mm _sfdep_arch/x86_64/lib _sfdep_arch/x86_64/ia32 _FASTDEP_ALL_SUB_DIRS="arch/x86_64/tools kernel drivers mm fs net ipc lib crypto arch/x86_64/kernel arch/x86_64/mm arch/x86_64/lib arch/x86_64/ia32"
make[1]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1'
make -C arch/x86_64/tools fastdep
make[2]: Entering directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
gcc -D__KERNEL__ -I/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fno-builtin-strpbrk -fno-builtin-sprintf -fomit-frame-pointer -Wno-pointer-sign -mno-red-zone -mcmodel=kernel -pipe -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-unit-at-a-time -march=nocona -S -o offset.tmp offset.c
cc1: error: code model kernel does not support PIC mode
make[2]: *** [Makefile:18: offset.h] Error 1
make[2]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1/arch/x86_64/tools'
make[1]: *** [Rules.make:136: _sfdep_arch/x86_64/tools] Error 2
make[1]: Leaving directory '/home/dingjun/Linux_kernel_build/src/linux-2.4.36.1'
make: *** [Makefile:506: dep-files] Error 2
dingjun@G02515:~/Linux_kernel_build/src/linux-2.4.36.1$ uname -a
Linux G02515 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
dingjun@G02515:~/Linux_kernel_build/src/linux-2.4.36.1$ gcc -version
gcc: error: unrecognized command-line option ‘-version’
gcc: fatal error: no input files
compilation terminated.

我怎样才能解决这个问题?

相关内容