我制作了简单的c ++源文件。
源文件是:
int main() {
std::cout << "hello world" << std::endl;
return 0;
}
并构建它包括调试符号。
使用clang时,二进制大小为100kb
但使用gcc,二进制大小为19kb。
我试过&#34; readelf -wi hello_clang&#34;
<4><22b>: Abbrev Number: 9 (DW_TAG_member)
<22c> DW_AT_name : (indirect string) __fmtflags_
<230> DW_AT_type : <0x5e>
<234> DW_AT_decl_file : 2
<235> DW_AT_decl_line : 362
readelf: dwarf_loclist_form_expr_b: Invalid argument [dwarf_loclist_from_expr_b(279)]
<237> DW_AT_data_member_location: 0 byte block: ()
<4><23a>: Abbrev Number: 9 (DW_TAG_member)
<23b> DW_AT_name : (indirect string) __precision_
<23f> DW_AT_type : <0x799>
<243> DW_AT_decl_file : 2
<244> DW_AT_decl_line : 363
readelf: dwarf_loclist_form_expr_b: Invalid argument [dwarf_loclist_from_expr_b(279)]
<246> DW_AT_data_member_location: 0 byte block: ()
<4><249>: Abbrev Number: 9 (DW_TAG_member)
<24a> DW_AT_name : (indirect string) __width_
<24e> DW_AT_type : <0x799>
<252> DW_AT_decl_file : 2
<253> DW_AT_decl_line : 364
readelf: dwarf_loclist_form_expr_b: Invalid argument [dwarf_loclist_from_expr_b(279)]
<255> DW_AT_data_member_location: 0 byte block: ()
<4><258>: Abbrev Number: 9 (DW_TAG_member)
<259> DW_AT_name : (indirect string) __rdstate_
<25d> DW_AT_type : <0x183>
<261> DW_AT_decl_file : 2
<262> DW_AT_decl_line : 365
readelf: dwarf_loclist_form_expr_b: Invalid argument [dwarf_loclist_from_expr_b(279)]
<264> DW_AT_data_member_location: 0 byte block: ()
<4><267>: Abbrev Number: 9 (DW_TAG_member)
<268> DW_AT_name : (indirect string) __exceptions_
<26c> DW_AT_type : <0x183>
<270> DW_AT_decl_file : 2
<271> DW_AT_decl_line : 366
readelf: dwarf_loclist_form_expr_b: Invalid argument [dwarf_loclist_from_expr_b(279)]
<273> DW_AT_data_member_location: 0 byte block: ()
<4><276>: Abbrev Number: 9 (DW_TAG_member)
<277> DW_AT_name : (indirect string) __rdbuf_
<27b> DW_AT_type : <0x4dda>
<27f> DW_AT_decl_file : 2
<280> DW_AT_decl_line : 367
readelf: dwarf_loclist_form_expr_b: Invalid argument [dwarf_loclist_from_expr_b(279)]
<282> DW_AT_data_member_location: 0 byte block: ()
<4><285>: Abbrev Number: 9 (DW_TAG_member)
<286> DW_AT_name : (indirect string) __loc_
<28a> DW_AT_type : <0x4dda>
<28e> DW_AT_decl_file : 2
<28f> DW_AT_decl_line : 368
重复输出此消息。
这条消息是什么意思?
为什么会出现这个问题?
这是铿锵的错误吗?
如何减少二进制大小?
我的环境:
i386,freebsd11,clang38
答案 0 :(得分:0)
我没有在我的Debian / Sid / x86-64盒子上观察GCC-6.2和Clang-3.8,尺寸与你的观察一致:
请注意,您的示例应在#include <iostream>
之前main
。
另请注意,g++
和clang++
正在接受-g0
或-g1
或-g2
或-g3
(您可以将其与{ {1}}或-O0
或-O1
)
-O2
我同意我们没有相同的操作系统和相同的架构(我的是64位)。