Closed Bug 1409713 Opened 3 years ago Closed 2 years ago

[clang] js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:92: undefined reference to `__atomic_load_8'

Categories

(Core :: JavaScript Engine: JIT, defect, P3)

x86
FreeBSD
defect

Tracking

()

RESOLVED FIXED
mozilla66
Tracking Status
firefox-esr52 --- unaffected
firefox-esr60 --- wontfix
firefox56 --- unaffected
firefox57 --- wontfix
firefox58 --- wontfix
firefox59 --- wontfix
firefox65 --- wontfix
firefox66 --- fixed

People

(Reporter: jbeich, Assigned: lth, NeedInfo)

References

Details

(Keywords: regression)

$ c++ -v
FreeBSD clang version 5.0.0 (tags/RELEASE_500/final 312559) (based on LLVM 5.0.0svn)
Target: i386-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin

$ pkg install autoconf213 gmake python27 binutils mercurial
$ hg clone https://hg.mozilla.org/mozilla-central
$ cd mozilla-central/js/src
$ autoconf-2.13
$ ./configure --disable-jemalloc
$ gmake
[...]
Executing: /usr/bin/c++ -std=gnu++11 -o jsapi-tests -Qunused-arguments -Qunused-arguments -Wall -Wc++11-compat -Wempty-body -Wignored-qualifiers -Woverloaded-virtual -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wunreachable-code-return -Wwrite-strings -Wno-invalid-offsetof -Wclass-varargs -Wloop-analysis -Wc++11-compat-pedantic -Wc++14-compat -Wc++14-compat-pedantic -Wc++1z-compat -Wcomma -Wimplicit-fallthrough -Wstring-conversion -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wformat -Wno-gnu-zero-variadic-macro-arguments -Wformat-security -Wno-noexcept-type -Wno-unknown-warning-option -Wno-return-type-c-linkage -fno-rtti -fno-exceptions -fno-math-errno -pipe -g -O -fno-omit-frame-pointer /tmp/mozilla-central/js/src/js/src/jsapi-tests/tmplew8S5.list -pthread -Wl,-z,noexecstack -Wl,-z,text -Wl,-z,relro -Wl,-rpath-link,/tmp/mozilla-central/js/src/dist/bin -Wl,-rpath-link,/usr/local/lib ../build/libjs_static.a -lm -lz -lm -pthread
/tmp/mozilla-central/js/src/js/src/jsapi-tests/tmplew8S5.list:
    INPUT("hidePointer.o")
    INPUT("testAssemblerBuffer.o")
    INPUT("Unified_cpp_js_src_jsapi-tests0.o")
    INPUT("Unified_cpp_js_src_jsapi-tests1.o")
    INPUT("Unified_cpp_js_src_jsapi-tests2.o")
    INPUT("Unified_cpp_js_src_jsapi-tests3.o")
    INPUT("Unified_cpp_js_src_jsapi-tests4.o")
    INPUT("Unified_cpp_js_src_jsapi-tests5.o")
    INPUT("Unified_cpp_js_src_jsapi-tests6.o")
    INPUT("../../../memory/build/Unified_cpp_memory_build0.o")
    INPUT("../../../memory/mozalloc/mozalloc_abort.o")
    INPUT("../../../memory/mozalloc/Unified_cpp_memory_mozalloc0.o")
    INPUT("../../../mozglue/misc/AutoProfilerLabel.o")
    INPUT("../../../mozglue/misc/ConditionVariable_posix.o")
    INPUT("../../../mozglue/misc/Mutex_posix.o")
    INPUT("../../../mozglue/misc/Printf.o")
    INPUT("../../../mozglue/misc/StackWalk.o")
    INPUT("../../../mozglue/misc/TimeStamp.o")
    INPUT("../../../mozglue/misc/TimeStamp_posix.o")
    INPUT("../../../mfbt/Compression.o")
    INPUT("../../../mfbt/Decimal.o")
    INPUT("../../../mfbt/Unified_cpp_mfbt0.o")
    INPUT("../../../mfbt/Unified_cpp_mfbt1.o")

Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::loadSeqCst<unsigned long long>(unsigned long long*)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:92: undefined reference to `__atomic_load_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `void js::jit::AtomicOperations::storeSeqCst<unsigned long long>(unsigned long long*, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:101: undefined reference to `__atomic_store_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::exchangeSeqCst<unsigned long long>(unsigned long long*, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:110: undefined reference to `__atomic_exchange_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::compareExchangeSeqCst<unsigned long long>(unsigned long long*, unsigned long long, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:119: undefined reference to `__atomic_compare_exchange_8'
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:119: undefined reference to `__atomic_compare_exchange_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::fetchAddSeqCst<unsigned long long>(unsigned long long*, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:128: undefined reference to `__atomic_fetch_add_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::fetchSubSeqCst<unsigned long long>(unsigned long long*, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:136: undefined reference to `__atomic_fetch_sub_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::fetchAndSeqCst<unsigned long long>(unsigned long long*, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:144: undefined reference to `__atomic_fetch_and_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::fetchOrSeqCst<unsigned long long>(unsigned long long*, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:152: undefined reference to `__atomic_fetch_or_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `unsigned long long js::jit::AtomicOperations::fetchXorSeqCst<unsigned long long>(unsigned long long*, unsigned long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:160: undefined reference to `__atomic_fetch_xor_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::loadSeqCst<long long>(long long*)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:92: undefined reference to `__atomic_load_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `void js::jit::AtomicOperations::storeSeqCst<long long>(long long*, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:101: undefined reference to `__atomic_store_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::exchangeSeqCst<long long>(long long*, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:110: undefined reference to `__atomic_exchange_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::compareExchangeSeqCst<long long>(long long*, long long, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:119: undefined reference to `__atomic_compare_exchange_8'
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:119: undefined reference to `__atomic_compare_exchange_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::fetchAddSeqCst<long long>(long long*, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:128: undefined reference to `__atomic_fetch_add_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::fetchSubSeqCst<long long>(long long*, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:136: undefined reference to `__atomic_fetch_sub_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::fetchAndSeqCst<long long>(long long*, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:144: undefined reference to `__atomic_fetch_and_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::fetchOrSeqCst<long long>(long long*, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:152: undefined reference to `__atomic_fetch_or_8'
Unified_cpp_js_src_jsapi-tests0.o: In function `long long js::jit::AtomicOperations::fetchXorSeqCst<long long>(long long*, long long)':
/tmp/mozilla-central/js/src/jit/x86-shared/AtomicOperations-x86-shared-gcc.h:160: undefined reference to `__atomic_fetch_xor_8'
c++: error: linker command failed with exit code 1 (use -v to see invocation)

Regressed by https://hg.mozilla.org/mozilla-central/rev/284002382c21
Similar to https://lists.freedesktop.org/archives/mesa-dev/2017-May/155575.html
Doesn't affect GCC 6.4.0.
Landry, do you have libatomic after OpenBSD switched to Clang? Otherwise, I'm confused why your buildbot doesn't hit the issue on i386.
Flags: needinfo?(landry)
Clang 3.9 has these functions, or one can link with -latomic.
I have no idea if we have libatomic, dont think so.
Flags: needinfo?(landry)
Dimitry, can you suggests how to force Clang use builtins rather than emit calls to libatomic? -march=i586 doesn't help.
Flags: needinfo?(dimitry)
(In reply to Lars T Hansen [:lth] from comment #2)
> Clang 3.9 has these functions, or one can link with -latomic.

Would it work on 32bit Clang-based systems that don't have GCC installed? -latomic is part of GCC.
(In reply to Jan Beich from comment #5)
> (In reply to Lars T Hansen [:lth] from comment #2)
> > Clang 3.9 has these functions, or one can link with -latomic.
> 
> Would it work on 32bit Clang-based systems that don't have GCC installed?
> -latomic is part of GCC.

Probably not, then.
What version of Clang are you guys using?  It may not matter, but I'm curious.  I've seen Clang 3.9 have this intrinsic but it could be a specially built version, as I think I have seen Clang 4.0 *not* have this intrinsic as well.  Confusion reigns.

This problem will for sure go away when the primitives for x86 are re-implemented properly (bug 1394420) but you probably want something working before then, because that might not be until next year.

A possible stopgap is that it is possible to make the 8-byte functions crash, for now.  The reason is that the 8-byte functions are only used for 8-byte atomics in WebAssembly, and even if that code is about to land in Firefox it'll be 2018H1 before support starts appearing in shipping browsers and content starts appearing on the web.  We'd need to disable 8-byte wasm atomic tests on systems affected by that workaround but that seems doable.
Priority: -- → P3
(In reply to Lars T Hansen [:lth] from comment #7)
> What version of Clang are you guys using?

- FreeBSD 10.* has Clang 3.4.1
- FreeBSD 11.0 has Clang 3.8.0 (will be EOL after 2017-10-26)
- FreeBSD 11.1 has Clang 4.0.0
- FreeBSD 11.2 (in development) currently has Clang 5.0.0
- FreeBSD 12.0 (in development) currently has Clang 5.0.0

Various versions of GCC are provided in packages with the caveat one has to force libc++ to avoid crashes, see
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221288#c4
https://github.com/freebsd/freebsd-ports/blob/f6f9562ed883/Mk/Uses/compiler.mk#L241

> I've seen Clang 3.9 have this intrinsic but it could be a
> specially built version, as I think I have seen Clang 4.0 *not* have this
> intrinsic as well.

I've tried Clang 3.9.1 from llvm39 package but the build still fails like in comment 0. --disable-tests seems to be a workaround and is already used downstream FreeBSD by default.

Looking at http://searchfox.org/mozilla-central/rev/d0448c970093/build/autoconf/toolchain.m4#101
it only pulls -latomic if the platform needs it for C++11 std::atomic.
Priority: -- → P3
Assignee: nobody → lhansen
(In reply to Jan Beich from comment #8)

> --disable-tests seems to be a workaround and is already used downstream FreeBSD by default.

That sounds right for FF57; code that uses the primitive more extensively has not landed yet but is slated for FF58.
Depends on: 1394420

This problem should go away, now that bug 1394420 has landed.

Presumed fixed, please reopen if that turns out to be false.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.