Closed Bug 930584 Opened 6 years ago Closed 6 years ago

ASan: duplicate symbol ___sputc when building on OSX Mavericks

Categories

(Firefox Build System :: General, defect, critical)

x86_64
macOS
defect
Not set
critical

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: posidron, Unassigned)

References

(Blocks 1 open bug)

Details

LLVM: r193290
Platform: OSX 10.9 13A603

[...]
nsinstall_real
Executing: ../../../../llvm/build/Release+Asserts/bin/clang -fgnu89-inline -o nsinstall_real -fsanitize=address -Dxmalloc=myxmalloc -fPIC -DXP_UNIX -DXP_MACOSX -DNO_X11 -MD -MP -MF .deps/nsinstall_real.pp -O1 -DUNICODE -D_UNICODE -fsanitize=address 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)
make[5]: *** [nsinstall_real] Error 1
make[4]: *** [config/export] Error 2
make[3]: *** [export] Error 2
make[2]: *** [default] Error 2
make[1]: *** [realbuild] Error 2
make: *** [build] Error 2 

It looks very similar to bug 917526 and if I use Apple's provided clang then the error does not occur.

Do we have suggested rev which works on OSX Mavericks or any other workarounds?
See Also: → 917526
What clang are you using?  What version, and where did it come from?

From what you say one workaround is to use Apple's clang (which so far is the only one I've been testing with).  Another might be to use the 10.8 SDK, or anything besides the 10.9 SDK.
(In reply to Steven Michaud from comment #1)
> and where did it come from?

clang version 3.4 (trunk 193290), from the official upstream repository. I was normally using r191367 on OSX 10.8 but it failed with the same error after the upgrade to 10.9. So I decided to update to tip which was yesterday r193290.

Using a SDK other than 10.9 in the .mozconfig didn't work for me - got the same error with:

ac_add_options --with-macos-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk 

and

ac_add_options --with-macos-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk 


Using Apple's provided clang "Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)" helps for this problem but fails at a different place. (without ASan)

Using Apple's provided clang with ASan fails here:


configure:3203: checking whether the C compiler (/usr/bin/clang -fgnu89-inline -fsanitize=address -Dxmalloc=myxmalloc -fPIC -fsanitize=address) works
configure:3219: /usr/bin/clang -fgnu89-inline -o conftest -fsanitize=address -Dxmalloc=myxmalloc -fPIC  -fsanitize=address conftest.c  1>&5
clang: error: '-fsanitize-undefined-trap-on-error' required with '-fsanitize=address' option
clang: error: unsupported argument 'address' to option 'fsanitize='
clang: error: '-fsanitize-undefined-trap-on-error' required with '-fsanitize=address' option
clang: error: unsupported argument 'address' to option 'fsanitize='
clang: error: '-fsanitize-undefined-trap-on-error' required with '-fsanitize=address' option
clang: error: unsupported argument 'address' to option 'fsanitize='
clang: error: '-fsanitize-undefined-trap-on-error' required with '-fsanitize=address' option
clang: error: unsupported argument 'address' to option 'fsanitize='
clang: error: '-fsanitize-undefined-trap-on-error' required with '-fsanitize=address' option
clang: error: unsupported argument 'address' to option 'fsanitize='
clang: error: '-fsanitize-undefined-trap-on-error' required with '-fsanitize=address' option
clang: error: unsupported argument 'address' to option 'fsanitize='
configure: failed program was:

#line 3214 "configure"
#include "confdefs.h"

main(){return(0);}
configure: error: installation or configuration problem: C compiler cannot create executables.
Please note that LLVM SVN tip fails to compile m-c since Oct 20. http://jenkins.gregoryszorc.com:9000/job/mozilla-central-linux-x64-optimized-llvm-tip/ due to at least bug 928808. r193034 is the last known good LLVM revision against m-c tip.

OS X 10.9 SDK fails to build b/c of bug 929686.

Using the Xcode 5 clang and the OS X 10.8 SDK yields a working non-ASAN build, at least.
As far as I know, you've needed clang 4.2 or higher to build the tree for about two months.  See bug 904108.

It may be, though, that this was only true if you were using *Apple's* clang.  But the situation seems to have changed once again.

Please test with the latest "official" (non-Apple) version of clang, to see if this bug still happens with it.
Real naive question:  How do you do an ASAN build (on trunk)?
> This answers my question.

Actually it doesn't, really.

Would it be fair to say I can use Apple's clang to get an ASan build by adding the following to a "standard" mozconfig?

export CC="/usr/bin/clang"
export CXX="/usr/bin/clang++"
ac_add_options --enable-address-sanitizer
export LDFLAGS="-fsanitize=address"
export HOST_CFLAGS=" "
export HOST_CXXFLAGS=" "
export HOST_LDFLAGS=" "
ac_add_options --disable-jemalloc
ac_add_options --disable-crashreporter
ac_add_options --disable-elf-hack
export MOZ_DEBUG_SYMBOLS=1
ac_add_options --enable-debug-symbols
ac_add_options --disable-install-strip

I'll try this and see what happens.  But I'd like to know whether, even it works, I'll get an ASan build.
If I remember correctly, ekr is/was using the Apple's clang compiler for his ASan builds.
(Following up comment #7)

I had no problems building with these additions to my mozconfig on OS X 10.7.5 with Apple's clang 4.2 (and the 10.6 SDK).

> clang: error: '-fsanitize-undefined-trap-on-error' required with '-fsanitize=address' option
> clang: error: unsupported argument 'address' to option 'fsanitize='

But I also see these errors building with the same mozconfig on OS X 10.9 with Apple's clang 5.0 (500.2.78) and the 10.8 SDK.  Adding -fsanitize-undefined-trap-on-error doesn't get rid of the "unsupported argument" error.

http://irclog.perlgeek.de/moarvm/2013-10-01/text

This, which is a chat log, hints that the problem is a bug in Apple's clang, and suggests that we just need to wait for an update from Apple.
OK, have found the suspect, "-fgnu89-inline" makes trouble which I had added to $CC. (I must have seen it some time ago and adapted it to my .mozconfig) - do we need it?

The following minimized .mozconfig works on OSX 10.9 with LKGR r193034 for mozilla-inbound.

export LLVM_HOME="$HOME/dev/repos/llvm/"
export CC="$LLVM_HOME/build/Release+Asserts/bin/clang"
export CXX="$LLVM_HOME/build/Release+Asserts/bin/clang++"
export SANFLAG="-fsanitize=address -Dxmalloc=myxmalloc -fPIC"
export CFLAGS=$SANFLAG
export CXXFLAGS=$SANFLAG
export LDFLAGS="-fsanitize=address"

ac_add_options --enable-address-sanitizer
ac_add_options --disable-jemalloc

export MOZ_LLVM_HACKS=1
ac_add_options --enable-optimize="-O1"
ac_add_options --enable-debug
ac_add_options --enable-debug-symbols
> The following minimized .mozconfig works on OSX 10.9 with LKGR r193034 for mozilla-inbound.

Glad to hear it.

Apple's 10.9 clang still doesn't work with ASan builds, but that seems to be Apple's problem -- which in any case probably deserves its own bug.

Shall we mark this bug WORKSFORME?
> "-fgnu89-inline" makes trouble which I had added to $CC. (I must
> have seen it some time ago and adapted it to my .mozconfig) - do we
> need it?

Definitely not.  See my patch for bug 917526.
Well, then let's close it. :-)
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WORKSFORME
> Apple's 10.9 clang still doesn't work with ASan builds, but that
> seems to be Apple's problem -- which in any case probably deserves
> its own bug.

I've opened bug 931176.
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.