Gert Doering wrote:
So, thank you very much for the workaround. We will have to rewrite parts of the software (some modules actually use static String and FILE variables),
So I suppose you'd appreciate a solution. ;-) Well, I can probably work on it a bit this weekend ...
Out of curiosity: do you have any idea what's going on inside gpc/gcc here? Why is it breaking the *link* phase? Are various parts of the system disagreeing on the suffix number to use for the linker?
The problem is that such variables must be initialized. (For file types, it should be possible to do it via static initializers internally, and I might do this in the course of a future change, but not at the moment. For strings, it would theoretically be possible to use a static initializer as well, but since this would force the whole (often large) variable into the initialized data section and blow up executable sizes, I don't think this would be appreciated. So in general, I think we must assume that we need initialization code.)
Static variables must be initialized only once, even if they're local (otherwise they'd lose their values when the containing routine is called again which would defeat much of their purpose). I see two ways of doing it:
1. Initialize them from the module/program constructor. That's what I'm doing now. The problem is that we have to violate the scoping internally, and apparently the current way is not correct since the AIX linker probably considers the variable to be initialized as different from the actual local variable and so runs into unresolved references.
2. Initialize them when the routine is called and use a (static) flag to make sure this is done only once. The disadvantage is that the flag would have to be checked on each call which is a little performance disadvantage. So I'd consider it half a kluge, but still a better kludge than the RTS patch.
So I'll try to fix 1., but if I can't do it now, I'll probably do 2.
Frank