如何判断GCC的版本
2023-04-18 14:49:08 时间
我说的 GCC 版本可不是指的「gcc –version」,而是指的上到 Linux 内核,下到 PHP 之类的软件,是用哪个版本的 GCC 编译的。
先看看如何判断 Linux 内核是用什么版本的 GCC 编译的?
shell> cat /proc/version
... (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) ...
shell> /lib64/libc.so.6
GNU C Library stable release version 2.12, by Roland McGrath et al.
Copyright (C) 2010 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.
Compiled by GNU CC version 4.4.7 20120313 (Red Hat 4.4.7-17).
Compiled on a Linux 2.6.32 system on 2016-05-10.
Available extensions:
The C stubs add-on version 2.1.2.
crypt add-on version 2.1 by Michael Glad and others
GNU Libidn by Simon Josefsson
Native POSIX Threads Library by Ulrich Drepper et al
BIND-8.2.3-T5B
RT using linux kernel aio
libc ABIs: UNIQUE IFUNC
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
再看看如何判断 PHP 之类的软件是用什么版本的 GCC 编译的?
shell> objdump -s --section .comment /usr/local/bin/php
/usr/local/bin/php: file format elf64-x86-64
Contents of section .comment:
0000 4743433a 2028474e 55292034 2e342e37 GCC: (GNU) 4.4.7
0010 20323031 32303331 33202852 65642048 20120313 (Red H
0020 61742034 2e342e37 2d313129 00474343 at 4.4.7-11).GCC
0030 3a202847 4e552920 342e342e 37203230 : (GNU) 4.4.7 20
0040 31323033 31332028 52656420 48617420 120313 (Red Hat
0050 342e342e 372d3429 00 4.4.7-4).
或者
shell> readelf -p .comment /usr/local/bin/php
String dump of section '.comment':
[ 0] GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-11)
[ 2d] GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-4)
知道这些有什么价值呢?因为视 GCC 版本的不同,可能会有各种各样的 BUG 或者性能问题,所以知晓如何判断 GCC 版本还是有意义的。比如我测试 tcp-recv-queue 的时候一直不成功,后来才发现它要求 Linux 内核必须用 GCC4.5+ 的版本编译才行。
相关文章
- 异步任务比同步任务快多少
- netcore后台任务注意事项
- 分布式缓存NCache使用
- orleans集群及负载均衡实现
- C#面对抽象编程第一讲
- netcore项目中IStartupFilter使用
- go语言package使用
- netcore依赖注入通过反射简化
- netcore5下ocelot网关简单使用
- netcore热插拔dll
- 简单高效二分查找算法
- centos7虚拟机部署netcore3.1服务供局域网访问
- 设计模式之装饰器-AOP
- netcore3.1 程序在cento8下运行selenium
- NetCore开发第一步 Log4Net日志引入
- 插入排序算法
- 选择排序算法
- 冒泡排序算法
- 线性链表
- 汉诺塔