I'm in the progress of writing a compiler for a subset of Java, using boost::spirit
, for lexing and parsing. During compilation of the lexer/parser phase, the compiler consumes 1.6GB
of RAM (g++ (GCC) 4.8.1
), this is not an issue however, as there's plenty of memory on this machine.
What is an issue however, is that when the compiler is done, and the assembler starts running (GNU assembler (GNU Binutils) 2.23.52.20130604
), it crashes with;
as: build/src/ast_generate.o: too many sections (33098)
/tmp/cc0ZyvKK.s: Assembler messages:
/tmp/cc0ZyvKK.s: Fatal error: can't write build/src/ast_generate.o: File too big
as: build/src/ast_generate.o: too many sections (33098)
/tmp/cc0ZyvKK.s: Fatal error: can't close build/src/ast_generate.o: File too big
scons: *** [build/src/ast_generate.o] Error 1
Adding '-Os'
to my compiler flags, allows the assembler to process the compiler output, but as I see it, it's only a matter of time, until I'll hit the same issue, even with the small optimization flag.
Inspecting, the size optimized object file (ast_generate.o
) using objdump
, tells me that I'm generating pe-x86-64
, which is what I'd expect on Windows.
The 2358
generated sections, is however a shock to me. Mostly as it seems that a section has been generated for each part of the boost::spirit
;
CONTENTS, ALLOC, LOAD, READONLY, DATA, LINK_ONCE_DISCARD
...
60 .pdata$_ZNK5boost5lexer6detail8end_node9unique_idEv 0000000c 0000000000000000 0000000000000000 00030750 2**2
61 .text$_ZNK5boost5lexer6detail8end_node11lexer_stateEv 00000010 0000000000000000 0000000000000000 0003075c 2**4
...
So my questions are;
- Is the number in the error (
too many sections (X)
), the number of sections to be generated, or is it an error code? - Why is a section generated for each data-type?
- What can I do, to avoid having to pass
'-Os'
to my compiler. That is, what can I do to fix the issue, rather than to work around it? - Would splitting the lexer and parse phase into two distinct phases (and compilation units), only connected through a lexer iterator help me out?
Note; I'm compiling using cygwin64
.