Closed Bug 580590 Opened 9 years ago Closed 9 years ago

js/src/xpconnect/wrappers failed to compile with Sun Studio 12

Categories

(Core :: XPConnect, defect)

All
iOS 3
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla2.0b4

People

(Reporter: ginnchen+exoracle, Assigned: ginnchen+exoracle)

Details

Attachments

(2 files)

Sun Studio 12 is doing this:
If a header file foo.h has template declarations, the compiler by default searches for a file foo with a C++ file extension (foo.c, foo.cc, foo.C, foo.cpp, foo.c++) and includes it automatically if it is found.

But FilteringWrapper.cpp and XrayWrapper.cpp have static functions / variables, it will introduce multiple declaration.

I think we can fix it by these options:

1) Rename FilteringWrapper.cpp XrayWrapper.cpp to FilteringWrapperImpl.cpp XrayWrapperImpl.cpp (or some other good names).

2) Copy code of FilteringWrapper.cpp XrayWrapper.cpp to FilteringWrapper.h, XrayWrapper.h and make header files idempotent.

3) Use -template=no%extdef to disable this behavior of Sun Studio.

I tried 1) 2), both can get around the problem.
I didn't try 3), I'm afraid I have to add the option globally, it might cause problems.

I think option 1) is easiest and safest.

gal, what do you think?
(In reply to comment #0)
> I didn't try 3), I'm afraid I have to add the option globally, it might cause
> problems.

Globally within Gecko/JS?  AFAIK no other compiler has this behaviour, so we are unlikely to depend on it anywhere... sounds like an option that we'd really want globally.
I cannot compile on AIX 'till now. Bustage long before this dir. But I'm quite sure IBM's XLC/C++ won't compile this, too.
Option 3) seems like the winner by a long shot, if it can be made to work.

I wasn't aware of this auto-include behavior. I suspect it will only break again and again as we continue to use templates more.
Looking at the Sun Studio documentation:

http://docs.sun.com/app/docs/doc/820-7599/6nirkt6ok?l=en&a=view#indexterm-268
http://docs.sun.com/app/docs/doc/820-7599/bkaev?l=en&a=view
Looking at the Sun Studio documentation:

http://docs.sun.com/app/docs/doc/820-7599/6nirkt6ok?l=en&a=view#indexterm-268
http://docs.sun.com/app/docs/doc/820-7599/bkaev?l=en&a=view

leaves me with the strong impression that we should not be compiling with the "Template Definitions Separate" model. Especially section 7.5.3. Code has to be written specially to work that way, and ours is just ordinary C++.

It's a mystery to me why Sun Studio has -template=extdef on by default.

leaves me with the strong impression that we should not be compiling with the "Template Definitions Separate" model. Especially section 7.5.3. Code has to be written specially to work that way, and ours is just ordinary C++.

It's a mystery to me why Sun Studio has -template=extdef on by default.
Sorry. Crossed my eyes writing that post; looked fine when I hit "Save Changes".
Thanks for your comments!

I tried to put -template=no%extdef globally and firefox builds fine.
So I think we can do it.
Attached patch patchSplinter Review
Assignee: nobody → ginn.chen
Status: NEW → ASSIGNED
Attachment #459157 - Flags: review?(benjamin)
Attachment #459157 - Flags: review?(benjamin) → review+
http://hg.mozilla.org/mozilla-central/rev/26ee1b556bd9
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b4
Attachment #463443 - Flags: review?(bugspam.Callek)
Attachment #463443 - Flags: review?(bugspam.Callek) → review+
Pushed to comm-central:
http://hg.mozilla.org/comm-central/rev/ac800fa55a0f
OS: OpenSolaris → iOS 3
You need to log in before you can comment on or make changes to this bug.