public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54791] New: AIX-only: Constructors are not called in main program.
@ 2012-10-03  9:20 adivilceanu at yahoo dot com
  2012-10-03  9:40 ` [Bug target/54791] " paolo.carlini at oracle dot com
                   ` (34 more replies)
  0 siblings, 35 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-10-03  9:20 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

             Bug #: 54791
           Summary: AIX-only: Constructors are not called in main program.
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: adivilceanu@yahoo.com


I work on a very big project on AIX 6.1(TL5 SP7). I migrated from xlC to
gcc(v4.7.2). I have the problem that constructors of a global objects defined
almost anywhere are not called. After searching a lot on this I saw this could
be if the objects are in libs(static or shared) and not referenced. This is not
my case because my global object is defined in the main source file(where main
is defined) and they are referenced.
I try to isolate the problem so I removed all the code from my main source file
and just let the following code:

#include <mybigtreeofconfidentialheaders.h>

class Adiv{
public:
    Adiv(char in_name[])
    {
        printf("Adiv()=%s\n",in_name);
        strcpy(name,in_name);
    }
    ~Adiv()
    {
        printf("~Adiv()=%s\n",name);
    }
    void f()
    {
        printf("f()name=%s\n",name);
    }
    char name[32];
    int x;
};

Adiv a("a");
static Adiv b("b");

int main()
{
    static Adiv c("c");
    a.f();
    b.f();
    c.f();
    return 0;
}


After building and executing I get the following output:
Adiv()=c
f()name=
f()name=
f()name=c
~Adiv()=c

Now, if I remove the #include <mybigtreeofconfidentialheaders.h> then I get the
correct output:
Adiv()=a
Adiv()=b
Adiv()=c
f()name=a
f()name=b
f()name=c
~Adiv()=c
~Adiv()=b
~Adiv()=a

The line I use to compile is:
g++ -c   -w -fno-strict-aliasing -fpermissive -save-temps -DMYCUSTOM_DEFINES
-DIALL_CHECKS -D_AIX_PTHREADS_D7   -Imy_custom_includes main.cpp
The line I use to link is:
g++ -Wl,-bmaxdata:0x40000000
-Wl,-blibpath:/usr/lib/threads:/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.7.2:/usr/lib:/lib
 -Wl,-bloadmap:/map.txt -omyexe main.o myobj_1.o myobj_2.o ...myobj_n.o

I want to mention that beside the pdsmain.cpp I have a lot of other
confidential cpp that I compile and link with pdsmain.cpp, but that should not
affect the constructors calling in the main object file, correct ?

So my basic question is: What could cause the constructors not to be called ?
Its definitely has to do with the big tree of headers. I can not provide them
as they are confidential.
I tried the same build (with the big tree of headers) on Linux and there it
works ! 

If needed I think I can provide the assembly file of the main.cpp with and
without the big tree of headers for you to see the differences.

One more thing:
This thread seems to have the same problem as me but it was never solved:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=2413#c3.
See the comment from " David Obermann 2006-09-20 06:38:07 UTC ".

It seems in both cases the problem is reproducible with big applications on
AIX.
Could be the very number of global objects? Big TOC ?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
@ 2012-10-03  9:40 ` paolo.carlini at oracle dot com
  2012-10-03 13:47 ` dje at gcc dot gnu.org
                   ` (33 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-10-03  9:40 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dje at gcc dot gnu.org
          Component|c++                         |target

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-10-03 09:40:27 UTC ---
CC-ing David.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
  2012-10-03  9:40 ` [Bug target/54791] " paolo.carlini at oracle dot com
@ 2012-10-03 13:47 ` dje at gcc dot gnu.org
  2012-11-02 14:49 ` adivilceanu at yahoo dot com
                   ` (32 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-10-03 13:47 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #2 from David Edelsohn <dje at gcc dot gnu.org> 2012-10-03 13:46:44 UTC ---
Constructors are working because they work without your big header.  I would
try using divide and conquer techniques to reduce the big header and find out
what is interfering with constructors.  It gives all appearances that it is due
to the user code.

Static constructors and destructors are run by functions generated at link
time.  A programmer wrapper around AIX ld called "collect2" scans object files
and libraries for constructors and generates functions that are invoked by AIX
linker -binitfini feature.  You can add -Wl,-debug to the link line to see the
way the AIX linker is invoked and see the helper function.

Is something in the big header changing the mangled names of constructors and
destructors so that they do not use the standard pattern?  Or inserting some
illegal character like dollar sign ($)?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
  2012-10-03  9:40 ` [Bug target/54791] " paolo.carlini at oracle dot com
  2012-10-03 13:47 ` dje at gcc dot gnu.org
@ 2012-11-02 14:49 ` adivilceanu at yahoo dot com
  2012-11-02 14:52 ` adivilceanu at yahoo dot com
                   ` (31 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-02 14:49 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #3 from Adi <adivilceanu at yahoo dot com> 2012-11-02 14:49:03 UTC ---
After more investigation I saw that I managed to get the constructors called by
removing the "inline" keyword from just one constructor of a class that resides
in my master header.

>From my -Wl,-debug linker options I see that this particular constructor name
is used to generate the dynamic initialization in almost every object file.
See debug.txt attached for more details. Look for
"_GLOBAL__I_65535_0__ZN5TraceD2Ev".


Do you know why would that be?   
Is this a bug ?
Do you know why on Linux with the same compiler version and same code is not
happening?

I have around 1000 member functions that are declared "inline" across various
classes.

Do you know if there are any know issues with inline and constructors? Any
compiler options I should be aware of? I am not using any optimization (yet ..
I am planning to). 

Now after I did this I am still having some other problems. Some object seemed
are not initialized properly.  I am still suspecting the other inlines might be
the culprit.

Any ideas/suggestions would be appreciated.






________________________________
 From: dje at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
To: adivilceanu@yahoo.com 
Sent: Wednesday, October 3, 2012 4:46 PM
Subject: [Bug target/54791] AIX-only: Constructors are not called in main
program.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #2 from David Edelsohn <dje at gcc dot gnu.org> 2012-10-03 13:46:44
UTC ---
Constructors are working because they work without your big header.  I would
try using divide and conquer techniques to reduce the big header and find out
what is interfering with constructors.  It gives all appearances that it is due
to the user code.

Static constructors and destructors are run by functions generated at link
time.  A programmer wrapper around AIX ld called "collect2" scans object files
and libraries for constructors and generates functions that are invoked by AIX
linker -binitfini feature.  You can add -Wl,-debug to the link line to see the
way the AIX linker is invoked and see the helper function.

Is something in the big header changing the mangled names of constructors and
destructors so that they do not use the standard pattern?  Or inserting some
illegal character like dollar sign ($)?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (2 preceding siblings ...)
  2012-11-02 14:49 ` adivilceanu at yahoo dot com
@ 2012-11-02 14:52 ` adivilceanu at yahoo dot com
  2012-11-03  6:21 ` adivilceanu at yahoo dot com
                   ` (30 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-02 14:52 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #4 from Adi <adivilceanu at yahoo dot com> 2012-11-02 14:51:50 UTC ---
my attachment as text did not work so I have done it via word doc.



________________________________
 From: "adivilceanu@yahoo.com" <adivilceanu@yahoo.com>
To: dje at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org> 
Sent: Friday, November 2, 2012 4:48 PM
Subject: Re: [Bug target/54791] AIX-only: Constructors are not called in main
program.


After more investigation I saw that I managed to get the constructors called by
removing the "inline" keyword from just one constructor of a class that resides
in my master header.

>From my -Wl,-debug linker options I see that this particular constructor name
is used to generate the dynamic initialization in almost every object file.
See debug.txt attached for more details. Look for
"_GLOBAL__I_65535_0__ZN5TraceD2Ev".


Do you know why would that be?   
Is this a bug ?
Do you know why on Linux with the same compiler version and same code is not
happening?

I have around 1000 member functions that are declared "inline" across various
classes.

Do you know if there are any know issues with inline and constructors? Any
compiler options I should be
 aware of? I am not using any optimization (yet .. I am planning to). 

Now after I did this I am still having some other problems. Some object seemed
are not initialized properly.  I am still suspecting the other inlines might be
the culprit.

Any ideas/suggestions would be appreciated.





________________________________
 From: dje at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
To: adivilceanu@yahoo.com 
Sent: Wednesday, October 3, 2012 4:46 PM
Subject: [Bug target/54791] AIX-only: Constructors are not called in main
program.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #2 from David Edelsohn <dje at gcc dot gnu.org> 2012-10-03 13:46:44
UTC ---
Constructors are working because they work without your big header.  I would
try using divide and conquer techniques to reduce the big header and find out
what is interfering with constructors.  It gives all appearances that it is due
to the user code.

Static constructors and destructors are run by functions generated at link
time.  A programmer wrapper around AIX ld called "collect2" scans object files
and libraries for constructors and generates functions that are invoked by AIX
linker -binitfini feature.  You can add -Wl,-debug to the link line to see the
way the AIX linker is invoked and see the helper
 function.

Is something in the big header changing the mangled names of constructors and
destructors so that they do not use the standard pattern?  Or inserting some
illegal character like dollar sign ($)?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (3 preceding siblings ...)
  2012-11-02 14:52 ` adivilceanu at yahoo dot com
@ 2012-11-03  6:21 ` adivilceanu at yahoo dot com
  2012-11-03  6:24 ` adivilceanu at yahoo dot com
                   ` (29 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-03  6:21 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #5 from Adi <adivilceanu at yahoo dot com> 2012-11-03 06:21:08 UTC ---
Please tell me if you received my email. I got some delivery failures because
of attachments.


----- Forwarded Message -----
From: "adivilceanu@yahoo.com" <adivilceanu@yahoo.com>
To: dje at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org> 
Sent: Friday, November 2, 2012 4:48 PM
Subject: Re: [Bug target/54791] AIX-only: Constructors are not called in main
program.


After more investigation I saw that I managed to get the constructors called by
removing the "inline" keyword from just one constructor of a class that resides
in my master header.

>From my -Wl,-debug linker options I see that this particular constructor name
is used to generate the dynamic initialization in almost every object file.
See debug.txt attached for more details. Look for
"_GLOBAL__I_65535_0__ZN5TraceD2Ev".


Do you know why would that be?   
Is this a bug ?
Do you know why on Linux with the same compiler version and same code is not
happening?

I have around 1000 member functions that are declared "inline" across various
classes.

Do you know if there are any know issues with inline and constructors? Any
compiler options I should be
 aware of? I am not using any optimization (yet .. I am planning to). 

Now after I did this I am still having some other problems. Some object seemed
are not initialized properly.  I am still suspecting the other inlines might be
the culprit.

Any ideas/suggestions would be appreciated.





________________________________
 From: dje at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
To: adivilceanu@yahoo.com 
Sent: Wednesday, October 3, 2012 4:46 PM
Subject: [Bug target/54791] AIX-only: Constructors are not called in main
program.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #2 from David Edelsohn <dje at gcc dot gnu.org> 2012-10-03 13:46:44
UTC ---
Constructors are working because they work without your big header.  I would
try using divide and conquer techniques to reduce the big header and find out
what is interfering with constructors.  It gives all appearances that it is due
to the user code.

Static constructors and destructors are run by functions generated at link
time.  A programmer wrapper around AIX ld called "collect2" scans object files
and libraries for constructors and generates functions that are invoked by AIX
linker -binitfini feature.  You can add -Wl,-debug to the link line to see the
way the AIX linker is invoked and see the helper
 function.

Is something in the big header changing the mangled names of constructors and
destructors so that they do not use the standard pattern?  Or inserting some
illegal character like dollar sign ($)?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (4 preceding siblings ...)
  2012-11-03  6:21 ` adivilceanu at yahoo dot com
@ 2012-11-03  6:24 ` adivilceanu at yahoo dot com
  2012-11-03 13:49 ` dje at gcc dot gnu.org
                   ` (28 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-03  6:24 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #6 from Adi <adivilceanu at yahoo dot com> 2012-11-03 06:24:03 UTC ---
This is the 5thmail I am sending(I got 4 delivery errors because of MIME
attachments).


After more investigation I saw that I managed to get the constructors 
called by removing the "inline" keyword from just one constructor of a 
class that resides in my master header.

From my -Wl,-debug linker
 options I see that this particular constructor name is used to generate
 the dynamic initialization in almost every object file.
See debug.txt attached for more details. Look for
"_GLOBAL__I_65535_0__ZN5TraceD2Ev".


Do you know why would that be?   
Is this a bug ?
Do you know why on Linux with the same compiler version and same code is not
happening?

I have around 1000 member functions that are declared "inline" across various
classes.

Do you know if there are any know issues with inline and
 constructors? Any compiler options I should be
 aware of? I am not using any optimization (yet .. I am planning to). 

Now
 after I did this I am still having some other problems. Some object 
seemed are not initialized properly.  I am still suspecting the other 
inlines might be the culprit.

Any ideas/suggestions would be appreciated.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (5 preceding siblings ...)
  2012-11-03  6:24 ` adivilceanu at yahoo dot com
@ 2012-11-03 13:49 ` dje at gcc dot gnu.org
  2012-11-03 19:15 ` adivilceanu at yahoo dot com
                   ` (27 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-03 13:49 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #7 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-03 13:48:46 UTC ---
The New York area has experienced a major natural disaster. I am located near
NYC. GCC support is provided by volunteers.  Repeatedly resending your message
will not elicit a faster response.

AIX uses the XCOFF file format, not ELF. The object files do not contain .ctor
or .init sections to define constructors. The GCC collect2 wrapper scans object
files for constructors and creates a function to call them.  If the
constructors are inlined, the symbols might not appear when the object files
are scanned, preventing them from being included in the list of constructors to
call.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (6 preceding siblings ...)
  2012-11-03 13:49 ` dje at gcc dot gnu.org
@ 2012-11-03 19:15 ` adivilceanu at yahoo dot com
  2012-11-03 22:48 ` dje at gcc dot gnu.org
                   ` (26 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-03 19:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #8 from Adi <adivilceanu at yahoo dot com> 2012-11-03 19:14:41 UTC ---
Thank you for your response. (Sorry for the repeated emails. I did it because I
got delivery failures on the first 4 mails.)

So just to be 100% sure on this: If I want to be sure all my constructors are
called I should not have any of them inlined. Correct ?
What about if I have a constructor body/implementation inside a class
declaration ? Does the compiler inline that as well? I guess it might.


So how do you see this case. Is it not a bug? I mean I am expecting my
constructors to be called and they are not.
Do you know a easy way to solve this without modifying all my constructors ?
(any compiler options perhaps, ..using __attribute__((constructor)) ) ?



PS: If I want to send you an attachment in a mail what format should it be ?
txt, doc ? I got some delivery failures,... that's why I am asking.



________________________________
 From: dje at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
To: adivilceanu@yahoo.com 
Sent: Saturday, November 3, 2012 3:48 PM
Subject: [Bug target/54791] AIX-only: Constructors are not called in main
program.


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #7 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-03 13:48:46
UTC ---
The New York area has experienced a major natural disaster. I am located near
NYC. GCC support is provided by volunteers.  Repeatedly resending your message
will not elicit a faster response.

AIX uses the XCOFF file format, not ELF. The object files do not contain .ctor
or .init sections to define constructors. The GCC collect2 wrapper scans object
files for constructors and creates a function to call them.  If the
constructors are inlined, the symbols might not appear when the object files
are scanned, preventing them from being included in the list of constructors to
call.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (7 preceding siblings ...)
  2012-11-03 19:15 ` adivilceanu at yahoo dot com
@ 2012-11-03 22:48 ` dje at gcc dot gnu.org
  2012-11-05 14:34 ` adivilceanu at yahoo dot com
                   ` (25 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-03 22:48 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

David Edelsohn <dje at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-11-03
     Ever Confirmed|0                           |1

--- Comment #9 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-03 22:48:06 UTC ---
> So just to be 100% sure on this: If I want to be sure all my constructors are
> called I should not have any of them inlined. Correct ?
> What about if I have a constructor body/implementation inside a class
> declaration ? Does the compiler inline that as well? I guess it might.

I am not positive that inlining is the problem, but that seems like a good
hypothesis.  collect2 scans object files looking for constructors by name,
e.g.,

GLOBAL__I_<xxxx>

You can look at the global symbols using

$ nm -BCpg xxxx.o

If the constructors are visible when NOT inlined and disappear when they are
inlined, that is the problem.  If "nm" cannot see them, the mechanism for
creating the list of constructors (and destructors) cannot see them either.

> So how do you see this case. Is it not a bug? I mean I am expecting my
> constructors to be called and they are not.
> Do you know a easy way to solve this without modifying all my constructors ?
> (any compiler options perhaps, ..using __attribute__((constructor)) ) ?

The methods already are constructors.  Additional attributes will not make a
difference.

If you can create a small, self-contained testcase with a constructor that
works or does not work depending on inlined, I can look. I am not sure how
inlined constructors are recorded in ELF files.  This sounds like a bug, but it
will take some investigation to figure out how difficult it is to fix given the
behavior of AIX and GCC.  Inlined constructors may not be a practical option on
AIX.

Also, please use the GCC Bugzilla interface for comments and attaching
testcases, not email replies. There probably is a way to add attachments using
email, but I do not know how and Bugzilla is much more useful without all of
the email history already present in the comment history.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (8 preceding siblings ...)
  2012-11-03 22:48 ` dje at gcc dot gnu.org
@ 2012-11-05 14:34 ` adivilceanu at yahoo dot com
  2012-11-05 18:55 ` dje at gcc dot gnu.org
                   ` (24 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-05 14:34 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #10 from Adi <adivilceanu at yahoo dot com> 2012-11-05 14:34:25 UTC ---
I found the real problem ! 
Now it can be reproducible even with a small test case.

I can summarize it like this: If you have a global object/function defined in
"n" different object files, then the constructors in the "n-1" object files
might not be invoked at all. This will happen always for sure if the
object/function is the first thing defined in those object files.

Explination: Each object file when complied with g++ for AIX, will get a
_GLOBAL__I_65535_0__***name_of_first_object_defined_in_this_compilation
unit***.
Now if there are 2 object file that have defined in them an object/function
with the same name/signature then these 2 object files will get the same
_GLOBAL__* symbol. 
Now later when the collect2 is involved it will take just one _GLOBAL__* into
account. It will ignore the other n-1 symbols and so n-1 object remain with all
their object's constructors not called.

Given the above I have fixed my project not to have this situation(object with
same name in multiple compilation units) and every constructor in my project is
called now !

So it has nothing to do with inline as I first suspected. My inline sub-problem
just was a side-effect of the real problem.

Do you consider this being a bug? I think it is. Even if no fix is provided at
least for me now something that would have been very usefull is if collect2
would have issued a more explicit message like "Multiple definitions of global
objects with the same name; Some global objects will not be initialied !".

I mean in the collect2 it is known that if it encounters this situation that
there will be objects that will remain not-initialized. Right?

Now that I solve this problem I have one new problem: It is related to the
order of initialization of global objects across multiple compilation units.
Shout I continue on this thread or open a new one? I am not sure its a bug.. I
first have some questions on it.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (9 preceding siblings ...)
  2012-11-05 14:34 ` adivilceanu at yahoo dot com
@ 2012-11-05 18:55 ` dje at gcc dot gnu.org
  2012-11-05 21:14 ` adivilceanu at yahoo dot com
                   ` (23 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-05 18:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #11 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-05 18:54:47 UTC ---
I believe that the G++ front end tries to create a unique name from the first
symbol it sees.  I do not now if this is related to the constructor name
collision that you are seeing.

Is it valid C++ to define an object with the same name in multiple files? I
cannot tell if you were doing something that happened to work but the behavior
is not clearly defined by the language, or if this is allowed and does not work
on AIX, in which case it is a bug.

Why does inlining or not inlining affect the name collision?

Do SVR4/ELF systems mangle each of the constructors uniquely?  I thought that
they all would end up in the ".init" sections, which will be concatenated. I am
curious how the calls to the different ctors are disambiguated at link time.

collect2 could warn, but it currently does not scan the constructor names it
finds for duplicates in its object file scan.  A warning would be nice, but I
do not know if it is valid C++ that it should expect.

I am not sure what you mean by order of initialization of global constructors
across compilation units.  This is within one library?  GCC has a way to
decorate constructors with a priority to order the constructors. If you mean
order of constructors among multiple shared libraries, that is a separate,
known issue on AIX.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (10 preceding siblings ...)
  2012-11-05 18:55 ` dje at gcc dot gnu.org
@ 2012-11-05 21:14 ` adivilceanu at yahoo dot com
  2012-11-06 14:46 ` dje at gcc dot gnu.org
                   ` (22 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-05 21:14 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #12 from Adi <adivilceanu at yahoo dot com> 2012-11-05 21:14:22 UTC ---
(In reply to comment #11)
> I believe that the G++ front end tries to create a unique name from the first
> symbol it sees.  I do not now if this is related to the constructor name
> collision that you are seeing.
    What do you mean that it is not related? From my point of view it is.

> 
> Is it valid C++ to define an object with the same name in multiple files? I
> cannot tell if you were doing something that happened to work but the behavior
> is not clearly defined by the language, or if this is allowed and does not work
> on AIX, in which case it is a bug.
    I agree with you here. This is why I am not insisting that this is a bug. I
mean you can expect bad results if you define this. BTW on Linux GNU ld does
not let me to define 2 globals with same name. I get a multiple definition
error. it seems that the AIX ld is more friendly :(.

> 
> Why does inlining or not inlining affect the name collision?
  Because if you have a function declared as inline in a header file that gets
propagated to multiple source files is ok, but in my case that inline keyword
was removed by some $ifdef LINUX and so I end up with having the constructor
body defined in the header  like this: ClassA::ClassA(){//body}. Now because
this is in the header it will propagate to all sources that includes it. So
finally I end up with that constructor in multiple constructors sources. This
would not happen if the inline keyword have not been removed from it. This was
a bug in our code and I removed it.

> 
> Do SVR4/ELF systems mangle each of the constructors uniquely?  I thought that
> they all would end up in the ".init" sections, which will be concatenated. I am
> curious how the calls to the different ctors are disambiguated at link time.
  I admit I am not very good at compilers(I am  a beginner in understanding how
compilers are working on various platforms ) so on this question I am going to
make assumptions. 
  I am going to test on Linux and see what happens there.

> 
> collect2 could warn, but it currently does not scan the constructor names it
> finds for duplicates in its object file scan.  A warning would be nice, but I
> do not know if it is valid C++ that it should expect.

> 
> I am not sure what you mean by order of initialization of global constructors
> across compilation units.  This is within one library?  GCC has a way to
> decorate constructors with a priority to order the constructors. If you mean
> order of constructors among multiple shared libraries, that is a separate,
> known issue on AIX.
  Our project has one exe and several shared and static libs. To make the
things easier I moved every source file in the exe. Now the problem I have is
with the order of the initialization of global objects that reside in multiple
object files. I need objects in a source file by constructed first before any
other objects in the rest of the files are constructed.
  You said that I can decorate the constructors with a priority. How to do that
? Before migrating from xlC we used #pragma priority. This is ignored by gcc.
We also used -qpriority flag of xlC. Also gcc does not have something like
this. Or?
  Also I tried moving the objects I need constructed in the source files where
main() is defined. Still seems that these objects are not constructed first.
  Also I put the object file where these objects are defined as the first one
wen passing to the linker. Still no luck.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (11 preceding siblings ...)
  2012-11-05 21:14 ` adivilceanu at yahoo dot com
@ 2012-11-06 14:46 ` dje at gcc dot gnu.org
  2012-11-06 16:23 ` adivilceanu at yahoo dot com
                   ` (21 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-06 14:46 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #13 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-06 14:46:34 UTC ---
> Because if you have a function declared as inline in a header file that gets
propagated to multiple source files is ok, but in my case that inline keyword
was removed by some $ifdef LINUX and so I end up with having the constructor
body defined in the header  like this: ClassA::ClassA(){//body}. Now because
this is in the header it will propagate to all sources that includes it. So
finally I end up with that constructor in multiple constructors sources. This
would not happen if the inline keyword have not been removed from it. This was
a bug in our code and I removed it.

Okay, so the problem was *lack* of inlined constructors. Now that makes more
sense.

> Our project has one exe and several shared and static libs. To make the
things easier I moved every source file in the exe. Now the problem I have is
with the order of the initialization of global objects that reside in multiple
object files. I need objects in a source file by constructed first before any
other objects in the rest of the files are constructed.

If you actually create shared libraries, you should add -fPIC to the
compilation command. This also adds some additional uniqueness to symbols.

> You said that I can decorate the constructors with a priority. How to do that
? Before migrating from xlC we used #pragma priority. This is ignored by gcc.
We also used -qpriority flag of xlC. Also gcc does not have something like
this. Or?

Use __attribute__ ((init_priority (NNNN)))

http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (12 preceding siblings ...)
  2012-11-06 14:46 ` dje at gcc dot gnu.org
@ 2012-11-06 16:23 ` adivilceanu at yahoo dot com
  2012-11-06 21:50 ` adivilceanu at yahoo dot com
                   ` (20 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-06 16:23 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #14 from Adi <adivilceanu at yahoo dot com> 2012-11-06 16:22:37 UTC ---
Regarding the __attribute__ ((init_priority (NNNN))).
Are you sure this works on AIX at namespace level. I think it might work on
linux. But on AIX I see no way of that ever working. 
Here is my understanding on how collect2 works on AIX(correct me if I am
wrong):
- g++ front end creates one _GLOBAL__I_65535_0_<nameoffirstobject> per object
file. Here it is putting all the static constructors that should be called from
that object file. 
- collect2 links (via ld) the whole exe(+libs). Then it is scanning all the
_GLOBAL__ and is putting them into the ctors array and generates a functions
named _GLOBAL__FI_<exe_name> that will call each _GLOBAL__* entry fro the array
in reverse order.

So as I see it this whole mechanism can at maximum support priority ordering on
a object file basis. (I mean it could sort the _GLOBAL__* entries according to
some criteria). Question: How can you influence this criteria? I did a hack and
altered the ctors array generated by collect2(in that /tmp//ccGVUVzP.c) and
reordered all those _GLOBAL__* entries based on my project needs. Then I
recompiled the  ccGVUVzP.c file and manually called ld (like g++ is doing the
second time).  So somehow I simulate the #pragma priority from xlC on a file
basis. And the hack worked.

Now if you use init_priority for a single global variable in an object file,
and use it again on another global in a different object file I do not see how
this could work? How would bypass the _GLOBAL__* entries in the ctors array
which is already sorted?

So my big assumption here is(correct me if I am wrong): On gcc for AIX, all
globals from an object file are initialized before globals from another object
file are. So you can not have initialization of one global1 from object1.o and
then global2 from object2 and then global3 from object1 again. Is my assuption
correct? If so a __attribute__ ((init_priority is not ok for what I need.

Now regarding the fPIC. I just started using it now. That has changed a lot of
stuff. First the _GLOABL__* names are now based on file name rather than name
of first object. I am just starting to test this. I will follow up with the
results.
Thanks for your support.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (13 preceding siblings ...)
  2012-11-06 16:23 ` adivilceanu at yahoo dot com
@ 2012-11-06 21:50 ` adivilceanu at yahoo dot com
  2012-11-07  1:27 ` dje at gcc dot gnu.org
                   ` (19 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-06 21:50 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #15 from Adi <adivilceanu at yahoo dot com> 2012-11-06 21:49:47 UTC ---
This is a follow up on comment 14.

It seems that -fPIC dramatically improved the way constructors are called. It
seems that the linker has some logic and is initializing the globals from
various object files in a correct order.(it somehow checks the dependencies
betweeen globals I assume). I don't know how this is happening yet. As I see
the ctors array has the same elements(except for the generated name that has
changed), so something other then the ctors list is involved here. Do you know
what?

Now this works on my exe that is linked with static libs. Now if I go and link
my exe with the shared version of my libs than it is not working. 

I saw this is because first all the constructors from the exe are called first
and only after that constructors from the shared libs are called. But as I said
I need some objects from the shared lib constructed first before objects in the
main exe are initialized. Do you know how I can solve this case ?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (14 preceding siblings ...)
  2012-11-06 21:50 ` adivilceanu at yahoo dot com
@ 2012-11-07  1:27 ` dje at gcc dot gnu.org
  2012-11-07 14:46 ` adivilceanu at yahoo dot com
                   ` (18 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-07  1:27 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #16 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-07 01:27:00 UTC ---
G++ should create one specially named _GLOBAL__I_NNNNN_XXXXX function per
constructor.  collect2 sorts the constructors based on the NNNNN priority
number encoded in the name.  If G++ is not creating separate constructors, then
that is a general G++ question and not AIX-specific.

As far as the problem with shared libs, this is a known, general deficiency in
AIX. This is what I referenced in comment #13. AIX runs initializers
breadth-first, not depth-first. There is another GCC Bugzilla PR open about
this problem.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (15 preceding siblings ...)
  2012-11-07  1:27 ` dje at gcc dot gnu.org
@ 2012-11-07 14:46 ` adivilceanu at yahoo dot com
  2012-11-07 15:25 ` adivilceanu at yahoo dot com
                   ` (17 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-07 14:46 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #17 from Adi <adivilceanu at yahoo dot com> 2012-11-07 14:45:59 UTC ---
Finally I got it working. You are right, there are _GLOBAL* symbols generated
for each constructor, but only when you specify the init_priority  attr for
that object. (otherwise there is just on _GLOBAL per file). 

Also init_priority did not work previously on my side because of how I put it
in the code: "ClassName objName("some string") __attribute__ ((init_priority
(NNNN)));
I realized that I need to put the _attribute_ between the objName and ("some
string").

So now my whole project works with static libs.

Do you know what I can do for shared libs?

Can I take advantage of the -binitfini option on the lib to somehow set a
priority for the hole lib? I need a lib to initialize before the main exe gets
initialized.

Thanks !


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (16 preceding siblings ...)
  2012-11-07 14:46 ` adivilceanu at yahoo dot com
@ 2012-11-07 15:25 ` adivilceanu at yahoo dot com
  2012-11-07 22:15 ` dje at gcc dot gnu.org
                   ` (16 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-07 15:25 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #18 from Adi <adivilceanu at yahoo dot com> 2012-11-07 15:25:27 UTC ---
Follow up on comment 17:


1) I did try to set the priority on the shared lib (via -binitfini) and it does
not work.  I mean the priority is set but the exe is still the one that is
getting initialized first.

2) I did manage to make my project work with shared libs by doing the following
hack:
I rewrite the generated file(the one collect2 generates) from /tmp so that the
_GLOBAL__FI_<name of my exe> is calling the _GLOBAL__FI_<name_of_my_shaderlib>:
void _GLOBAL__FI_<name of my exe>() {
        _GLOBAL__FI_<name_of_my_shaderlib>;
    static entry_pt *ctors[] = {
        x11,
    reg_frame,
    };
    entry_pt **p;
    if (count++ != 0) return;
    p = ctors + 2;
    while (p > ctors) (*--p)();
} 
Then I recompiled this file and relink it with ld and it works.

So basically I got the lib to get initialized before the exe is initialized.
It is true though that my whole lib will be initialized and only after that my
exe will be. So if I set init_priority on 2 objects(one in exe and on in the
shared lib) it will not work. I mean always all the objects from the lib will
get initialized first regardless of the init_priority on the exe. Right ?

Can you tell me a more elegant solution to this ?(if there is). If not at least
how can I do this more automatically? Now I do some steps manually(like going
to /tmp and modify that file and recompile it and relink).

I wander how this has worked with xlC. There we used the -p flag when linking
the shared libraries with makeCCSharedLibs, and I think (not 100% sure )the
library got first initialized.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (17 preceding siblings ...)
  2012-11-07 15:25 ` adivilceanu at yahoo dot com
@ 2012-11-07 22:15 ` dje at gcc dot gnu.org
  2012-11-13  8:21 ` adivilceanu at yahoo dot com
                   ` (15 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-07 22:15 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

David Edelsohn <dje at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |33704

--- Comment #19 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-07 22:15:23 UTC ---
> Can you tell me a more elegant solution to this ?(if there is). If not at least
how can I do this more automatically? Now I do some steps manually(like going
to /tmp and modify that file and recompile it and relink).

For the shared library dependency order see PR 33704.  The PR includes a patch,
but we never reached a final resolution and copyright assignment to include the
patch.

> I wonder how this has worked with xlC. There we used the -p flag when linking
the shared libraries with makeCCSharedLibs, and I think (not 100% sure )the
library got first initialized.

xlC now uses a program instead of a script. It generates some code to
explicitly run constructors in the right order and does not rely on AIX
semantics.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (18 preceding siblings ...)
  2012-11-07 22:15 ` dje at gcc dot gnu.org
@ 2012-11-13  8:21 ` adivilceanu at yahoo dot com
  2012-11-13  8:30 ` adivilceanu at yahoo dot com
                   ` (14 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-13  8:21 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #20 from Adi <adivilceanu at yahoo dot com> 2012-11-13 08:21:12 UTC ---
Created attachment 28672
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28672
the error while building gcc

the error while building gcc 4.7.2


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (19 preceding siblings ...)
  2012-11-13  8:21 ` adivilceanu at yahoo dot com
@ 2012-11-13  8:30 ` adivilceanu at yahoo dot com
  2012-11-13 14:03 ` dje at gcc dot gnu.org
                   ` (13 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-13  8:30 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #21 from Adi <adivilceanu at yahoo dot com> 2012-11-13 08:29:51 UTC ---
I am trying to build gcc 4.7.2 in order to apply the patch you suggested.
I did the following:
-download the gcc 4.7.2
-unzip and untar to to the root directory.
mkdir /gcc-build
cd /gcc-build
../gcc-4.7.2/configure --enable-languages=c,c++
make

When making I get the errors from the attachment I put on Comment 20.

I am using:
AIX (oslevel -s = 6100-06-09-1228)
make-3.80-1
mpfr-3.1.0-1
libmpc-0.9-1
mpfr-devel-3.1.1-1
gmp-5.0.5-1
gmp-devel-5.0.5-1
libmpc-devel-1.0.1-2

Do you know why I am getting this ?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (20 preceding siblings ...)
  2012-11-13  8:30 ` adivilceanu at yahoo dot com
@ 2012-11-13 14:03 ` dje at gcc dot gnu.org
  2012-11-13 14:09 ` adivilceanu at yahoo dot com
                   ` (12 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-13 14:03 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #22 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-13 14:02:48 UTC ---
The patch in PR 33704 makes no changes to libstdc++ or to any GCC , so I have
no idea why you are seeing C++ errors compiling c-lang.c. Something else was
modified.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (21 preceding siblings ...)
  2012-11-13 14:03 ` dje at gcc dot gnu.org
@ 2012-11-13 14:09 ` adivilceanu at yahoo dot com
  2012-11-14 14:20 ` dje at gcc dot gnu.org
                   ` (11 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-13 14:09 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #23 from Adi <adivilceanu at yahoo dot com> 2012-11-13 14:08:42 UTC ---
I did not put the patch yet.
This is just gcc 4.7.2 original sources. Why would they not compile?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (22 preceding siblings ...)
  2012-11-13 14:09 ` adivilceanu at yahoo dot com
@ 2012-11-14 14:20 ` dje at gcc dot gnu.org
  2012-11-27 15:54 ` adivilceanu at yahoo dot com
                   ` (10 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-14 14:20 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #24 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-14 14:20:06 UTC ---
I successfully built GCC 4.7 earlier this week.

You may need to use GMP 4.3.2, not GMP 5.0


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (23 preceding siblings ...)
  2012-11-14 14:20 ` dje at gcc dot gnu.org
@ 2012-11-27 15:54 ` adivilceanu at yahoo dot com
  2012-11-27 18:55 ` adivilceanu at yahoo dot com
                   ` (9 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-27 15:54 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #25 from Adi <adivilceanu at yahoo dot com> 2012-11-27 15:54:30 UTC ---
One more question: Do you know why cc1plus and cc1 have around 300 Mb after I
build them ? I just did configure and make on the official sources.(now other
options)
I see that on the official rpm-s  they have around 10 Mb.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (24 preceding siblings ...)
  2012-11-27 15:54 ` adivilceanu at yahoo dot com
@ 2012-11-27 18:55 ` adivilceanu at yahoo dot com
  2012-11-27 19:01 ` adivilceanu at yahoo dot com
                   ` (8 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-27 18:55 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #26 from Adi <adivilceanu at yahoo dot com> 2012-11-27 18:55:08 UTC ---
One more question: Do you know why cc1plus and cc1 have around 300 Mb after I
build them ? I just did configure and make on the official sources.(now other
options)
I see that on the official rpm-s  they have around 10 Mb.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (25 preceding siblings ...)
  2012-11-27 18:55 ` adivilceanu at yahoo dot com
@ 2012-11-27 19:01 ` adivilceanu at yahoo dot com
  2012-11-27 20:42 ` dje at gcc dot gnu.org
                   ` (7 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-27 19:01 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #27 from Adi <adivilceanu at yahoo dot com> 2012-11-27 19:00:53 UTC ---
I have put gmp 4.3.2 and still I get the errors when it builds libstdc++-v3.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (26 preceding siblings ...)
  2012-11-27 19:01 ` adivilceanu at yahoo dot com
@ 2012-11-27 20:42 ` dje at gcc dot gnu.org
  2012-11-28 14:01 ` adivilceanu at yahoo dot com
                   ` (6 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-27 20:42 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #28 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-27 20:42:06 UTC ---
Is the executable size due to debugging information? Do the RPMs contain
stripped executables?

I do not know why your build is failing. It looks like a conflict due to your
GMP installation.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (27 preceding siblings ...)
  2012-11-27 20:42 ` dje at gcc dot gnu.org
@ 2012-11-28 14:01 ` adivilceanu at yahoo dot com
  2012-11-28 19:35 ` dje at gcc dot gnu.org
                   ` (5 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-28 14:01 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #29 from Adi <adivilceanu at yahoo dot com> 2012-11-28 14:00:55 UTC ---
Ok... if you are so kind please tell me exactly

1) how did you install the gcc(you said it works on your aix) ? I mean what
mpfr,gmp, libmpc did you use and how did you install them?

2) How did you configure gcc before makeing? (the exact command line)

3) what aix do you you use(oslevel -s) ? and any other pre-requisites that I
should put in order for me to have my gcc built.(environment vars... etc)


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (28 preceding siblings ...)
  2012-11-28 14:01 ` adivilceanu at yahoo dot com
@ 2012-11-28 19:35 ` dje at gcc dot gnu.org
  2012-11-29  9:35 ` adivilceanu at yahoo dot com
                   ` (4 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-11-28 19:35 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #30 from David Edelsohn <dje at gcc dot gnu.org> 2012-11-28 19:35:36 UTC ---
> 1) how did you install the gcc(you said it works on your aix) ? I mean what
> mpfr,gmp, libmpc did you use and how did you install them?

I built gmp, mpfr and mpc from source code and installed them in a local
directory. I configure GCC with --with-gmp=/path/to/tools

2) How did you configure gcc before makeing? (the exact command line)

You can see this in my regular GCC testsuite results.

/gsa/yktgsa/home/e/d/edelsohn/src/src/configure
--prefix=/gsa/yktgsa/home/e/d/edelsohn/install/powerpc-ibm-aix7.1.0.0-20121127
--disable-werror --enable-languages=c,c++,fortran,objc --with-gmp=/usr/gnu
--with-mpfr=/usr/gnu --with-cloog=no --with-ppl=no --disable-libstdcxx-pch
--with-boot-ldflags=-L/usr/gnu/lib

3) what aix do you you use(oslevel -s) ? and any other pre-requisites that I
should put in order for me to have my gcc built.(environment vars... etc)

I recently have built with AIX 7.1. I think it technically is 7.1.1 but not all
filesets were upgraded so oslevel is not accurate. I previously built regularly
with AIX 5.3 and have built with AIX 6.1. There were some problems with the AIX
assembler that caused errors at link time, but not the type of errors that you
are reporting.

You also can contact Michael Perzl who has GCC 4.7 builds for nearly all recent
releases of AIX. http://www.perzl.org/


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (29 preceding siblings ...)
  2012-11-28 19:35 ` dje at gcc dot gnu.org
@ 2012-11-29  9:35 ` adivilceanu at yahoo dot com
  2012-11-29  9:44 ` adivilceanu at yahoo dot com
                   ` (3 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-29  9:35 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #31 from Adi <adivilceanu at yahoo dot com> 2012-11-29 09:34:54 UTC ---
OK I finally managed to get it working.

The problem was I was using the rpm packages from perlz.org for mpfr,gmp and
libmpc. Both gmp 4.3.2 and 5.0 gave me the gcc errors.

But when compiling the on my own machine gcc finally worked.

I will write further to Michael for gcc configuration. 

Thanks


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (30 preceding siblings ...)
  2012-11-29  9:35 ` adivilceanu at yahoo dot com
@ 2012-11-29  9:44 ` adivilceanu at yahoo dot com
  2012-12-01 21:42 ` dje at gcc dot gnu.org
                   ` (2 subsequent siblings)
  34 siblings, 0 replies; 36+ messages in thread
From: adivilceanu at yahoo dot com @ 2012-11-29  9:44 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #32 from Adi <adivilceanu at yahoo dot com> 2012-11-29 09:43:45 UTC ---
One more question:

If I intend to use the patch from PR 33704 to modify my gcc and then build
commercial applications with it, is that ok? Would that raise any
copyright/legal issues?


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (31 preceding siblings ...)
  2012-11-29  9:44 ` adivilceanu at yahoo dot com
@ 2012-12-01 21:42 ` dje at gcc dot gnu.org
  2015-03-18 12:42 ` dje at gcc dot gnu.org
  2015-03-18 12:49 ` dje at gcc dot gnu.org
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2012-12-01 21:42 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

--- Comment #33 from David Edelsohn <dje at gcc dot gnu.org> 2012-12-01 21:42:10 UTC ---
You cannot ask legal questions and expect to receive an answer.


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (32 preceding siblings ...)
  2012-12-01 21:42 ` dje at gcc dot gnu.org
@ 2015-03-18 12:42 ` dje at gcc dot gnu.org
  2015-03-18 12:49 ` dje at gcc dot gnu.org
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2015-03-18 12:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791
Bug 54791 depends on bug 33704, which changed state.

Bug 33704 Summary: AIX runs c++ constructors in incorrect order
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33704

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED


^ permalink raw reply	[flat|nested] 36+ messages in thread

* [Bug target/54791] AIX-only: Constructors are not called in main program.
  2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
                   ` (33 preceding siblings ...)
  2015-03-18 12:42 ` dje at gcc dot gnu.org
@ 2015-03-18 12:49 ` dje at gcc dot gnu.org
  34 siblings, 0 replies; 36+ messages in thread
From: dje at gcc dot gnu.org @ 2015-03-18 12:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54791

David Edelsohn <dje at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |WAITING

--- Comment #34 from David Edelsohn <dje at gcc dot gnu.org> ---
Is this still failing with GCC 4.9 or trunk?


^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2015-03-18 12:49 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-03  9:20 [Bug c++/54791] New: AIX-only: Constructors are not called in main program adivilceanu at yahoo dot com
2012-10-03  9:40 ` [Bug target/54791] " paolo.carlini at oracle dot com
2012-10-03 13:47 ` dje at gcc dot gnu.org
2012-11-02 14:49 ` adivilceanu at yahoo dot com
2012-11-02 14:52 ` adivilceanu at yahoo dot com
2012-11-03  6:21 ` adivilceanu at yahoo dot com
2012-11-03  6:24 ` adivilceanu at yahoo dot com
2012-11-03 13:49 ` dje at gcc dot gnu.org
2012-11-03 19:15 ` adivilceanu at yahoo dot com
2012-11-03 22:48 ` dje at gcc dot gnu.org
2012-11-05 14:34 ` adivilceanu at yahoo dot com
2012-11-05 18:55 ` dje at gcc dot gnu.org
2012-11-05 21:14 ` adivilceanu at yahoo dot com
2012-11-06 14:46 ` dje at gcc dot gnu.org
2012-11-06 16:23 ` adivilceanu at yahoo dot com
2012-11-06 21:50 ` adivilceanu at yahoo dot com
2012-11-07  1:27 ` dje at gcc dot gnu.org
2012-11-07 14:46 ` adivilceanu at yahoo dot com
2012-11-07 15:25 ` adivilceanu at yahoo dot com
2012-11-07 22:15 ` dje at gcc dot gnu.org
2012-11-13  8:21 ` adivilceanu at yahoo dot com
2012-11-13  8:30 ` adivilceanu at yahoo dot com
2012-11-13 14:03 ` dje at gcc dot gnu.org
2012-11-13 14:09 ` adivilceanu at yahoo dot com
2012-11-14 14:20 ` dje at gcc dot gnu.org
2012-11-27 15:54 ` adivilceanu at yahoo dot com
2012-11-27 18:55 ` adivilceanu at yahoo dot com
2012-11-27 19:01 ` adivilceanu at yahoo dot com
2012-11-27 20:42 ` dje at gcc dot gnu.org
2012-11-28 14:01 ` adivilceanu at yahoo dot com
2012-11-28 19:35 ` dje at gcc dot gnu.org
2012-11-29  9:35 ` adivilceanu at yahoo dot com
2012-11-29  9:44 ` adivilceanu at yahoo dot com
2012-12-01 21:42 ` dje at gcc dot gnu.org
2015-03-18 12:42 ` dje at gcc dot gnu.org
2015-03-18 12:49 ` dje at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).