Closed Bug 917526 Opened 11 years ago Closed 11 years ago

[10.9] Various duplicate symbols error building tree with the 10.9 SDK

Categories

(Firefox Build System :: General, defect)

x86
macOS
defect
Not set
normal

Tracking

(firefox27 fixed, firefox-esr24 fixed, b2g-v1.2 fixed)

RESOLVED FIXED
mozilla27
Tracking Status
firefox27 --- fixed
firefox-esr24 --- fixed
b2g-v1.2 --- fixed

People

(Reporter: smichaud, Assigned: smichaud)

References

Details

Attachments

(1 file, 3 obsolete files)

I get the following error building current trunk with --disable-optimize and the 10.9 SDK specified in my mozconfig file:

...
nsinstall_real
clang -o nsinstall_real -Qunused-arguments  -Qunused-arguments -Wall -Wpointer-arith -Wdeclaration-after-statement -Werror=return-type -Wtype-limits -Wempty-body -Wsign-compare -Wno-unused -isysroot /Developer/SDKs/MacOSX10.9.sdk -std=gnu99 -fgnu89-inline -fno-common -fno-math-errno -pthread -pipe  -DNDEBUG -DTRIMMED -g -fno-omit-frame-pointer  -DXP_UNIX -DXP_MACOSX -DNO_X11  -DUNICODE -D_UNICODE -lobjc  -framework ExceptionHandling -Wl,-executable_path,../../../dist/bin host_nsinstall.o host_pathsub.o  
duplicate symbol ___sputc in:
    host_nsinstall.o
    host_pathsub.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
...
This happens building in the js/src/config directory.
This may be a clang bug, but it involves subtleties about the behavior of the "inline" keyword (compiling with and without -fgnu89-inline) that are far beyond my knowledge.

__sputc() is defined as follows in the stdio.h that comes with Apple's current developer preview (DP8) of OS X 10.9:

__header_always_inline int __sputc(int _c, FILE *_p) {
        if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
                return (*_p->_p++ = _c);
        else
                return (__swbuf(_c, _p));
}

"__header_always_inline" ends up (I think) getting defined as follows in sys/cdefs.h:

inline __attribute__ ((__always_inline__))

This works just fine if we get rid of -fgnu89-inline here:

http://hg.mozilla.org/mozilla-central/annotate/e8bb95435a54/js/src/configure.in#l1064

But I doubt that's feasible in the general case.  And it's puzzling that "inline __attribute__ ((__always_inline__))" would fail to work properly (to force inlining in all cases) when we compile with -fgnu89-inline.

Ted, Jeff:  Any idea what's going on?
Flags: needinfo?(ted)
Flags: needinfo?(jwalden+bmo)
(In reply to Steven Michaud from comment #2)
> This works just fine if we get rid of -fgnu89-inline here:
> 
> http://hg.mozilla.org/mozilla-central/annotate/e8bb95435a54/js/src/configure.
> in#l1064
> 
> But I doubt that's feasible in the general case.

Actually glandium claimed recently that it would be feasible, now that we've updated some tinderboxen, to drop that.  (And in the main configure.in.)  Maybe tryserver that change and see?
Flags: needinfo?(jwalden+bmo)
Here's the output of "clang --version" on my system:

Apple LLVM version 5.0 (clang-500.1.74) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
> Maybe tryserver that change and see?

Will do.
Sorry, I don't have a clue here.
Flags: needinfo?(ted)
> https://tbpl.mozilla.org/?tree=Try&rev=adeb8c7d19d6

There were no build failures, and no non-spurious failures of any kind.  So it might be worthwhile getting rid of -fgnu89-inline on the trunk, at least temporarily, to see what happens.
Attached patch Possible workaround (obsolete) — Splinter Review
Here's the patch I tested (successfully) on the tryservers.
Attached patch Possible workaround rev1 (obsolete) — Splinter Review
Changed the comments to match the code changes.
Attachment #807284 - Attachment is obsolete: true
Comment on attachment 807290 [details] [diff] [review]
Possible workaround rev1

Glandium, what do you think of this?

If you think it also needs other reviewers, please add them.
Attachment #807290 - Flags: review?(mh+mozilla)
Comment on attachment 807290 [details] [diff] [review]
Possible workaround rev1

This patch also works around many more (different) duplicate symbol errors when --disable-optimize is not specified.
Comment on attachment 807290 [details] [diff] [review]
Possible workaround rev1

Review of attachment 807290 [details] [diff] [review]:
-----------------------------------------------------------------

::: configure.in
@@ +1233,5 @@
>  dnl GNU specific defaults
>  dnl ========================================================
>  if test "$GNU_CC"; then
> +    # Use C99 plus GNU extensions.  See bug 719659.
> +    CFLAGS="$CFLAGS -std=gnu99"

I'd rather keep -fgnu89-inline on non-osx systems.
Attachment #807290 - Flags: review?(mh+mozilla) → review-
Summary: [10.9] Duplicate symbol error building tree with --disable-optimize and the 10.9 SDK → [10.9] Various duplicate symbols error building tree with the 10.9 SDK
> I'd rather keep -fgnu89-inline on non-osx systems.

OK.  New patch coming up.
Attached patch Possible workaround rev2 (obsolete) — Splinter Review
How's this?
Assignee: nobody → smichaud
Attachment #807290 - Attachment is obsolete: true
Attachment #808042 - Flags: review?(mh+mozilla)
Comment on attachment 808042 [details] [diff] [review]
Possible workaround rev2

Review of attachment 808042 [details] [diff] [review]:
-----------------------------------------------------------------

::: configure.in
@@ +1240,5 @@
> +    if test "${OS_ARCH}" = Darwin; then
> +        CFLAGS="$CFLAGS -std=gnu99"
> +    else
> +        CFLAGS="$CFLAGS -std=gnu99 -fgnu89-inline"
> +    fi

CFLAGS="$CFLAGS -std=gnu99"
if test "${OS_ARCH}" != Darwin; then
    CFLAGS="$CFLAGS -fgnu89-inline"
fi
Attachment #808042 - Flags: review?(mh+mozilla) → review+
Carrying forward glandium's r+.
Attachment #808042 - Attachment is obsolete: true
Attachment #808090 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/5e4d9cc03f15
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
See Also: → 930584
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: