Closed Bug 854212 Opened 11 years ago Closed 11 years ago

Build error with jsfuninlines.h:194: undefined reference to `JSFunction::ExtendedFinalizeKind' / jsfuninlines.h:194: undefined reference to `JSFunction::FinalizeKind'

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dholbert, Assigned: n.nethercote)

References

Details

Attachments

(1 file)

This morning, my local mozilla-central debug build fails to compile, with this error:
 1:04.77 
 1:04.77 ../libjs_static.a(jsinterp.o): In function `js::CloneFunctionObjectIfNotSingleton(JSContext*, JS::Handle<JSFunction*>, JS::Handle<JSObject*>)':
 1:04.77 /mozilla/js/src/jsfuninlines.h:194: undefined reference to `JSFunction::ExtendedFinalizeKind'
 1:04.77 /mozilla/js/src/jsfuninlines.h:194: undefined reference to `JSFunction::FinalizeKind'
 1:04.77 /usr/bin/ld.bfd.real: js: hidden symbol `_ZN10JSFunction12FinalizeKindE' isn't defined
 1:04.77 /usr/bin/ld.bfd.real: final link failed: Bad value
 1:04.77 collect2: error: ld returned 1 exit status
This was a clobber build, on 64-bit Ubuntu Linux with GCC 4.7.2.
hg bisect says the first bad revision is:

changeset:   126040:82ea4e6d7349
user:        Luke Wagner <luke@mozilla.com>
date:        Sat Mar 23 05:31:01 2013 -0700
summary:     Bug 851421 (part 1) - Clone extended function slots.  r=nnethercote.

which makes sense, because that's what added the references to ExtendFinalizeKind/FinalizeKind in jsfuninlines.h (in the last chunk of the cset):
 https://hg.mozilla.org/mozilla-central/rev/82ea4e6d7349#l3.2
Blocks: 851421
I suspect that what I'm hitting is "the opposite link error on linux" that Luke referred to in bug 851421 comment 21. (context: it's the opposite of another linking error that was hit on Try at one point, for these symbols being already defined)
My mozconfig looks like:
{
mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/../obj
ac_add_options --enable-debug --disable-optimize

mk_add_options MOZ_MAKE_FLAGS='-s -j8'
ac_add_options --with-ccache=/usr/bin/ccache

# Don't want installer/updater in my local builds
ac_add_options --disable-installer
ac_add_options --disable-updater

ac_add_options --enable-valgrind
ac_add_options --enable-warnings-as-errors
}
(I'm hitting this in up-to-date mozilla-inbound, too, so it looks like this hasn't been fixed elsewhere yet.)
This build error happens with the --enable-debug flag.

A non-debug build doesn't fail.
static const js::gc::AllocKind FinalizeKind
static const js::gc::AllocKind ExtendedFinalizeKind

are defined in jsfun.h:251

Not sure why they aren't being included in debug build, but are in the default one.
I can reproduce this with gcc-4.7 on my Linux box.  (I normally use clang-3.2.)

This is mostly explained by
http://stackoverflow.com/questions/4891067/weird-undefined-symbols-of-static-constants-inside-a-struct-class.

Basically, if a |static const| class member is used in a non-const expression,
on Linux (GCC, and sometimes clang) you need to also define it outside of the
class.  But on Windows defining it outside the class causes it to be defined
multiple times!  The solution, which this patch does, is to assign the constant
to a temporary variable so it's only used in const expressions.  I hit the same
problem in bug 747831 -- see the comment in
TokenStream::SourceCoords::SourceCoords in js/src/TokenStream.cpp.

I'll take r+ from whoever can first confirm this fix.  Thanks!
Attachment #728783 - Flags: review?(sstangl)
Attachment #728783 - Flags: review?(dholbert)
Assignee: general → n.nethercote
Comment on attachment 728783 [details] [diff] [review]
Fix link errors in jsfuninlines.h caused by bug 851421.

This let's me to build m-c
Attachment #728783 - Flags: review+
Attachment #728783 - Flags: review?(sstangl)
Attachment #728783 - Flags: review?(dholbert)
It works for me as well. Thanks! :)
Have to get m-c working too, so landed there
https://hg.mozilla.org/mozilla-central/rev/631d57b31bb1
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: