Closed Bug 492720 Opened 16 years ago Closed 16 years ago

libgjs failed to compile with jsopcode.h of Firefox 3.5 beta 4

Categories

(Core :: JavaScript Engine, defect, P2)

1.9.1 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla1.9.1
Tracking Status
status1.9.1 --- .2-fixed

People

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

Details

(Keywords: regression)

Attachments

(3 files, 1 obsolete file)

The error message is cc -G -h console.so -o .libs/console.so .libs/console_la-console.o -R/export/home/brianca/packages/BUILD/gjs-0.3/gjs/.libs -L/usr/lib/firefox ./.libs/libgjs.so -L/usr/lib/mps -lgmodule-2.0 -lgobject-2.0 -lglib-2.0 -lmozjs -lplds4 -lplc4 -lnspr4 -lpthread -ldl -lposix4 -lc -z defs Undefined first referenced symbol in file js_GetVariableStackUses ./.libs/libgjs.so js_GetEnterBlockStackDefs ./.libs/libgjs.so In jsopcode.h, we have 356 static JS_INLINE uintN 357 js_GetStackUses(const JSCodeSpec *cs, JSOp op, jsbytecode *pc) 358 { 359 JS_ASSERT(cs == &js_CodeSpec[op]); 360 if (cs->nuses >= 0) 361 return cs->nuses; 362 return js_GetVariableStackUses(op, pc); 363 } 364 365 static JS_INLINE uintN 366 js_GetStackDefs(JSContext *cx, const JSCodeSpec *cs, JSOp op, JSScript *script, 367 jsbytecode *pc) 368 { 369 JS_ASSERT(cs == &js_CodeSpec[op]); 370 if (cs->ndefs >= 0) 371 return cs->ndefs; 372 373 /* Only JSOP_ENTERBLOCK has a variable number of stack defs. */ 374 JS_ASSERT(op == JSOP_ENTERBLOCK); 375 return js_GetEnterBlockStackDefs(cx, script, pc); 376 } But js_GetVariableStackUses and js_GetEnterBlockStackDefs are not export API. Therefore we have the link problem.
Keywords: regression
Attached patch patch (obsolete) — Splinter Review
I don't think inlining these particular functions is worth the trouble. Can you please verify that this patch fixes your linker problem?
Assignee: general → gal
Attachment #377118 - Flags: review?(brendan)
Severity: major → normal
Flags: wanted1.9.1?
Priority: -- → P2
Target Milestone: --- → mozilla1.9.1
Attachment #377118 - Flags: review?(brendan) → review?(igor)
Comment on attachment 377118 [details] [diff] [review] patch Deferring to Igor, the inline may be worth it for some kind of perf. But I suspect you are wallpapering over a "JS_INLINE is misdefined on Solaris" bug. :-/ /be
(In reply to comment #1) > I don't think inlining these particular functions is worth the trouble. The js_GetStackDefs has debug-only parameter that would be completely eliminated in a non-debug build. When the function is not inlined it would add an extra bloat. (In reply to comment #2) > (From update of attachment 377118 [details] [diff] [review]) > But I suspect you are wallpapering over a "JS_INLINE is misdefined on Solaris" > bug. :-/ There are two possibility. Either some code inside libgjs calls js_GetStackUses or js_GetStackDefs. In this case the embedding in question does need FRIEND on js_GetVariableStackUses and js_GetEnterBlockStackDefs. Or the embedding does not call the functions from libgjs. That means a compiler bug where it put unused static inline function in the object file and the linker tried to resolve it. In this case we need to consider how to work-around this. To Ginn Chen: could you tell which possibility happens in your case? If it is the second one and the issue is a compiler, what happen if you replace static JS_INLINE to just inline or "extern inline" on these two functions?
Comment on attachment 377118 [details] [diff] [review] patch I clear the review request pending the input about the real nature of the bug.
Attachment #377118 - Flags: review?(igor)
Brian Cameron told me there's no call of js_GetStackUses, js_GetStackDefs in libgjs. I'm not sure if it is a bug of the compiler. I wrote an almost empty C program, it just includes jsopcode.h. If I compile it with -xO0 to -xO5, it is fine. If I compile it without -xO[0-5], or with -g, it fails to link. Using "extern inline" or "inline" doesn't fix it. inline has different meanings with C89/C99 or different compilers. See: http://blogs.sun.com/dew/entry/c99_inline_function I think we should not rely on it.
I think it is important to fix ths bug. Since the problem happens when simply including the header file, that is a pretty serious problem, I think. I have a suspicion that just moving the two offending functions from the header file to the c-file would likely hide them so the compiler and linker don't get confused. Ginn, could you try this, or perhaps work with the Sun Studio compiler team and ask them the best way to fix this? If you don't have a contact person, I would recommend pinging Alexey.Shubin@sun.com, who works on the compiler and has been helpful in addressing other desktop compiler issues. Thanks.
Please test this and confirm it fixes the problem. /be
Assignee: gal → brendan
Attachment #377118 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #381328 - Flags: review?(ginn.chen)
Ginn, could you carry this to completion? If it fixes the compilation problem, r=me on the patch (you can mark it yourself). Thanks, /be
Assignee: brendan → ginn.chen
Attachment #381328 - Flags: review?(ginn.chen) → review+
Comment on attachment 381328 [details] [diff] [review] #ifdef __cplusplus yes, it works. r=brendan
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Attachment #381328 - Flags: approval1.9.1?
Brendan, It seems we have some similar problems with jsinterp.h now. js_PurgeScopeChainHelper, js_GetVariableStackUses, js_GetEnterBlockStackDefs, JS_GetTrapOpcode, js_ComputeThis are local linkage in libmozjs.so. So a C program includes <jsinterp.h> can't be linked with ld option "-z defs" which is default. Do you think we should use "#ifdef __cplusplus" for all these function declarations?
oops, JS_GetTrapOpcode is obviously global. And js_GetVariableStackUses, js_GetEnterBlockStackDefs were fixed by the earlier patch. So we still have problems with js_PurgeScopeChainHelper js_ComputeThis
Attachment #381328 - Flags: approval1.9.1? → approval1.9.1.2+
Comment on attachment 381328 [details] [diff] [review] #ifdef __cplusplus a1912=beltzner
Attachment #389911 - Flags: review?(brendan) → review+
Part 2 committed to mozilla-central http://hg.mozilla.org/mozilla-central/rev/9efce50d28ca
Attachment #390191 - Flags: approval1.9.1.2?
Comment on attachment 390191 [details] [diff] [review] combined patch for 1.9.1 branch a1912=beltzner
Attachment #390191 - Flags: approval1.9.1.2? → approval1.9.1.2+
What is the best/simplest way for QA to verify this bug for Firefox 3.5.2?
I think you can only verify it from source code or source code in SDK tarball.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: