On Fri, May 13, 2016 at 09:04:26PM +0100, Stuart Henderson wrote:
> On 2016/05/13 21:49, Patrick Wildt wrote:
> > +BUILD_DEPENDS +=   devel/llvm
> 
> Only thing I noticed in first review was this, please use
> 
> MODULES =             lang/clang
> MODCLANG_LANGS =      c++
> MODCLANG_ARCHS =      amd64
> 
> instead of the BUILD_DEPENDS. Then, in theory, you shouldn't need
> these lines in the various Makefiles:
> 
> > +CC=                clang
> > +CXX=               clang++
> 
> I'll try to do some testing but I'm a bit swamped at the moment.

Thanks!

FWIW, updated diff based on LLVM 3.8:

diff --git devel/libc++/Makefile devel/libc++/Makefile
new file mode 100644
index 0000000..1c16190
--- /dev/null
+++ devel/libc++/Makefile
@@ -0,0 +1,57 @@
+# $OpenBSD$
+
+ONLY_FOR_ARCHS = amd64
+DPB_PROPERTIES = parallel
+
+COMMENT =      new implementation of the C++ standard library
+
+LLVM_V =       3.8.0
+DISTNAME =     libcxx-${LLVM_V}.src
+PKGNAME =      libc++-${LLVM_V}
+CATEGORIES =   devel
+DISTFILES =    libcxx-${LLVM_V}.src${EXTRACT_SUFX} \
+               libcxxabi-${LLVM_V}.src${EXTRACT_SUFX} \
+               libunwind-${LLVM_V}.src${EXTRACT_SUFX}
+MASTER_SITES = http://www.llvm.org/releases/${LLVM_V}/
+EXTRACT_SUFX = .tar.xz
+
+SHARED_LIBS =  c++             1.0 \
+               c++abi          1.0
+
+# packager notes in http://llvm.org/docs/Packaging.html
+HOMEPAGE =     http://www.llvm.org/
+
+MAINTAINER=    Patrick Wildt <patr...@blueri.se>
+
+# BSD
+PERMIT_PACKAGE_CDROM = Yes
+
+WANTLIB =      c
+
+MODULES =              lang/clang
+MODCLANG_LANGS =       c++
+MODCLANG_ARCHS =       amd64
+
+SEPARATE_BUILD =       Yes
+
+WRKDIST = ${WRKDIR}/${DISTNAME}
+MAKE_ENV += LIBCXX=${WRKSRC}
+MAKE_ENV += LIBCXXABI=${WRKSRC}/libcxxabi
+MAKE_ENV += LIBUNWIND=${WRKSRC}/libunwind
+
+post-extract:
+       mv ${WRKDIR}/libcxxabi-${LLVM_V}.src ${WRKSRC}/libcxxabi
+       mv ${WRKDIR}/libunwind-${LLVM_V}.src ${WRKSRC}/libunwind
+       mkdir -p ${WRKBUILD}/libcxx
+       mkdir -p ${WRKBUILD}/libcxxabi
+
+pre-build:
+       @printf "major=${LIBc++_VERSION:R}\nminor=${LIBc++_VERSION:E}\n" \
+           >${WRKBUILD}/libcxx/shlib_version
+       @printf "major=${LIBc++abi_VERSION:R}\nminor=${LIBc++abi_VERSION:E}\n" \
+           >${WRKBUILD}/libcxxabi/shlib_version
+       @cp ${FILESDIR}/Makefile ${WRKBUILD}/Makefile
+       @cp ${FILESDIR}/libcxx-Makefile ${WRKBUILD}/libcxx/Makefile
+       @cp ${FILESDIR}/libcxxabi-Makefile ${WRKBUILD}/libcxxabi/Makefile
+
+.include <bsd.port.mk>
diff --git devel/libc++/distinfo devel/libc++/distinfo
new file mode 100644
index 0000000..e7d0a73
--- /dev/null
+++ devel/libc++/distinfo
@@ -0,0 +1,6 @@
+SHA256 (libcxx-3.8.0.src.tar.xz) = NoBFEblAvIp878fLORprKPXj9T9jcpZWQgINuRF0I3s=
+SHA256 (libcxxabi-3.8.0.src.tar.xz) = 
xe4Ica/27HQTgMSJkAen2X8LeRyB32nSW3RO68XO5QQ=
+SHA256 (libunwind-3.8.0.src.tar.xz) = 
rz6vOezcO56Jhj+2LhqjwTXP3n6UFUJOTjltdIapQis=
+SIZE (libcxx-3.8.0.src.tar.xz) = 1062884
+SIZE (libcxxabi-3.8.0.src.tar.xz) = 508900
+SIZE (libunwind-3.8.0.src.tar.xz) = 60600
diff --git devel/libc++/files/Makefile devel/libc++/files/Makefile
new file mode 100644
index 0000000..32aef54
--- /dev/null
+++ devel/libc++/files/Makefile
@@ -0,0 +1,7 @@
+# $OpenBSD$
+
+.include <bsd.own.mk>
+
+SUBDIR= libcxx libcxxabi
+
+.include <bsd.subdir.mk>
diff --git devel/libc++/files/libcxx-Makefile devel/libc++/files/libcxx-Makefile
new file mode 100644
index 0000000..2e08e38
--- /dev/null
+++ devel/libc++/files/libcxx-Makefile
@@ -0,0 +1,222 @@
+HDRDIR=                ${LIBCXX}/include
+SRCDIR=                ${LIBCXX}/src
+AHDRDIR=       ${LIBCXXABI}/include
+UHDRDIR=       ${LIBUNWIND}/include
+CXXINCLUDEDIR= /usr/local/include/c++/v1
+
+.PATH: ${SRCDIR}
+
+LIB=           c++
+LIBDIR=                /usr/local/lib
+
+SRCS+=         algorithm.cpp\
+               any.cpp\
+               bind.cpp\
+               chrono.cpp\
+               condition_variable.cpp\
+               debug.cpp\
+               exception.cpp\
+               future.cpp\
+               hash.cpp\
+               ios.cpp\
+               iostream.cpp\
+               locale.cpp\
+               memory.cpp\
+               mutex.cpp\
+               new.cpp\
+               random.cpp\
+               regex.cpp\
+               shared_mutex.cpp\
+               stdexcept.cpp\
+               string.cpp\
+               strstream.cpp\
+               system_error.cpp\
+               thread.cpp\
+               typeinfo.cpp\
+               utility.cpp\
+               valarray.cpp
+
+WARNS=         0
+CFLAGS+=       -nostdlib -DLIBCXXABI -I${HDRDIR} -I${SRCDIR}/include \
+               -DLIBCXX_BUILDING_LIBCXXABI -I${AHDRDIR} -I${UHDRDIR}
+CPPFLAGS+=     ${CFLAGS}
+.if empty(CXXFLAGS:M-std=*)
+CXXFLAGS+=     -std=c++11
+.endif
+
+LDFLAGS+=      --verbose
+INCSGROUPS=    STD EXT EXP
+
+STD_HEADERS=   __bit_reference\
+               __config\
+               __debug\
+               __functional_03\
+               __functional_base\
+               __functional_base_03\
+               __hash_table\
+               __locale\
+               __mutex_base\
+               __nullptr\
+               __refstring\
+               __split_buffer\
+               __sso_allocator\
+               __std_stream\
+               __tree\
+               __tuple\
+               __undef___deallocate\
+               __undef_min_max\
+               algorithm\
+               array\
+               atomic\
+               bitset\
+               cassert\
+               ccomplex\
+               cctype\
+               cerrno\
+               cfenv\
+               cfloat\
+               chrono\
+               cinttypes\
+               ciso646\
+               climits\
+               clocale\
+               cmath\
+               codecvt\
+               complex\
+               complex.h\
+               condition_variable\
+               csetjmp\
+               csignal\
+               cstdarg\
+               cstdbool\
+               cstddef\
+               cstdint\
+               cstdio\
+               cstdlib\
+               cstring\
+               ctgmath\
+               ctime\
+               ctype.h\
+               cwchar\
+               cwctype\
+               deque\
+               errno.h\
+               exception\
+               float.h\
+               forward_list\
+               fstream\
+               functional\
+               future\
+               initializer_list\
+               inttypes.h\
+               iomanip\
+               ios\
+               iosfwd\
+               iostream\
+               istream\
+               iterator\
+               limits\
+               list\
+               locale\
+               map\
+               math.h\
+               memory\
+               mutex\
+               new\
+               numeric\
+               ostream\
+               queue\
+               random\
+               ratio\
+               regex\
+               scoped_allocator\
+               set\
+               setjmp.h\
+               shared_mutex\
+               sstream\
+               stack\
+               stddef.h\
+               stdexcept\
+               stdio.h\
+               stdlib.h\
+               streambuf\
+               string\
+               strstream\
+               system_error\
+               tgmath.h\
+               thread\
+               tuple\
+               type_traits\
+               typeindex\
+               typeinfo\
+               unordered_map\
+               unordered_set\
+               utility\
+               valarray\
+               vector\
+               wchar.h\
+               wctype.h
+
+.for hdr in ${STD_HEADERS}
+STD+=          ${hdr} ${HDRDIR}/${hdr}
+.endfor
+STDDIR=                ${CXXINCLUDEDIR}
+
+EXT_HEADERS=   __hash\
+               hash_map\
+               hash_set
+
+.for hdr in ${EXT_HEADERS}
+EXT+=          ${hdr} ${HDRDIR}/ext/${hdr}
+.endfor
+EXTDIR=                ${CXXINCLUDEDIR}/ext
+
+EXP_HEADERS=   __config\
+               algorithm\
+               any\
+               chrono\
+               dynarray\
+               functional\
+               optional\
+               ratio\
+               string_view\
+               system_error\
+               tuple\
+               type_traits\
+               utility
+
+.for hdr in ${EXP_HEADERS}
+EXP+=          ${hdr} ${HDRDIR}/experimental/${hdr}
+.endfor
+EXPDIR=                ${CXXINCLUDEDIR}/experimental
+
+#includes:
+beforeinstall:
+       @echo installing ${STD_HEADERS}
+       ${INSTALL} -d -m 555 ${DESTDIR}/${STDDIR};
+.      for hdr src in ${STD}
+               cmp -s ${src} ${DESTDIR}/${STDDIR}/${hdr} || \
+               ${INSTALL} ${INSTALL_COPY} -m 444 ${src} 
${DESTDIR}/${STDDIR}/${hdr};
+.      endfor
+       ${INSTALL} -d -m 555 ${DESTDIR}/${EXTDIR};
+.      for hdr src in ${EXT}
+               cmp -s ${src} ${DESTDIR}/${EXTDIR}/${hdr} || \
+               ${INSTALL} ${INSTALL_COPY} -m 444 ${src} 
${DESTDIR}/${EXTDIR}/${hdr};
+.      endfor
+       ${INSTALL} -d -m 555 ${DESTDIR}/${EXPDIR};
+.      for hdr src in ${EXP}
+               cmp -s ${src} ${DESTDIR}/${EXPDIR}/${hdr} || \
+               ${INSTALL} ${INSTALL_COPY} -m 444 ${src} 
${DESTDIR}/${EXPDIR}/${hdr};
+.      endfor
+       ${INSTALL} -d -m 555 ${DESTDIR}/${CXXINCLUDEDIR}/support/newlib;
+       cmp -s ${HDRDIR}/support/newlib/xlocale.h \
+           ${DESTDIR}/${CXXINCLUDEDIR}/support/newlib/xlocale.h || \
+           ${INSTALL} ${INSTALL_COPY} -m 444 
${HDRDIR}/support/newlib/xlocale.h \
+           ${DESTDIR}/${CXXINCLUDEDIR}/support/newlib/xlocale.h;
+       ${INSTALL} -d -m 555 ${DESTDIR}/${CXXINCLUDEDIR}/support/xlocale;
+       cmp -s ${HDRDIR}/support/xlocale/xlocale.h \
+           ${DESTDIR}/${CXXINCLUDEDIR}/support/xlocale/xlocale.h || \
+           ${INSTALL} ${INSTALL_COPY} -m 444 
${HDRDIR}/support/xlocale/xlocale.h \
+           ${DESTDIR}/${CXXINCLUDEDIR}/support/xlocale/xlocale.h;
+
+.include <bsd.lib.mk>
diff --git devel/libc++/files/libcxxabi-Makefile 
devel/libc++/files/libcxxabi-Makefile
new file mode 100644
index 0000000..af5b039
--- /dev/null
+++ devel/libc++/files/libcxxabi-Makefile
@@ -0,0 +1,89 @@
+HDRDIR=                ${LIBCXXABI}/include
+SRCDIR=                ${LIBCXXABI}/src
+SHDRDIR=       ${LIBCXX}/include
+UHDRDIR=       ${LIBUNWIND}/include
+CXXINCLUDEDIR= /usr/local/include/c++/v1
+
+.PATH: ${SRCDIR} ${LIBUNWIND}/src
+
+LIB=           c++abi
+LIBDIR=                /usr/local/lib
+
+SRCS+=         abort_message.cpp\
+               cxa_aux_runtime.cpp\
+               cxa_default_handlers.cpp\
+               cxa_demangle.cpp\
+               cxa_exception.cpp\
+               cxa_exception_storage.cpp\
+               cxa_guard.cpp\
+               cxa_handlers.cpp\
+               cxa_new_delete.cpp\
+               cxa_personality.cpp\
+               cxa_thread_atexit.cpp\
+               cxa_unexpected.cpp\
+               cxa_vector.cpp\
+               cxa_virtual.cpp\
+               exception.cpp\
+               private_typeinfo.cpp\
+               stdexcept.cpp\
+               typeinfo.cpp\
+               Unwind-EHABI.cpp\
+               Unwind-sjlj.c\
+               UnwindLevel1-gcc-ext.c\
+               UnwindLevel1.c\
+               UnwindRegistersRestore.S\
+               UnwindRegistersSave.S\
+               libunwind.cpp
+
+WARNS=         0
+CFLAGS+=       -nostdlib -I${SHDRDIR} -funwind-tables -I${HDRDIR} -I${UHDRDIR}
+CPPFLAGS+=     ${CFLAGS}
+.if empty(CXXFLAGS:M-std=*)
+CXXFLAGS+=     -std=c++11
+.endif
+
+STD_HEADERS=   cxxabi.h \
+               __cxxabi_config.h
+
+.for hdr in ${STD_HEADERS}
+STD+=          ${hdr} ${HDRDIR}/${hdr}
+.endfor
+STDDIR=                ${CXXINCLUDEDIR}
+
+# Libunwind stuff
+STD_UHEADERS=  libunwind.h \
+               __libunwind_config.h \
+               unwind.h
+
+.for hdr in ${STD_UHEADERS}
+USTD+=         ${hdr} ${UHDRDIR}/${hdr}
+.endfor
+USTDDIR=       ${CXXINCLUDEDIR}
+
+MACHO_HEADERS=compact_unwind_encoding.h
+
+.for hdr in ${MACHO_HEADERS}
+MACHO+=                ${hdr} ${UHDRDIR}/mach-o/${hdr}
+.endfor
+MACHODIR=      ${CXXINCLUDEDIR}/mach-o
+
+#includes:
+beforeinstall:
+       @echo installing ${STD_HEADERS}
+       ${INSTALL} -d -m 555 ${DESTDIR}/${STDDIR};
+.      for hdr src in ${STD}
+               cmp -s ${src} ${DESTDIR}/${STDDIR}/${hdr} || \
+               ${INSTALL} ${INSTALL_COPY} -m 444 ${src} 
${DESTDIR}/${STDDIR}/${hdr};
+.      endfor
+       ${INSTALL} -d -m 555 ${DESTDIR}/${USTDDIR};
+.      for hdr src in ${USTD}
+               cmp -s ${src} ${DESTDIR}/${USTDDIR}/${hdr} || \
+               ${INSTALL} ${INSTALL_COPY} -m 444 ${src} 
${DESTDIR}/${USTDDIR}/${hdr};
+.      endfor
+       ${INSTALL} -d -m 555 ${DESTDIR}/${MACHODIR};
+.      for hdr src in ${MACHO}
+               cmp -s ${src} ${DESTDIR}/${MACHODIR}/${hdr} || \
+               ${INSTALL} ${INSTALL_COPY} -m 444 ${src} 
${DESTDIR}/${MACHODIR}/${hdr};
+.      endfor
+
+.include <bsd.lib.mk>
diff --git devel/libc++/patches/patch-include___config 
devel/libc++/patches/patch-include___config
new file mode 100644
index 0000000..b36dcc4
--- /dev/null
+++ devel/libc++/patches/patch-include___config
@@ -0,0 +1,31 @@
+$OpenBSD$
+--- include/__config.orig      Tue Jan 12 01:38:04 2016
++++ include/__config   Sun May 15 22:44:57 2016
+@@ -118,6 +118,17 @@
+ # define _LIBCPP_HAS_QUICK_EXIT
+ #endif  // __NetBSD__
+ 
++#ifdef __OpenBSD__
++# include <sys/endian.h>
++#  if _BYTE_ORDER == _LITTLE_ENDIAN
++#   define _LIBCPP_LITTLE_ENDIAN 1
++#   define _LIBCPP_BIG_ENDIAN    0
++# else  // _BYTE_ORDER == _LITTLE_ENDIAN
++#   define _LIBCPP_LITTLE_ENDIAN 0
++#   define _LIBCPP_BIG_ENDIAN    1
++# endif  // _BYTE_ORDER == _LITTLE_ENDIAN
++#endif  // __OpenBSD__
++
+ #ifdef _WIN32
+ #  define _LIBCPP_LITTLE_ENDIAN 1
+ #  define _LIBCPP_BIG_ENDIAN    0
+@@ -810,7 +821,8 @@ extern "C" void __sanitizer_annotate_contiguous_contai
+ #define _LIBCPP_HAS_NO_STDOUT
+ #endif
+ 
+-#if defined(__ANDROID__) || defined(__CloudABI__) || 
defined(_LIBCPP_HAS_MUSL_LIBC)
++#if defined(__ANDROID__) || defined(__CloudABI__) || 
defined(_LIBCPP_HAS_MUSL_LIBC) \
++    || defined(__OpenBSD__)
+ #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+ #endif
+ 
diff --git devel/libc++/patches/patch-include___locale 
devel/libc++/patches/patch-include___locale
new file mode 100644
index 0000000..d4bbdf0
--- /dev/null
+++ devel/libc++/patches/patch-include___locale
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- include/__locale.orig      Wed Mar 11 18:00:28 2015
++++ include/__locale   Fri May 13 15:49:28 2016
+@@ -32,7 +32,7 @@
+ #elif defined(__sun__)
+ # include <xlocale.h>
+ # include <support/solaris/xlocale.h>
+-#elif defined(_NEWLIB_VERSION)
++#elif defined(_NEWLIB_VERSION) || defined(__OpenBSD__)
+ # include <support/newlib/xlocale.h>
+ #elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
+     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
diff --git devel/libc++/patches/patch-include_cstdio 
devel/libc++/patches/patch-include_cstdio
new file mode 100644
index 0000000..bff409d
--- /dev/null
+++ devel/libc++/patches/patch-include_cstdio
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- include/cstdio.orig        Fri Oct  9 03:29:09 2015
++++ include/cstdio     Sun May 15 22:43:54 2016
+@@ -155,7 +155,7 @@ using ::tmpnam;
+ 
+ #ifndef _LIBCPP_HAS_NO_STDIN
+ using ::getchar;
+-#if _LIBCPP_STD_VER <= 11
++#if _LIBCPP_STD_VER <= 11 && !defined(__OpenBSD__)
+ using ::gets;
+ #endif
+ using ::scanf;
diff --git devel/libc++/patches/patch-include_locale 
devel/libc++/patches/patch-include_locale
new file mode 100644
index 0000000..836fe27
--- /dev/null
+++ devel/libc++/patches/patch-include_locale
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- include/locale.orig        Fri May 13 15:55:21 2016
++++ include/locale     Fri May 13 15:57:13 2016
+@@ -236,7 +236,7 @@ typedef _VSTD::unique_ptr<__locale_struct, decltype(&u
+ // locale.  Linux, not so much.  The following functions avoid the locale when
+ // that's possible and otherwise do the wrong thing.  FIXME.
+ #if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) || \
+-    defined(_NEWLIB_VERSION) || defined(__GLIBC__)
++    defined(_NEWLIB_VERSION) || defined(__GLIBC__) || defined(__OpenBSD__)
+ 
+ #ifdef _LIBCPP_LOCALE__L_EXTENSIONS
+ decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>()))
diff --git devel/libc++/patches/patch-include_support_newlib_xlocale_h 
devel/libc++/patches/patch-include_support_newlib_xlocale_h
new file mode 100644
index 0000000..6a28191
--- /dev/null
+++ devel/libc++/patches/patch-include_support_newlib_xlocale_h
@@ -0,0 +1,12 @@
+$OpenBSD$
+--- include/support/newlib/xlocale.h.orig      Fri Sep 19 22:09:12 2014
++++ include/support/newlib/xlocale.h   Fri May 13 15:49:28 2016
+@@ -10,7 +10,7 @@
+ #ifndef _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H
+ #define _LIBCPP_SUPPORT_NEWLIB_XLOCALE_H
+ 
+-#if defined(_NEWLIB_VERSION)
++#if defined(_NEWLIB_VERSION) || defined(__OpenBSD__)
+ 
+ #include <cstdlib>
+ #include <clocale>
diff --git devel/libc++/patches/patch-libunwind_src_AddressSpace_hpp 
devel/libc++/patches/patch-libunwind_src_AddressSpace_hpp
new file mode 100644
index 0000000..b89f03b
--- /dev/null
+++ devel/libc++/patches/patch-libunwind_src_AddressSpace_hpp
@@ -0,0 +1,108 @@
+$OpenBSD$
+--- libunwind/src/AddressSpace.hpp.orig        Fri Oct 16 21:40:09 2015
++++ libunwind/src/AddressSpace.hpp     Sun May 15 22:43:54 2016
+@@ -347,6 +347,85 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t en
+   #endif
+ #endif
+ 
++#if __OpenBSD__
++  #include <link_elf.h>
++  #define PT_EH_FRAME_HDR (PT_LOOS + 0x474e550)
++
++  struct dl_unwind_sections
++  {
++    uintptr_t                    base;
++    const void                  *dwarf_section;
++    uintptr_t                    dwarf_section_length;
++    const void                  *compact_unwind_section;
++    uintptr_t                    compact_unwind_section_length;
++  };
++
++  struct eh_frame_hdr
++  {
++    uint8_t version;
++    uint8_t eh_frame_ptr_enc;
++    uint8_t fde_count_enc;
++    uint8_t table_enc;
++    uint8_t data[0];
++  };
++
++  struct _dl_iterate_struct
++  {
++    Elf_Addr                   addr;
++    Elf_Addr                   base;
++    Elf_Phdr                  *eh_frame_hdr;
++  };
++
++  static int _dl_iterate_cb(struct dl_phdr_info *dlpi, size_t size, void* 
data) {
++    struct _dl_iterate_struct *dlis = (struct _dl_iterate_struct *)data;
++    Elf_Phdr *phdr = (Elf_Phdr *)dlpi->dlpi_phdr;
++    int idx, found = 0;
++
++    for (idx = 0; idx < dlpi->dlpi_phnum; idx++, phdr++) {
++      if (phdr->p_type == PT_LOAD) {
++        Elf_Addr vaddr = dlpi->dlpi_addr + phdr->p_vaddr;
++        if (dlis->addr >= vaddr && dlis->addr < (vaddr + phdr->p_memsz))
++          found = 1;
++      } else if (phdr->p_type == PT_EH_FRAME_HDR)
++        dlis->eh_frame_hdr = phdr;
++    }
++
++    dlis->base = dlpi->dlpi_addr;
++    return found;
++  }
++
++  static inline bool _dl_find_unwind_sections(void *addr,
++      dl_unwind_sections *info) {
++
++    LocalAddressSpace::pint_t encoded, end;
++    struct _dl_iterate_struct dlis;
++    struct eh_frame_hdr *ehfh;
++    Elf_Phdr *phdr;
++    int idx;
++
++    dlis.addr = (Elf_Addr)addr;
++    if (!dl_iterate_phdr(_dl_iterate_cb, &dlis))
++      return false;
++
++    phdr = (Elf_Phdr *)dlis.eh_frame_hdr;
++    ehfh = (struct eh_frame_hdr *)(dlis.base + phdr->p_vaddr);
++
++    encoded = (LocalAddressSpace::pint_t)&ehfh->data;
++    end = (LocalAddressSpace::pint_t)ehfh + phdr->p_memsz;
++
++    // Fill in return struct.
++    info->base = dlis.base;
++    info->dwarf_section = (const void *)LocalAddressSpace::sThisAddressSpace
++        .getEncodedP(encoded, end, ehfh->eh_frame_ptr_enc);
++    /* XXX: We don't know how big it is, shouldn't be bigger than this. */
++    info->dwarf_section_length = 0x00ffffff;
++    info->compact_unwind_section = 0;
++    info->compact_unwind_section_length = 0;
++
++    return true;
++  }
++#endif
++
+ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
+                                                   UnwindInfoSections &info) {
+ #ifdef __APPLE__
+@@ -359,6 +438,18 @@ inline bool LocalAddressSpace::findUnwindSections(pint
+  #endif
+     info.compact_unwind_section        = 
(uintptr_t)dyldInfo.compact_unwind_section;
+     info.compact_unwind_section_length = 
dyldInfo.compact_unwind_section_length;
++    return true;
++  }
++#elif __OpenBSD__
++  dl_unwind_sections dlInfo;
++  if (_dl_find_unwind_sections((void *)targetAddr, &dlInfo)) {
++    info.dso_base                      = (uintptr_t)dlInfo.base;
++ #if _LIBUNWIND_SUPPORT_DWARF_UNWIND
++    info.dwarf_section                 = (uintptr_t)dlInfo.dwarf_section;
++    info.dwarf_section_length          = dlInfo.dwarf_section_length;
++ #endif
++    info.compact_unwind_section        = 
(uintptr_t)dlInfo.compact_unwind_section;
++    info.compact_unwind_section_length = dlInfo.compact_unwind_section_length;
+     return true;
+   }
+ #elif _LIBUNWIND_ARM_EHABI
diff --git devel/libc++/patches/patch-libunwind_src_config_h 
devel/libc++/patches/patch-libunwind_src_config_h
new file mode 100644
index 0000000..cfafc6c
--- /dev/null
+++ devel/libc++/patches/patch-libunwind_src_config_h
@@ -0,0 +1,22 @@
+$OpenBSD$
+--- libunwind/src/config.h.orig        Sat Sep 26 20:26:01 2015
++++ libunwind/src/config.h     Sun May 15 22:43:54 2016
+@@ -61,6 +61,18 @@
+     #define _LIBUNWIND_SUPPORT_DWARF_INDEX    0
+   #endif
+ 
++#elif __OpenBSD__
++  #define _LIBUNWIND_BUILD_ZERO_COST_APIS (__i386__ || __x86_64__ || 
__aarch64__ || __arm__)
++  #define _LIBUNWIND_BUILD_SJLJ_APIS      0
++  #define _LIBUNWIND_SUPPORT_FRAME_APIS   (__i386__ || __x86_64__)
++  #define _LIBUNWIND_EXPORT               
__attribute__((visibility("default")))
++  #define _LIBUNWIND_HIDDEN               
__attribute__((visibility("hidden")))
++  #define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libuwind: " msg, 
__VA_ARGS__)
++  #define _LIBUNWIND_ABORT(msg) __assert2(__FILE__, __LINE__, __func__, msg)
++  #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
++  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
++  #define _LIBUNWIND_SUPPORT_DWARF_INDEX    0
++
+ #else
+   #include <stdlib.h>
+ 
diff --git devel/libc++/pkg/DESCR devel/libc++/pkg/DESCR
new file mode 100644
index 0000000..bfa8bdf
--- /dev/null
+++ devel/libc++/pkg/DESCR
@@ -0,0 +1,2 @@
+libc++ is a new implementation of the C++ standard library,
+targeting C++11.
diff --git devel/libc++/pkg/PLIST devel/libc++/pkg/PLIST
new file mode 100644
index 0000000..a7e5f74
--- /dev/null
+++ devel/libc++/pkg/PLIST
@@ -0,0 +1,148 @@
+@comment $OpenBSD$
+include/c++/
+include/c++/v1/
+include/c++/v1/__bit_reference
+include/c++/v1/__config
+include/c++/v1/__cxxabi_config.h
+include/c++/v1/__debug
+include/c++/v1/__functional_03
+include/c++/v1/__functional_base
+include/c++/v1/__functional_base_03
+include/c++/v1/__hash_table
+include/c++/v1/__libunwind_config.h
+include/c++/v1/__locale
+include/c++/v1/__mutex_base
+include/c++/v1/__nullptr
+include/c++/v1/__refstring
+include/c++/v1/__split_buffer
+include/c++/v1/__sso_allocator
+include/c++/v1/__std_stream
+include/c++/v1/__tree
+include/c++/v1/__tuple
+include/c++/v1/__undef___deallocate
+include/c++/v1/__undef_min_max
+include/c++/v1/algorithm
+include/c++/v1/array
+include/c++/v1/atomic
+include/c++/v1/bitset
+include/c++/v1/cassert
+include/c++/v1/ccomplex
+include/c++/v1/cctype
+include/c++/v1/cerrno
+include/c++/v1/cfenv
+include/c++/v1/cfloat
+include/c++/v1/chrono
+include/c++/v1/cinttypes
+include/c++/v1/ciso646
+include/c++/v1/climits
+include/c++/v1/clocale
+include/c++/v1/cmath
+include/c++/v1/codecvt
+include/c++/v1/complex
+include/c++/v1/complex.h
+include/c++/v1/condition_variable
+include/c++/v1/csetjmp
+include/c++/v1/csignal
+include/c++/v1/cstdarg
+include/c++/v1/cstdbool
+include/c++/v1/cstddef
+include/c++/v1/cstdint
+include/c++/v1/cstdio
+include/c++/v1/cstdlib
+include/c++/v1/cstring
+include/c++/v1/ctgmath
+include/c++/v1/ctime
+include/c++/v1/ctype.h
+include/c++/v1/cwchar
+include/c++/v1/cwctype
+include/c++/v1/cxxabi.h
+include/c++/v1/deque
+include/c++/v1/errno.h
+include/c++/v1/exception
+include/c++/v1/experimental/
+include/c++/v1/experimental/__config
+include/c++/v1/experimental/algorithm
+include/c++/v1/experimental/any
+include/c++/v1/experimental/chrono
+include/c++/v1/experimental/dynarray
+include/c++/v1/experimental/functional
+include/c++/v1/experimental/optional
+include/c++/v1/experimental/ratio
+include/c++/v1/experimental/string_view
+include/c++/v1/experimental/system_error
+include/c++/v1/experimental/tuple
+include/c++/v1/experimental/type_traits
+include/c++/v1/experimental/utility
+include/c++/v1/ext/
+include/c++/v1/ext/__hash
+include/c++/v1/ext/hash_map
+include/c++/v1/ext/hash_set
+include/c++/v1/float.h
+include/c++/v1/forward_list
+include/c++/v1/fstream
+include/c++/v1/functional
+include/c++/v1/future
+include/c++/v1/initializer_list
+include/c++/v1/inttypes.h
+include/c++/v1/iomanip
+include/c++/v1/ios
+include/c++/v1/iosfwd
+include/c++/v1/iostream
+include/c++/v1/istream
+include/c++/v1/iterator
+include/c++/v1/libunwind.h
+include/c++/v1/limits
+include/c++/v1/list
+include/c++/v1/locale
+include/c++/v1/mach-o/
+include/c++/v1/mach-o/compact_unwind_encoding.h
+include/c++/v1/map
+include/c++/v1/math.h
+include/c++/v1/memory
+include/c++/v1/mutex
+include/c++/v1/new
+include/c++/v1/numeric
+include/c++/v1/ostream
+include/c++/v1/queue
+include/c++/v1/random
+include/c++/v1/ratio
+include/c++/v1/regex
+include/c++/v1/scoped_allocator
+include/c++/v1/set
+include/c++/v1/setjmp.h
+include/c++/v1/shared_mutex
+include/c++/v1/sstream
+include/c++/v1/stack
+include/c++/v1/stddef.h
+include/c++/v1/stdexcept
+include/c++/v1/stdio.h
+include/c++/v1/stdlib.h
+include/c++/v1/streambuf
+include/c++/v1/string
+include/c++/v1/strstream
+include/c++/v1/support/
+include/c++/v1/support/newlib/
+include/c++/v1/support/newlib/xlocale.h
+include/c++/v1/support/xlocale/
+include/c++/v1/support/xlocale/xlocale.h
+include/c++/v1/system_error
+include/c++/v1/tgmath.h
+include/c++/v1/thread
+include/c++/v1/tuple
+include/c++/v1/type_traits
+include/c++/v1/typeindex
+include/c++/v1/typeinfo
+include/c++/v1/unordered_map
+include/c++/v1/unordered_set
+include/c++/v1/unwind.h
+include/c++/v1/utility
+include/c++/v1/valarray
+include/c++/v1/vector
+include/c++/v1/wchar.h
+include/c++/v1/wctype.h
+lib/libc++.a
+@lib lib/libc++.so.${LIBc++_VERSION}
+lib/libc++_p.a
+lib/libc++abi.a
+@lib lib/libc++abi.so.${LIBc++abi_VERSION}
+lib/libc++abi_p.a
diff --git devel/llvm/patches/patch-tools_clang_lib_Driver_ToolChains_cpp 
devel/llvm/patches/patch-tools_clang_lib_Driver_ToolChains_cpp
index 0c97d3e..daea470 100644
--- devel/llvm/patches/patch-tools_clang_lib_Driver_ToolChains_cpp
+++ devel/llvm/patches/patch-tools_clang_lib_Driver_ToolChains_cpp
@@ -2,8 +2,8 @@ $OpenBSD: patch-tools_clang_lib_Driver_ToolChains_cpp,v 1.7 
2016/05/15 07:07:52
 
 Use the integrated assembler by default on Sparc and Mips64.
 
---- tools/clang/lib/Driver/ToolChains.cpp.orig Tue Feb 16 14:56:48 2016
-+++ tools/clang/lib/Driver/ToolChains.cpp      Sat May 14 20:34:32 2016
+--- tools/clang/lib/Driver/ToolChains.cpp.orig Tue Feb 16 20:56:48 2016
++++ tools/clang/lib/Driver/ToolChains.cpp      Sun May 15 22:35:28 2016
 @@ -2378,6 +2378,10 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const
    case llvm::Triple::ppc64:
    case llvm::Triple::ppc64le:
@@ -15,7 +15,7 @@ Use the integrated assembler by default on Sparc and Mips64.
      return true;
    default:
      return false;
-@@ -2985,6 +2989,50 @@ Tool *OpenBSD::buildAssembler() const {
+@@ -2985,6 +2989,56 @@ Tool *OpenBSD::buildAssembler() const {
  }
  
  Tool *OpenBSD::buildLinker() const { return new 
tools::openbsd::Linker(*this); }
@@ -39,15 +39,21 @@ Use the integrated assembler by default on Sparc and Mips64.
 +      DriverArgs.hasArg(options::OPT_nostdincxx))
 +    return;
 +
-+  /* XXX handle libc++ includes */
-+
-+  addSystemInclude(DriverArgs, CC1Args,
-+                   getDriver().SysRoot + 
"${LOCALBASE}/include/c++/${GCC_VER}");
++  switch (GetCXXStdlibType(DriverArgs)) {
++  case ToolChain::CST_Libcxx:
++    addSystemInclude(DriverArgs, CC1Args,
++                     getDriver().SysRoot + "${LOCALBASE}/include/c++/v1");
++    break;
++  case ToolChain::CST_Libstdcxx:
++    addSystemInclude(DriverArgs, CC1Args,
++                     getDriver().SysRoot + 
"${LOCALBASE}/include/c++/${GCC_VER}");
 +
-+  addSystemInclude(DriverArgs, CC1Args,
-+                   getDriver().SysRoot + 
"${LOCALBASE}/include/c++/${GCC_VER}/${GCC_CONFIG}");
-+  addSystemInclude(DriverArgs, CC1Args,
-+                   getDriver().SysRoot + 
"${LOCALBASE}/include/c++/${GCC_VER}/backward");
++    addSystemInclude(DriverArgs, CC1Args,
++                     getDriver().SysRoot + 
"${LOCALBASE}/include/c++/${GCC_VER}/${GCC_CONFIG}");
++    addSystemInclude(DriverArgs, CC1Args,
++                     getDriver().SysRoot + 
"${LOCALBASE}/include/c++/${GCC_VER}/backward");
++    break;
++  }
 +}
 +
 +void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,

Reply via email to