Closed Bug 1404839 Opened 7 years ago Closed 7 years ago

TSAN build: requires dynamic R_X86_64_PC32 reloc against 'AnnotateRWLockCreate'

Categories

(Firefox Build System :: General, defect)

All
Linux
defect
Not set
normal

Tracking

(firefox58 fixed)

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

Details

Attachments

(1 file)

I did this by following MDN to build a local build for TSAN
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Thread_Sanitizer
and my desktop is Ubuntu 17.10, (also tried this on my laptop Ubuntu 17.04, and have the same result)

My mozconfig:
mk_add_options MOZ_MAKE_FLAGS="-s -j8"

export CC="clang"
export CXX="clang++"

ac_add_options --enable-thread-sanitizer
ac_add_options --disable-sandbox

export LLVM_SYMBOLIZER=/usr/bin/llvm-symbolizer-4.0
export CFLAGS="-fsanitize=thread -fPIC -pie"
export CXXFLAGS="-fsanitize=thread -fPIC -pie"
export LDFLAGS="-fsanitize=thread -fPIC -pie"

# These three are required by TSan
ac_add_options --disable-jemalloc
ac_add_options --disable-crashreporter
ac_add_options --disable-elf-hack
ac_add_options --enable-pie

export MOZ_DEBUG_SYMBOLS=1
ac_add_options --enable-debug-symbols
ac_add_options --disable-install-strip

ac_add_options --enable-application=browser
ac_add_options --enable-tests


then ./mach build

0:13.04 ../../build/unix/gold/ld: error: /home/allstars/src/tsan/obj-x86_64-pc-linux-gnu/toolkit/library/../../gfx/skia/Unified_cpp_gfx_skia8.o: requires dynamic R_X86_64_PC32 reloc against 'AnnotateRWLockCreate' which may overflow at runtime; recompile with -fPIC
 0:13.04 ../../build/unix/gold/ld: error: read-only segment has dynamic relocations
 0:13.04 /home/allstars/src/tsan/gfx/skia/skia/src/core/SkSharedMutex.cpp:262: error: undefined reference to 'AnnotateRWLockCreate'
 0:13.04 /home/allstars/src/tsan/gfx/skia/skia/src/core/SkSharedMutex.cpp:263: error: undefined reference to 'AnnotateRWLockDestroy'
 0:13.04 /home/allstars/src/tsan/gfx/skia/skia/src/core/SkSharedMutex.cpp:274: error: undefined reference to 'AnnotateRWLockAcquired'
 0:13.04 /home/allstars/src/tsan/gfx/skia/skia/src/core/SkSharedMutex.cpp:278: error: undefined reference to 'AnnotateRWLockReleased'
 0:13.04 /home/allstars/src/tsan/gfx/skia/skia/src/core/SkSharedMutex.cpp:335: error: undefined reference to 'AnnotateRWLockAcquired'
 0:13.04 /home/allstars/src/tsan/gfx/skia/skia/src/core/SkSharedMutex.cpp:340: error: undefined reference to 'AnnotateRWLockReleased'
 0:13.04 clang: error: linker command failed with exit code 1 (use -v to see invocation)


clang -v
clang version 4.0.1-5ubuntu1 (tags/RELEASE_401/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/7.2.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
The declarations here:

http://dxr.mozilla.org/mozilla-central/source/gfx/skia/skia/src/core/SkSharedMutex.cpp#49

need a dance like:

#ifdef __GNUC__
#pragma GCC visibility push(default)
#endif

...declarations...

#ifdef __GNUC__
#pragma GCC visibility pop
#endif

Want to try that out?
Flags: needinfo?(allstars.chh)
Yes, it's working.
I'll fix this.

Thanks
Assignee: nobody → allstars.chh
Flags: needinfo?(allstars.chh)
Comment on attachment 8914586 [details] [diff] [review]
Patch

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

I have no problem with this, but Lee is the keeper of All Things Skia, and there maybe be special procedures for patching Skia here that only he knows.
Attachment #8914586 - Flags: review?(nfroyd)
Attachment #8914586 - Flags: review?(lsalzman)
Attachment #8914586 - Flags: review+
Attachment #8914586 - Flags: review?(lsalzman) → review+
Pushed by yhuang@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/5de17d3c1004
fix linking error for TSAN build. r=froydnj, lsalzman
https://hg.mozilla.org/mozilla-central/rev/5de17d3c1004
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
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: