Open mmastrac opened 3 years ago
Thanks for your problem reporting and sample code. Please could you give me compilable sample to be able reproduce this performance issue. What host OS, compiler version (32/64-bit) and compiler options you are using?
I'm using a docker container in which I've wrapped up the 2021-05-01 release. I think that the problem comes from a combination of a 1) large initializer inside a function, 2) not static and 3) -fnonconst-initializers
.
Here's the container invocation that will reproduce it (I'm on a mac and have not tried the native mac compiler).
docker run --rm -v /tmp/:/src/ mmastrac/openwatcom:2021-05-01 owcc -std=c99 -fnonconst-initializers -c /src/_kalos_idl_compiler.c -o /src/foo.o
Attached is a repro of the three files I used, minimized a bit. Note that it compiles fine without -fnonconst-initializers
, but adding in -fnonconst-initializers
makes the compile drastically slower.
If I switch out the byte array for strings, the compilation returns to normal speed. It appears to have something to do with char literals, -fnonconst-initializers
and function-local, large definitions.
While compiling one of my projects for DOS, I ran into an interesting problem with constant arrays within functions. If an array is declared inside of a function with 10k+ elements (eg: from an
#include
generated byxxd
), declaring itstatic const
is fine, but declaring it justconst
blows up the compile time to minutes (!).This only appears to be a problem with
xxd
-style large arrays. The problem does not occur when#include
ing a datafile containing a string of exactly the same size.Here is the place where the include is blowing up compile times: https://github.com/mmastrac/kalos/blob/dcf411d676cff22d0e69dd0a32e3bb7cf0fac1c4/src/_kalos_idl_compiler.c#L363
This is the file that was included before that was blowing up the compile time: https://github.com/mmastrac/kalos/blob/45dc1153067cde6ca9b121fbb4f2dc90daad1d2b/src/_kalos_idl_compiler.kalos.inc
And here is the one that works file: https://github.com/mmastrac/kalos/blob/dcf411d676cff22d0e69dd0a32e3bb7cf0fac1c4/src/_kalos_idl_compiler.kalos.inc