Hi,
On Wed, Jul 07, 2004 at 10:16:17AM +0100, Frank Heckenbach wrote:
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. ;-)
Indeed :-)
Well, I can probably work on it a bit this weekend ...
I'll happily give it a good testing on AIX 5.1 and 5.2...
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.)
Hmmm. Indeed. Things like (in C)
static char text[10000] = "hello, world\n";
might indeed be very wastive on executable size.
I assume pascal strings work similar - a maximum size is allocated, and only the relevant part is initialized.
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).
This is understood :-)
I see two ways of doing it:
- 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.
What I do not understand about this: it's not only the AIX linker that breaks here. On the AIX 5.1 system, I have installed GNU ld, and it displayed the same problems with unresolved symbols.
$ ld --version GNU ld version 2.15 Copyright 2002 Free Software Foundation, Inc.
OTOH, on Linux, with GNU ld, everything works.
$ ld --version GNU ld version 2.15.90.0.1.1 20040303 (SuSE Linux) Copyright 2002 Free Software Foundation, Inc.
... so why does the same approach with the same gcc backend (3.3.3) and the same GNU ld work on Linux, and not on AIX?!
- 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.
Agreed.
So I'll try to fix 1., but if I can't do it now, I'll probably do 2.
Thanks!
gert