Skip to content

Instantly share code, notes, and snippets.

@tonosaman
Last active November 12, 2016 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonosaman/b3247719709d655028a4ff6527886807 to your computer and use it in GitHub Desktop.
Save tonosaman/b3247719709d655028a4ff6527886807 to your computer and use it in GitHub Desktop.
NetBSD7.0でLLVM-3.9 をビルドしたい人の備忘録(3)

NetBSD7.0でLLVM-3.9 をビルドしたい人の備忘録(3): _LIBCPP_HAS_ATOMIC_BUILTINS

ビルドした Clang for AArch64 target の atomicity を確認

LLVM Atomic Instructions and Concurrency Guide

/vagrant/freebsd/lib/libc++/../../contrib/libc++/src/include/atomic_support.h にて targetがアトミック性をサポートしているならば_LIBCPP_HAS_ATOMIC_BUILTINS が有効になる。

#if defined(__clang__) && __has_builtin(__atomic_load_n)             \
                       && __has_builtin(__atomic_store_n)            \
                       && __has_builtin(__atomic_add_fetch)          \
                       && __has_builtin(__atomic_compare_exchange_n) \
                       && defined(__ATOMIC_RELAXED)                  \
                       && defined(__ATOMIC_CONSUME)                  \
                       && defined(__ATOMIC_ACQUIRE)                  \
                       && defined(__ATOMIC_RELEASE)                  \
                       && defined(__ATOMIC_ACQ_REL)                  \
                       && defined(__ATOMIC_SEQ_CST)
#   define _LIBCPP_HAS_ATOMIC_BUILTINS
#endif

#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS)
    static_assert(false, "_LIBCPP_HAS_ATOMIC_BUILTINS not defined");
#endif
$ /vagrant/build/bin/clang++ -std=c++1z --target=aarch64 test-LIBCPP_HAS_ATOMIC_BUILTINS.cxx -S -o /dev/null

passed!

log

  • 備忘録(1) BSD系カーネルは動的リンク時の$ORIGIN未対応

  • 備忘録(2) 1GBだとメモリ足りなくてOOMキラーにわからん殺しされるので4GBにした話

@tonosaman
Copy link
Author

  • _LIBCPP_BEGIN_NAMESPACE_STDの実態はnamespace std {inline namespace __1 {
  • inline namespace __1 は透過的にアクセス可能なnamespaceでバージョニングのために設けられている。
$ /vagrant/build/bin/clang++ -c -std=c++1z --target=aarch64 ~/test-_LIBCPP_BEGIN_NAMESPACE_STD.cxx -E -I /vagrant/freebsd/contrib/libc++/include/
# 1 "/home/vagrant/test-_LIBCPP_BEGIN_NAMESPACE_STD.cxx"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 356 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "/home/vagrant/test-_LIBCPP_BEGIN_NAMESPACE_STD.cxx" 2
# 1 "/vagrant/freebsd/contrib/libc++/include/__config" 1
# 20 "/vagrant/freebsd/contrib/libc++/include/__config" 3
# 427 "/vagrant/freebsd/contrib/libc++/include/__config" 3
namespace std {
  inline namespace __1 {
  }
}
# 2 "/home/vagrant/test-_LIBCPP_BEGIN_NAMESPACE_STD.cxx" 2

namespace std {inline namespace __1 {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment