linux - 在 Ubuntu 16.04 LTS 上编译旧的 Linux 内核

标签 linux ubuntu gcc linux-kernel

我尝试在 Ubuntu 16.04 LTS 上编译 Linux 内核 3.10.31。 我曾经在 Ubuntu 12.04 LTS 上编译完全相同的内核,一切运行良好。

在 Ubuntu 16.04 上,gcc 版本为 gcc-5; 在 Ubuntu 12.04 上,gcc 版本是 gcc-4.6

Linux kernel 3.18之前的kernel好像不能用gcc-5编译。 kernel 3.10.31用make

编译报如下错误
 fatal error: linux/compiler-gcc5.h: No such file or directory

我尝试将 gcc-4.7 安装到 Ubuntu 16.04 上,并将 /usr/bin/gcc 更改为指向 gcc-4.7。这可以解决上述错误。但是,在我运行 make

后它会导致新问题
$linux/arch/x86/Makefile:98: stack protector enabled but no compiler support
make[1]: Nothing to be done for 'all'.
make[1]: Nothing to be done for 'relocs'.
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      kernel/bounds.s
gcc-4.7.real: error: unrecognized command line option ‘-no-pie’
linux/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:835: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2

我的问题是:

有没有一种巧妙的方法可以使用旧的编译链在 Ubuntu 16.04 上编译旧的内核 3.10.31?

非常感谢您的帮助!非常感谢任何建议。

最佳答案

我想我找到了解决办法。

我们不必安装旧版本的 gcc。我们只需要复制文件 compiler-gcc5.h from herefrom here进入包含/linux/。它将解决编译问题。

关于linux - 在 Ubuntu 16.04 LTS 上编译旧的 Linux 内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37802473/

相关文章:

c++ - 不是最后一个模板参数的推导和参数包 : is this valid code?

linux - 安装 g++ 而不更新 glibc

linux - 在提示中包含字符 UTF-8

linux - 如何判断脚本是否以 super 用户身份运行?

在 Windows 7 上的 VirtualBox 中运行的 Ubuntu 中无法识别 Android 设备?

linux - 授予每个人对此设置的读取权限有哪些安全风险?

linux - Debian安装完成后运行脚本

node.js - Cloud9 安装问题

ruby - ming swf库如何在Ubuntu中安装?

c++ - Red hat EnterPrise Edition 4 GCC 编译器支持带 BOM 的 utf8