Bug 234976 - Clang: undefined reference to __atomic_exchange and __atomic_load
Summary: Clang: undefined reference to __atomic_exchange and __atomic_load
Status: Closed DUPLICATE of bug 230888
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-toolchain (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-15 14:57 UTC by Matthias Vallentin
Modified: 2019-03-09 15:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Vallentin 2019-01-15 14:57:51 UTC
I'm having trouble with compiling the following code snippet:

#include <atomic>
#include <cstdint>

struct sixteen {
  uint64_t x = 1;
  int64_t  y = -1;
};

std::atomic<sixteen> x;

int main() {
  auto v = x.load(std::memory_order_relaxed);
  return std::atomic_is_lock_free(&x);
}

I've attempted to compile this as follows:

c++ -std=c++17 -stdlib=libc++ test.cpp
/tmp/test-3fe722.o: In function `main':
test.cpp:(.text+0x34): undefined reference to `__atomic_load'
test.cpp:(.text+0x86): undefined reference to `__atomic_is_lock_free'
c++: error: linker command failed with exit code 1 (use -v to see invocation)

The same snippet compiles fine with GCC 8 and -latomic.

This issue appears to be related to bug #233725 and bug #220822.
Comment 1 Dimitry Andric freebsd_committer freebsd_triage 2019-03-09 15:15:17 UTC

*** This bug has been marked as a duplicate of bug 230888 ***