当我尝试使用 boost spirit Qi compiler_tutorial 来修改一个大型复杂示例(在模板实例化方面修改为更复杂)时,我收到以下错误消息:
debug\expression.o:-1: error: section .debug_frame$_ZNK5boost5proto3if_INS0_6detail7has_tagINS0_6tagns_3tag7greaterEEENS0_12reverse_foldINS0_1_ENS0_6_stateENS2_18reverse_fold_tree_IS6_NS_6spirit6detail18make_binary_helperINSC_13meta_compilerINSC_2qi6domainEE12meta_grammarEEEEEEESK_E4implIRNSG_4ruleINSC_3lex7lexertl8iteratorINSR_7functorINSR_14position_tokenIN9__gnu_cxx17__normal_iteratorIPKcSsEENS_3mpl6vectorISsN4mpl_2naES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_EENS12_5bool_ILb0EEEyEENSR_6detail4dataESZ_NS15_ILb1EEES16_EEEEFSt4listIN7client3ast10expressionIdEESaIS1H_EEvENSC_11unused_typeES1L_S1L_EENS_6fusion4consINSG_12literal_charINSC_13char_encoding8standardELb1ELb0EEENS1O_4nil_EEERS1L_EclES1N_RKS1V_S1W_: string table overflow at offset 10000433
命令行:
c:/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/4.7.2/cc1plus.exe -quiet -v -I c:/libs/boost/include -I ../src/compiler -I c:/libs/boost/include -I . -I c:/libs/Qt-static/mkspecs/win32-g++-x64-4.7.2-corei7-avx-corei7-avx -iprefix c:\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/ -D_REENTRANT -U_REENTRANT -D BOOST_THREAD_POSIX -D BOOST_THREAD_USE_LIB -D UNICODE -D QT_LARGEFILE_SUPPORT -D _DEBUG=1 -D DEBUG=1 -D BOOST_SPIRIT_QI_DEBUG=1 -D BOOST_SPIRIT_NO_PREDEFINED_TERMINALS=1 ../src/compiler/expression.cpp -quiet -dumpbase expression.cpp -m64 -march=corei7-avx -mtune=corei7-avx -mtls-dialect=gnu2 -auxbase-strip debug/expression.o -g -O0 -Wall -Wextra -std=gnu++11 -version -fsignaling-nans -fno-math-errno -frtti -fexceptions -o - |
平台:x64主机上的mingw-builds(x64-4.7.2-release-posix-sjlj-rev5.7z)和x64 Windows 7上的目标(-m64
)(符合gcc 4.7.2) HB具有8GB物理内存。
看起来是因为内存不足。
我该怎么做才能避免这个问题?我确信这里没有递归模板。
答案 0 :(得分:8)
我发现这个问题的一个答案令人不满意,但经过进一步的研究,确实看来运行具有更高优化级别的gcc是如何解决这个问题的。我以为我会分享我学到的东西。
此问题特定于以PE / COFF格式编写二进制文件,这是Windows使用的格式。抓住binutils的来源,我发现了this code snippet/comment in bfd's coff backend code:
/* An inherent limitation of the /nnnnnnn notation used to indicate
the offset of the long name in the string table is that we
cannot address entries beyone the ten million byte boundary. */
if (string_size >= 10000000)
{
bfd_set_error (bfd_error_file_too_big);
(*_bfd_error_handler)
(_("%B: section %s: string table overflow at offset %ld"),
abfd, current->name, string_size);
return FALSE;
}
二进制文件中的字符串表看起来在PE / COFF中最多可以是1000万字节。我认为唯一限制它的是节表项的格式只为节名指定8个字节。如果名称长于该名称,则可以指定字符串表中的偏移量。该数字必须以UTF-8编码字符串中的ASCII表示,并以正斜杠开头。这只给你七个基数10位数,因此10,000,000限制。我在Microsoft的PE / COFF规范修订版8.1的第13节中找到了这个。
你无法真正改变二进制格式,因此我所知道的唯一解决方法是让gcc创建一个更小的字符串表。 -O2为我做了诀窍。
答案 1 :(得分:4)
我遇到了类似的问题并找到了解决方案。我使用Boost.Spirit2解析器中的很多boost模板类。
我在openSuse 12.2(gcc 4.7.2)上使用MingW64交叉编译器 MingW32在发布和调试模式下编译相同的文件都没有问题。
命令:
/ usr / bin / x86_64-w64-mingw32-g ++ -c -fpermissive -fexceptions -Wall -Wextra -Wno-long-long -Wno-unknown-pragmas -mthreads -Wall -frtti -finline-functions -o file .o file.cpp
输出:
部.pdata $ _ZN5boost6fusion6detail10linear_anyINS0_13cons_iteratorIKNS0_4consINS_6spirit2qi6kleeneINS6_10char_classINS5_3tag9char_codeINS9_5spaceENS5_13char_encoding8standardEEEEEEENS4_INS6_11alternativeINS4_INS6_6actionINSI_INSI_INS6_8sequenceINS4_INSI_INS6_14literal_stringIRA11_KcLb1EEENS_7phoenix5actorINSP_9compositeINSP_6detail13function_evalILi2EEENS0_6vectorINSP_5valueINSP_3stl9push_backEEENSP_9referenceISsEENSW_IcEENS0_5void_ES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_EEEEEEEENS4_INS6_16lexeme_directiveINS7_INSI_INS6_10differenceINS8_INSA_INS9_5char_ESD_EEEENS6_10eol_parserEEENSQ_INSR_ISU_NSV_ISZ_S11_NS5_8argumentILi0EEES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_Ssos-夜间@ SUSE-x86-64的:〜/ MNT /约瑟夫/ SUS E / build__mingw64__individual__next__debug / SRC / sos_import> _SF_EEEENS4_ISG_NS0_3nilEEEEEEEEEEENS4_INS6_4plusINSI_INS6_9referenceIKNS6_4ruleIN9__gnu_cxx17__normal_iteratorIPSL_SsEEFN7dynardo9structure11SimplexDataEvENS_5proto7exprns_4exprINS2A_6tagns_3tag8terminalENS2A_7argsns_4termINSA_INS9_5blankESD_EEEELl0EEENS5_11unused_typeES2M_EEEENSQ_INSR_ISU_NSV_INSW_INSS_19member_function_ptrILi1EvM11My_PushbackINS27_20SimplexDataContainerEEFvRKS28_EEEEENSW_IPS2T_EES1G_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_EEEEEEEEEES1T_EEEEEEEEEEEENSQ_INSR_ISU_NSV_INSW_INSX_6insertEEENS10_ISt3mapISsS2S_St4lessISsESaISt4pairIKSsS2S_EEEEENS10_IS3I_ISsS2S_EEES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_EEEEEEEENSQ_INSR_INST_ILi1EEENSV_INSW_INSX_5clearEEES11_S13_S13_S13_S13_S13_S13_S1 3_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_EEEEEEEENSQ_INSR_IS3U_NSV_IS3W_NS10_IS2S_EES13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_S13_EEEEEEEENS4_INSI_INSI_INSI_INSJ_INS4_INSK_IRA9_SL_Lb1EEENS4_IS1S_NS4_ISG_S37_EEEEEEEES3S_EES3Z_EES44_EENS4_INSJ_IS1V_EES1T_EEEEEEEES1T_EEEEEENS3_IKS1T_EENS6_6detail13fail_functionIS25_KS2M_NS8_IS2J_EEEEEEbRKT_RKT0_RT1_N4mpl_5bool_ILb0EEE:在字符串表溢出抵消10002537 /tmp/ccMd36nu.s:汇编程序消息: /tmp/ccMd36nu.s:致命错误:无法关闭debug / osl_lsdyna_k_parser.o:文件太大
似乎缺少优化选项是问题所在。添加-O1或-O2
/ usr / bin / x86_64-w64-mingw32-g ++ -c -fpermissive -fexceptions -Wall -Wextra -Wno-long-long -Wno-unknown-pragmas -mthreads -Wall -frtti -O1 -g -o file .o file.cpp
为我解决了问题,甚至允许调试选项(-g)!