1. 问题

gcc7.3 编译linux内核linux-4.10.4时,出现如下错误:

  GEN     .versionCHK     include/generated/compile.hUPD     include/generated/compile.hCC      init/version.oLD      init/built-in.oLD      vmlinux.oMODPOST vmlinux.o
kernel/built-in.o: In function `update_wall_time':
/home/ubuntu/linux-4.10.4/kernel/time/timekeeping.c:2088: undefined reference to `____ilog2_NaN'
Makefile:969: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

2. 网上搜了下, 需要打patch

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/diff/?id=474c90156c8dcc2fa815e6716cc9394d7930cb9c

diff --git a/include/linux/log2.h b/include/linux/log2.h
index ef3d4f67118c..c373295f359f 100644
--- a/include/linux/log2.h
+++ b/include/linux/log2.h
@@ -16,12 +16,6 @@#include <linux/bitops.h>/*
- * deal with unrepresentable constant logarithms
- */
-extern __attribute__((const, noreturn))
-int ____ilog2_NaN(void);
-
-/** non-constant log of base 2 calculators* - the arch may override these in asm/bitops.h if they can be implemented*   more efficiently than using fls() and fls64()
@@ -85,7 +79,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)#define ilog2(n)                \(                      \__builtin_constant_p(n) ? (        \
-       (n) < 1 ? ____ilog2_NaN() :  \
+      (n) < 2 ? 0 :            \(n) & (1ULL << 63) ? 63 :    \(n) & (1ULL << 62) ? 62 :    \(n) & (1ULL << 61) ? 61 :    \
@@ -148,10 +142,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)(n) & (1ULL <<  4) ?  4 :  \(n) & (1ULL <<  3) ?  3 :    \(n) & (1ULL <<  2) ?  2 :    \
-       (n) & (1ULL <<  1) ?  1 : \
-       (n) & (1ULL <<  0) ?  0 : \
-       ____ilog2_NaN()         \
-                  ) :      \
+      1 ) :               \(sizeof(n) <= 4) ?         \__ilog2_u32(n) :           \__ilog2_u64(n)             \
diff --git a/tools/include/linux/log2.h b/tools/include/linux/log2.h
index 41446668ccce..d5677d39c1e4 100644
--- a/tools/include/linux/log2.h
+++ b/tools/include/linux/log2.h
@@ -13,12 +13,6 @@#define _TOOLS_LINUX_LOG2_H/*
- * deal with unrepresentable constant logarithms
- */
-extern __attribute__((const, noreturn))
-int ____ilog2_NaN(void);
-
-/** non-constant log of base 2 calculators* - the arch may override these in asm/bitops.h if they can be implemented*   more efficiently than using fls() and fls64()
@@ -78,7 +72,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)#define ilog2(n)                \(                      \__builtin_constant_p(n) ? (        \
-       (n) < 1 ? ____ilog2_NaN() :  \
+      (n) < 2 ? 0 :            \(n) & (1ULL << 63) ? 63 :    \(n) & (1ULL << 62) ? 62 :    \(n) & (1ULL << 61) ? 61 :    \
@@ -141,10 +135,7 @@ unsigned long __rounddown_pow_of_two(unsigned long n)(n) & (1ULL <<  4) ?  4 :  \(n) & (1ULL <<  3) ?  3 :    \(n) & (1ULL <<  2) ?  2 :    \
-       (n) & (1ULL <<  1) ?  1 : \
-       (n) & (1ULL <<  0) ?  0 : \
-       ____ilog2_NaN()         \
-                  ) :      \
+      1 ) :               \(sizeof(n) <= 4) ?         \__ilog2_u32(n) :           \__ilog2_u64(n)             \

复制patch内容 保存成 patch.diff文件, 拷贝文件到linux内核路径下,

运行命令: patch -i patch.diff, 提示输入操作文件时, 先后输入 include/linux/log2.h, tools/include/linux/log2.h即可。

3. 后记

看patch的意思,就是不用'____ilog2_NaN'函数。

gcc7 编译 linux内核提示 undefined reference to `____ilog2_NaN'相关推荐

  1. 64位ubuntu 12.04编译linux内核提示mkimage command not found

    今天心血来潮,想编译以下linux内核来玩玩.一开始编译x86的版本,遇到了openssl/opensslv.h文件缺失的问题,经过一番折腾,顺利解决(解决过程请参见我的另外一篇博客"lin ...

  2. 64位ubuntu 12.04编译linux内核提示openssl/opensslv.h文件缺失

    今天心血来潮,想编译一下linux内核来玩玩.从git上下载了最新版本的源码,放在我的ubuntu系统下,首先从现有ubuntu系统的boot目录下,拷贝了config-3.13.0-32-gener ...

  3. 安装debian总结以及编译linux内核

    1. 安装debian 使用unetbootin(http://unetbootin.sourceforge.net/)来创建启动盘,并且下载debian的基本包. 将磁盘进行压缩操作,并且保留出一个 ...

  4. 记第一次编译Linux内核

    前言 国庆期间老师布置了一个作业,其中有一个主要的部分是编译Linux内核. 然而第一次编译可能会遇到许多问题,特别是安装包依赖的问题.这里为了留个纪念,或者希望能帮到大家,特意写了这篇博客. 安装虚 ...

  5. 编译linux内核3.0系统出现的警告信息(原创)

    编译linux内核3.0系统出现的警告信息(原创) 余超   yuchao86@gmail.com [yuchao@yuchao-Latitude-E5410 linux-3.0]$gcc --ver ...

  6. linux 内核编译_如何在21世纪编译Linux内核

    linux 内核编译 在计算中,内核是处理与硬件和一般系统协调通信的低级软件. 除了计算机主板上内置的一些初始固件之外,启动计算机时,内核还使您意识到它具有硬盘驱动器,屏幕,键盘和网卡. 确保为每个组 ...

  7. CentOS下编译Linux内核

    前言 编译内核是一项很简单的事情,但却是进入Linux内核世界的第一步,想要开发内核代码,想要了解内核的运行机制,第一步就是编译Linux内核,以下是在centos7.5环境下编译内核的具体流程. 1 ...

  8. Linux内核开发_1_编译LInux内核

    目录 1. 准备工作 1.1 学习环境 1.2 下载Linux内核源码 1.3 解压Linux内核 1.4 目录结构介绍 2. Linux内核配置 2.1 配置选项 1. make config 2. ...

  9. Ubuntu20.04编译Linux内核

    Ubuntu20.04编译Linux内核 下载Linux源码 生成.config文件 编译Linux内核 下载Linux源码 Linux源码可以从Linux内核官网进行下载,如下图所示,我下载的是5. ...

最新文章

  1. lisp语言cond和if套用_在'if'语句中设置多行条件的样式?
  2. 学习别跟我谈兴趣 No.88
  3. 对于非技术人员来说,闪电网络和BCH分别意味着什么?
  4. Linux下tomcat安装及优化
  5. 计算机软件的输出设备有哪些,计算机输出设备有哪些?计算机输出设备介绍
  6. android的窗口机制分析------ViewRoot类
  7. ObjectArx开发对txt文本文件的操作一例
  8. 大疆地理围栏系统预防无人机闯入机场
  9. Notes:DOM的事件模拟
  10. 导入要素到要素类(C++)ArcEngine开发
  11. php 小程序登录授权解密,微信小程序授权登录,PHP解密数据,并返回用户信息token记住登录状态...
  12. 管理新语:一项工作如果一定要上,不要等准备好,立即上
  13. authware_在yonohub上轻松使用autoware auto
  14. 节约里程法求解CVRP问题
  15. Win7开发的VC2012程序在XP上无法运行
  16. 窦志成:从微软到人大,只为做有温度的AI
  17. 万和计算机学院,万和亿的换算(万和亿的换算计算器)
  18. markdown如何设置图片大小_cnblogs文章/MarkDown内如何调整图片的宽度?
  19. 在bug的边缘疯狂试探之mybatis
  20. 引流脚本有没有效果,引流脚本是什么

热门文章

  1. 中国移动机顶盒系统升级服务器地址,中国移动电视机顶盒WIFI网络设置步骤
  2. arch-linux+xfce4+lightdm+uefi个人安装记录
  3. 免费使用的pdf转cad软件使用
  4. 移动端切图内容包括什么_手机移动端前端开发切图的一些疑问
  5. RabbitVCS 对比不同后取消新增内容
  6. 数电_第九章_数模模数转换
  7. #第六章 曲率二维表达的拟合应用 ​一、四维时空曲率的二维几何表达
  8. godaddy biz域名续费优惠码
  9. Win7 ODBC 数据源ACCESS2003的链接
  10. python 做软件授权代理_软件提卡+授权API+代理系统三合一网站源码(开源)