一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Centos7.2系统下安装VirtualBox缺少compiler-gcc6.h

时间:2022-06-30 20:46:26 编辑:袖梨 来源:一聚教程网

1、之前为了在Centos7.2安装网易云音乐,而编译安装了GCC6.2.0,后来发现之前安装的VirtualBox却不能用了,按照提示在终端执行sudo /sbin/vboxconfig,错误提示:
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.

There were problems setting up VirtualBox.  To re-start the set-up process, run
 /sbin/vboxconfig
as root.
 
2、查看/var/log/vbox-install.log ,提示重大错误:缺少include/linux/compiler-gcc6.h。后来度娘了之后发现可能是kernel和GCC6的更新造成的(http://blog.chinaunix.net/uid-20680966-id-5322921.html),查看系统内核目录include/linux下发现确实没有compiler-gcc6.h。然后在这里找到了compiler-gcc6.h的代码:http://lkml.iu.edu/hypermail/linux/kernel/1504.1/04805.html
内容如下:
——————————————————————————————————————
#ifndef __LINUX_COMPILER_H
#error "Please don't include directly, include instead."
#endif


#define __used                   __attribute__((__used__))
#define __must_check             __attribute__((warn_unused_result))
#define __compiler_offsetof(a, b) __builtin_offsetof(a, b)


/* Mark functions as cold. gcc will assume any path leading to a call
   to them will be unlikely. This means a lot of manual unlikely()s
   are unnecessary now for any paths leading to the usual suspects
   like BUG(), printk(), panic() etc. [but let's keep them for now for
   older compilers]
 
  gcc also has a __attribute__((__hot__)) to move hot functions into
  a special section, but I don't see any sense in this right now in
  the kernel context */
#define __cold           __attribute__((__cold__))


#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)


#ifndef __CHECKER__
# define __compiletime_warning(message) __attribute__((warning(message)))
# define __compiletime_error(message) __attribute__((error(message)))
#endif /* __CHECKER__ */


/*
 * Mark a position in code as unreachable. This can be used to
 * suppress control flow warnings after asm blocks that transfer
 * control elsewhere.
 */
#define unreachable() __builtin_unreachable()


/* Mark a function definition as prohibited from being cloned. */
#define __noclone __attribute__((__noclone__))


/*
 * Tell the optimizer that something else uses this function or variable.
 */
#define __visible __attribute__((externally_visible))


/*
 * GCC 'asm goto' miscompiles certain code sequences:
 *
 * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
 *
 * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
 *
 * (asm goto is automatically volatile - the naming reflects this.)
 */
#define asm_volatile_goto(x...) do { asm goto(x); asm (""); } while (0)


#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
#define __HAVE_BUILTIN_BSWAP32__
#define __HAVE_BUILTIN_BSWAP64__
#define __HAVE_BUILTIN_BSWAP16__
#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */


#define KASAN_ABI_VERSION 4
————————————————————————————————
其实这个内容和compiler-gcc5.h几乎一样,你也可以将compiler-gcc5.h内容稍作修改后复制为compiler-gcc6.h。新建compiler-gcc6.h,然后复制到kernel的include/linux目录下,和compiler-gcc5.h在相同的目录。注意每更新一次kernel,就会多一个目录如:/usr/src/kernels/3.10.0-327.36.1.el7.x86_64/include/linux
 
3、添加了compiler-gcc6.h后,再执行命令 sudo /sbin/vboxconfig 就不会有错误提示了。

热门栏目