Module Name:    src
Committed By:   bouyer
Date:           Tue Aug 29 09:43:20 UTC 2017

Modified Files:
        src/distrib/sets/lists/debug [netbsd-8]: mi shl.mi
        src/distrib/sets/lists/tests [netbsd-8]: mi shl.mi
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/alpha [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/arm [netbsd-8]: c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/armeb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earm [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/hppa [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/i386 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/ia64 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68000 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68k [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/or1k [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64 [netbsd-8]:
            c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/vax [netbsd-8]: c++config.h
        src/external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64 [netbsd-8]:
            c++config.h
        src/include [netbsd-8]: dlfcn.h
        src/lib/libc/dlfcn [netbsd-8]: dlfcn_elf.c
        src/lib/libc/stdlib [netbsd-8]: Makefile.inc exit.c
        src/lib/libpthread [netbsd-8]: pthread.c
        src/libexec/ld.elf_so [netbsd-8]: rtld.c rtld.h symbols.map
        src/tests/lib/libpthread [netbsd-8]: Makefile
        src/tests/libexec/ld.elf_so [netbsd-8]: Makefile
Added Files:
        src/lib/libc/include [netbsd-8]: atexit.h
        src/lib/libc/stdlib [netbsd-8]: cxa_thread_atexit.c
        src/tests/libexec/ld.elf_so [netbsd-8]: h_thread_local_dtor.c
            t_thread_local_dtor.sh
        src/tests/libexec/ld.elf_so/helper_dso3 [netbsd-8]: Makefile
            h_helper_dso3.cpp
Removed Files:
        src/lib/libc/stdlib [netbsd-8]: atexit.h

Log Message:
Pull up following revision(s) (requested by joerg in ticket #127):
        tests/libexec/ld.elf_so/h_thread_local_dtor.c: revision 1.1
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h: revision 
1.14
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h: revision 
1.17
        lib/libc/stdlib/atexit.h: file removal
        lib/libc/stdlib/exit.c: revision 1.16
        external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h: revision 
1.8
        lib/libc/stdlib/exit.c: revision 1.17
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h: revision 
1.14
        distrib/sets/lists/debug/shl.mi: revision 1.178
        external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h: revision 1.21
        distrib/sets/lists/debug/shl.mi: revision 1.179
        distrib/sets/lists/debug/mi: revision 1.219
        lib/libpthread/pthread.c: revision 1.150
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h: revision 
1.14
        libexec/ld.elf_so/symbols.map: revision 1.2
        include/dlfcn.h: revision 1.25
        external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h: revision 1.21
        external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h: revision 
1.23
        external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h: revision 
1.18
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h: revision 
1.14
        external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h: revision 1.19
        external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h: revision 
1.19
        external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h: revision 1.5
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h: revision 
1.14
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h: revision 
1.17
        distrib/sets/lists/tests/mi: revision 1.755
        external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h: revision 
1.19
        external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h: revision 1.20
        external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h: revision 1.21
        external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h: revision 1.21
        external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h: revision 1.20
        lib/libc/dlfcn/dlfcn_elf.c: revision 1.14
        tests/libexec/ld.elf_so/t_thread_local_dtor.sh: revision 1.1
        tests/lib/libpthread/t_thread_local_dtor.sh: revision 1.1
        lib/libc/stdlib/Makefile.inc: revision 1.93
        lib/libc/include/atexit.h: revision 1.1
        lib/libc/include/atexit.h: revision 1.2
        external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h: revision 1.19
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h: revision 
1.14
        distrib/sets/lists/debug/shl.mi: revision 1.180
        external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h: revision 
1.19
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h: 
revision 1.14
        external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h: revision 1.19
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h: 
revision 1.14
        lib/libc/stdlib/cxa_thread_atexit.c: revision 1.1
        tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp: revision 1.1
        tests/libexec/ld.elf_so/helper_dso3/Makefile: revision 1.1
        external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h: revision 
1.5
        libexec/ld.elf_so/rtld.c: revision 1.185
        external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h: revision 1.19
        external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h: revision 
1.5
        external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h: revision 
1.15
        external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h: revision 
1.21
        external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h: revision 
1.12
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h: revision 
1.14
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h: revision 
1.15
        external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h: revision 1.19
        tests/libexec/ld.elf_so/Makefile: revision 1.9
        external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h: revision 
1.20
        external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h: revision 
1.14
        tests/lib/libpthread/h_thread_local_dtor.cpp: revision 1.1
        distrib/sets/lists/tests/shl.mi: revision 1.11
        tests/lib/libpthread/Makefile: revision 1.13
        libexec/ld.elf_so/rtld.h: revision 1.129
        external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h: revision 1.6
Implement __cxa_thread_atexit and __cxa_thread_atexit_impl. This
functions are used for destructors of thread_local objects.
If a pending destructor exists, prevent unloading of shared objects.
Introduce __dl_cxa_refcount interface for this purpose. When the last
reference is gone and the object has been dlclose'd before, the
unloading is finalized.
Ideally, __cxa_thread_atexit_impl wouldn't exist, but libstdc++ insists
on providing __cxa_thread_atexit as direct wrapper without further
patching.
Fix filename of new debug file
Add misising DEBUGLIB file
Avoid common declaration.
Drop TLS variant checks, emutls is enough for VAX and Sun2.


To generate a diff of this commit:
cvs rdiff -u -r1.216.2.1 -r1.216.2.2 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.176.2.1 -r1.176.2.2 src/distrib/sets/lists/debug/shl.mi
cvs rdiff -u -r1.752 -r1.752.2.1 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.10 -r1.10.8.1 src/distrib/sets/lists/tests/shl.mi
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h
cvs rdiff -u -r1.20 -r1.20.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h
cvs rdiff -u -r1.20 -r1.20.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h
cvs rdiff -u -r1.11 -r1.11.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h
cvs rdiff -u -r1.16 -r1.16.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h
cvs rdiff -u -r1.16 -r1.16.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h
cvs rdiff -u -r1.14 -r1.14.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h
cvs rdiff -u -r1.19 -r1.19.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h
cvs rdiff -u -r1.4 -r1.4.8.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h
cvs rdiff -u -r1.13 -r1.13.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h
cvs rdiff -u -r1.17 -r1.17.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h
cvs rdiff -u -r1.20 -r1.20.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h
cvs rdiff -u -r1.5 -r1.5.8.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h
cvs rdiff -u -r1.19 -r1.19.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h
cvs rdiff -u -r1.7 -r1.7.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h
cvs rdiff -u -r1.4 -r1.4.8.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h
cvs rdiff -u -r1.4 -r1.4.8.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h
cvs rdiff -u -r1.20 -r1.20.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h
cvs rdiff -u -r1.19 -r1.19.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h
cvs rdiff -u -r1.18 -r1.18.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h
cvs rdiff -u -r1.20 -r1.20.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h
cvs rdiff -u -r1.22 -r1.22.6.1 \
    src/external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h
cvs rdiff -u -r1.24 -r1.24.24.1 src/include/dlfcn.h
cvs rdiff -u -r1.13 -r1.13.24.1 src/lib/libc/dlfcn/dlfcn_elf.c
cvs rdiff -u -r0 -r1.2.2.2 src/lib/libc/include/atexit.h
cvs rdiff -u -r1.92 -r1.92.8.1 src/lib/libc/stdlib/Makefile.inc
cvs rdiff -u -r1.11 -r0 src/lib/libc/stdlib/atexit.h
cvs rdiff -u -r0 -r1.1.4.2 src/lib/libc/stdlib/cxa_thread_atexit.c
cvs rdiff -u -r1.15 -r1.15.36.1 src/lib/libc/stdlib/exit.c
cvs rdiff -u -r1.147 -r1.147.8.1 src/lib/libpthread/pthread.c
cvs rdiff -u -r1.183.4.1 -r1.183.4.2 src/libexec/ld.elf_so/rtld.c
cvs rdiff -u -r1.126.6.2 -r1.126.6.3 src/libexec/ld.elf_so/rtld.h
cvs rdiff -u -r1.1 -r1.1.8.1 src/libexec/ld.elf_so/symbols.map
cvs rdiff -u -r1.12 -r1.12.6.1 src/tests/lib/libpthread/Makefile
cvs rdiff -u -r1.8 -r1.8.8.1 src/tests/libexec/ld.elf_so/Makefile
cvs rdiff -u -r0 -r1.2.2.2 src/tests/libexec/ld.elf_so/h_thread_local_dtor.c
cvs rdiff -u -r0 -r1.1.4.2 src/tests/libexec/ld.elf_so/t_thread_local_dtor.sh
cvs rdiff -u -r0 -r1.1.4.2 src/tests/libexec/ld.elf_so/helper_dso3/Makefile \
    src/tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.216.2.1 src/distrib/sets/lists/debug/mi:1.216.2.2
--- src/distrib/sets/lists/debug/mi:1.216.2.1	Tue Jul 18 17:32:50 2017
+++ src/distrib/sets/lists/debug/mi	Tue Aug 29 09:43:16 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.216.2.1 2017/07/18 17:32:50 snj Exp $
+# $NetBSD: mi,v 1.216.2.2 2017/08/29 09:43:16 bouyer Exp $
 ./etc/mtree/set.debug                           comp-sys-root
 ./usr/lib					comp-sys-usr		compatdir
 ./usr/lib/i18n/libBIG5_g.a			comp-c-debuglib		debuglib,compatfile
@@ -2196,6 +2196,7 @@
 ./usr/libdata/debug/usr/tests/lib/libpthread/h_cancel.debug		tests-lib-tests		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libpthread/h_exit.debug		tests-lib-tests		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libpthread/h_resolv.debug		tests-lib-tests		debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/lib/libpthread/h_thread_local_dtor.debug	tests-lib-tests		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libpthread/t_barrier.debug		tests-lib-tests		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libpthread/t_cond.debug		tests-lib-tests		debug,atf,compattestfile
 ./usr/libdata/debug/usr/tests/lib/libpthread/t_condwait.debug		tests-lib-tests		debug,atf,compattestfile

Index: src/distrib/sets/lists/debug/shl.mi
diff -u src/distrib/sets/lists/debug/shl.mi:1.176.2.1 src/distrib/sets/lists/debug/shl.mi:1.176.2.2
--- src/distrib/sets/lists/debug/shl.mi:1.176.2.1	Wed Jun 21 18:03:17 2017
+++ src/distrib/sets/lists/debug/shl.mi	Tue Aug 29 09:43:16 2017
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.176.2.1 2017/06/21 18:03:17 snj Exp $
+# $NetBSD: shl.mi,v 1.176.2.2 2017/08/29 09:43:16 bouyer Exp $
 ./usr/lib/libbfd_g.a						comp-c-debuglib	debuglib,compatfile,binutils
 ./usr/libdata/debug/lib						base-sys-usr	debug,dynamicroot,compatdir
 ./usr/libdata/debug/lib/libblacklist.so.0.0.debug		comp-sys-debug	debug,dynamicroot
@@ -307,12 +307,16 @@
 ./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_helper_symver_dso0/libh_helper_symver_dso.so.1.debug	tests-libexec-debug	debug,compattestfile,atf
 ./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_helper_symver_dso1/libh_helper_symver_dso.so.1.debug	tests-libexec-debug	debug,compattestfile,atf
 ./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_helper_symver_dso2/libh_helper_symver_dso.so.1.debug	tests-libexec-debug	debug,compattestfile,atf
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so/h_thread_local_dtor.debug	tests-libexec-debug	debug,compattestfile,atf
 ./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_dso1.so.1.debug	tests-libexec-debug	debug,compattestfile,atf
 ./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_dso2.so.1.debug	tests-libexec-debug	debug,compattestfile,atf
+./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_dso3.so.1.debug	tests-libexec-debug	debug,compattestfile,atf
 ./usr/libdata/debug/usr/tests/libexec/ld.elf_so/libh_helper_ifunc_dso.so.1.debug	tests-libexec-debug	debug,compattestfile,atf
 ./usr/tests/libexec/ld.elf_so/h_helper_symver_dso0/libh_helper_symver_dso_g.a	comp-c-debuglib	atf,debuglib,compattestfile
 ./usr/tests/libexec/ld.elf_so/h_helper_symver_dso1/libh_helper_symver_dso_g.a	comp-c-debuglib	atf,debuglib,compattestfile
 ./usr/tests/libexec/ld.elf_so/h_helper_symver_dso2/libh_helper_symver_dso_g.a	comp-c-debuglib	atf,debuglib,compattestfile
 ./usr/tests/libexec/ld.elf_so/libh_helper_dso1_g.a			comp-c-debuglib	atf,debuglib,compattestfile
 ./usr/tests/libexec/ld.elf_so/libh_helper_dso2_g.a			comp-c-debuglib	atf,debuglib,compattestfile
+./usr/tests/libexec/ld.elf_so/libh_helper_dso3_g.a			comp-c-debuglib	atf,debuglib,compattestfile
 ./usr/tests/libexec/ld.elf_so/libh_helper_ifunc_dso_g.a			comp-c-debuglib	atf,debuglib,compattestfile
+

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.752 src/distrib/sets/lists/tests/mi:1.752.2.1
--- src/distrib/sets/lists/tests/mi:1.752	Thu Jun  1 15:45:02 2017
+++ src/distrib/sets/lists/tests/mi	Tue Aug 29 09:43:17 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.752 2017/06/01 15:45:02 perseant Exp $
+# $NetBSD: mi,v 1.752.2.1 2017/08/29 09:43:17 bouyer Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3043,6 +3043,7 @@
 ./usr/tests/lib/libpthread/h_cancel		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread/h_exit		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread/h_resolv		tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libpthread/h_thread_local_dtor	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread/t_atexit		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread/t_barrier		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread/t_cancel		tests-lib-tests		compattestfile,atf
@@ -3068,6 +3069,7 @@
 ./usr/tests/lib/libpthread/t_sleep		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread/t_status		tests-obsolete		obsolete
 ./usr/tests/lib/libpthread/t_swapcontext	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libpthread/t_thread_local_dtor	tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread/t_timedmutex		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libpthread_dbg			tests-obsolete		obsolete
 ./usr/tests/lib/libpthread_dbg/Atffile		tests-obsolete		obsolete
@@ -3205,6 +3207,7 @@
 ./usr/tests/libexec/ld.elf_so/h_helper_symver_dso2	tests-libexec-tests	compattestfile,atf
 ./usr/tests/libexec/ld.elf_so/h_ifunc		tests-libexec-tests	compattestfile,atf,pic
 ./usr/tests/libexec/ld.elf_so/h_locking		tests-libexec-tests	compattestfile,atf,pic
+./usr/tests/libexec/ld.elf_so/h_thread_local_dtor	tests-libexec-tests	compattestfile,atf,pic
 ./usr/tests/libexec/ld.elf_so/t_df_1_noopen	tests-libexec-tests	compattestfile,atf,pic
 ./usr/tests/libexec/ld.elf_so/t_dl_symver	tests-libexec-tests	compattestfile,atf,pic
 ./usr/tests/libexec/ld.elf_so/t_dlerror-cleared	tests-libexec-tests	compattestfile,atf,pic
@@ -3212,6 +3215,7 @@
 ./usr/tests/libexec/ld.elf_so/t_dlinfo		tests-libexec-tests	compattestfile,atf,pic
 ./usr/tests/libexec/ld.elf_so/t_dlvsym		tests-libexec-tests	compattestfile,atf,pic
 ./usr/tests/libexec/ld.elf_so/t_ifunc		tests-libexec-tests	compattestfile,atf,pic
+./usr/tests/libexec/ld.elf_so/t_thread_local_dtor	tests-libexec-tests	compattestfile,atf,pic
 ./usr/tests/modules				tests-sys-tests		compattestfile,atf
 ./usr/tests/net					tests-net-tests		compattestfile,atf
 ./usr/tests/net/Atffile				tests-net-tests		compattestfile,atf

Index: src/distrib/sets/lists/tests/shl.mi
diff -u src/distrib/sets/lists/tests/shl.mi:1.10 src/distrib/sets/lists/tests/shl.mi:1.10.8.1
--- src/distrib/sets/lists/tests/shl.mi:1.10	Mon Jun 22 06:02:02 2015
+++ src/distrib/sets/lists/tests/shl.mi	Tue Aug 29 09:43:18 2017
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.10 2015/06/22 06:02:02 matt Exp $
+# $NetBSD: shl.mi,v 1.10.8.1 2017/08/29 09:43:18 bouyer Exp $
 #
 ./usr/tests/lib/csu/h_initfini3_dso.so		tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/csu/h_initfini3_dso.so.1	tests-lib-tests		compattestfile,atf
@@ -20,6 +20,8 @@
 ./usr/tests/libexec/ld.elf_so/libh_helper_dso1.so.1				tests-libexec-tests	compattestfile,atf
 ./usr/tests/libexec/ld.elf_so/libh_helper_dso2.so				tests-libexec-tests	compattestfile,atf
 ./usr/tests/libexec/ld.elf_so/libh_helper_dso2.so.1				tests-libexec-tests	compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_helper_dso3.so				tests-libexec-tests	compattestfile,atf
+./usr/tests/libexec/ld.elf_so/libh_helper_dso3.so.1				tests-libexec-tests	compattestfile,atf
 ./usr/tests/libexec/ld.elf_so/libh_helper_ifunc_dso.so				tests-libexec-tests	compattestfile,atf
 ./usr/tests/libexec/ld.elf_so/libh_helper_ifunc_dso.so.1			tests-libexec-tests	compattestfile,atf
 ./usr/tests/util/id/libfake.so.0		tests-obsolete		obsolete

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h:1.18	Tue Oct 18 01:32:56 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/alpha/c++config.h	Tue Aug 29 09:43:20 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h:1.20 src/external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h:1.20.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h:1.20	Tue Oct 18 01:32:56 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/arm/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h:1.20 src/external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h:1.20.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h:1.20	Tue Oct 18 01:32:56 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/armeb/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h:1.11 src/external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h:1.11.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h:1.11	Tue Oct 18 01:32:56 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/coldfire/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h:1.18	Tue Oct 18 01:32:56 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earm/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h:1.16 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h:1.16.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h:1.16	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmeb/c++config.h	Tue Aug 29 09:43:16 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h:1.16 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h:1.16.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h:1.16	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhf/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h:1.14 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h:1.14.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h:1.14	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmhfeb/c++config.h	Tue Aug 29 09:43:20 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv4eb/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6/c++config.h	Tue Aug 29 09:43:16 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6eb/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hf/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv6hfeb/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7/c++config.h	Tue Aug 29 09:43:16 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h:1.13	Tue Oct 18 01:32:57 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7eb/c++config.h	Tue Aug 29 09:43:20 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h:1.13	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hf/c++config.h	Tue Aug 29 09:43:16 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h:1.13	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/earmv7hfeb/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h:1.18	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/hppa/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h:1.19 src/external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h:1.19.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h:1.19	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/i386/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h:1.4 src/external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h:1.4.8.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h:1.4	Thu Jun 30 01:44:49 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/ia64/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h:1.13 src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h:1.13.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h:1.13	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68000/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h:1.18	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/m68k/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h:1.18	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64eb/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h:1.17 src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h:1.17.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h:1.17	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/mips64el/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h:1.20 src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h:1.20.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h:1.20	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipseb/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h:1.18	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/mipsel/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h:1.5 src/external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h:1.5.8.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h:1.5	Sat Jan 10 22:59:40 2015
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/or1k/c++config.h	Tue Aug 29 09:43:20 2017
@@ -1132,7 +1132,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h:1.19 src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h:1.19.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h:1.19	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc/c++config.h	Tue Aug 29 09:43:20 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h:1.7 src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h:1.7.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h:1.7	Tue Oct 18 01:32:58 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/powerpc64/c++config.h	Tue Aug 29 09:43:16 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h:1.4 src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h:1.4.8.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h:1.4	Sat Jan 10 22:59:40 2015
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv32/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1132,7 +1132,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h:1.4 src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h:1.4.8.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h:1.4	Sat Jan 10 22:59:40 2015
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/riscv64/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1132,7 +1132,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h:1.18	Tue Oct 18 01:32:59 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3eb/c++config.h	Tue Aug 29 09:43:19 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h:1.20 src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h:1.20.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h:1.20	Tue Oct 18 01:32:59 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/sh3el/c++config.h	Tue Aug 29 09:43:16 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h:1.19 src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h:1.19.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h:1.19	Tue Oct 18 01:32:59 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h:1.18 src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h:1.18.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h:1.18	Tue Oct 18 01:32:59 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/sparc64/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h:1.20 src/external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h:1.20.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h:1.20	Tue Oct 18 01:32:59 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/vax/c++config.h	Tue Aug 29 09:43:18 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h
diff -u src/external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h:1.22 src/external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h:1.22.6.1
--- src/external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h:1.22	Tue Oct 18 01:32:59 2016
+++ src/external/gpl3/gcc/lib/libstdc++-v3/arch/x86_64/c++config.h	Tue Aug 29 09:43:17 2017
@@ -1203,7 +1203,7 @@ namespace std
 /* #undef _GLIBCXX_HAVE__TANL */
 
 /* Define to 1 if you have the `__cxa_thread_atexit_impl' function. */
-/* #undef _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
+#define _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL 1
 
 /* Define as const if the declaration of iconv() needs const. */
 #define _GLIBCXX_ICONV_CONST const

Index: src/include/dlfcn.h
diff -u src/include/dlfcn.h:1.24 src/include/dlfcn.h:1.24.24.1
--- src/include/dlfcn.h:1.24	Thu Feb 16 23:00:39 2012
+++ src/include/dlfcn.h	Tue Aug 29 09:43:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dlfcn.h,v 1.24 2012/02/16 23:00:39 joerg Exp $	*/
+/*	$NetBSD: dlfcn.h,v 1.24.24.1 2017/08/29 09:43:17 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -34,6 +34,12 @@
 
 #include <sys/featuretest.h>
 #include <sys/cdefs.h>
+#include <machine/ansi.h>
+
+#ifdef	_BSD_SSIZE_T_
+typedef	_BSD_SSIZE_T_	ssize_t;
+#undef	_BSD_SSIZE_T_
+#endif
 
 #if defined(_NETBSD_SOURCE)
 typedef struct _dl_info {
@@ -59,6 +65,7 @@ int	dlctl(void *, int, void *);
 int	dlinfo(void *, int, void *);
 void	*dlvsym(void * __restrict, const char * __restrict,
 	    const char * __restrict);
+void	__dl_cxa_refcount(void *, ssize_t);
 #endif
 __aconst char *dlerror(void);
 __END_DECLS

Index: src/lib/libc/dlfcn/dlfcn_elf.c
diff -u src/lib/libc/dlfcn/dlfcn_elf.c:1.13 src/lib/libc/dlfcn/dlfcn_elf.c:1.13.24.1
--- src/lib/libc/dlfcn/dlfcn_elf.c:1.13	Sun Jun 24 15:26:03 2012
+++ src/lib/libc/dlfcn/dlfcn_elf.c	Tue Aug 29 09:43:18 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: dlfcn_elf.c,v 1.13 2012/06/24 15:26:03 christos Exp $	*/
+/*	$NetBSD: dlfcn_elf.c,v 1.13.24.1 2017/08/29 09:43:18 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2000 Takuya SHIOZAKI
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: dlfcn_elf.c,v 1.13 2012/06/24 15:26:03 christos Exp $");
+__RCSID("$NetBSD: dlfcn_elf.c,v 1.13.24.1 2017/08/29 09:43:18 bouyer Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include "namespace.h"
@@ -75,6 +75,7 @@ __weak_alias(__dlerror,___dlerror)
 __weak_alias(__dladdr,___dladdr)
 __weak_alias(__dlinfo,___dlinfo)
 __weak_alias(__dl_iterate_phdr,___dl_iterate_phdr)
+__weak_alias(__dl_cxa_refcount, ___dl_cxa_refcount)
 #endif
 
 /*
@@ -203,3 +204,11 @@ dl_iterate_phdr(int (*callback)(struct d
 
 	return callback(&phdr_info, sizeof(phdr_info), data);
 }
+
+void ___dl_cxa_refcount(void *, ssize_t);
+
+/*ARGSUSED*/
+void
+___dl_cxa_refcount(void *dso_symbol, ssize_t delta)
+{
+}

Index: src/lib/libc/stdlib/Makefile.inc
diff -u src/lib/libc/stdlib/Makefile.inc:1.92 src/lib/libc/stdlib/Makefile.inc:1.92.8.1
--- src/lib/libc/stdlib/Makefile.inc:1.92	Fri Apr  1 12:37:48 2016
+++ src/lib/libc/stdlib/Makefile.inc	Tue Aug 29 09:43:16 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.92 2016/04/01 12:37:48 msaitoh Exp $
+#	$NetBSD: Makefile.inc,v 1.92.8.1 2017/08/29 09:43:16 bouyer Exp $
 #	from: @(#)Makefile.inc	8.3 (Berkeley) 2/4/95
 
 # stdlib sources
@@ -6,7 +6,7 @@
 
 SRCS+=	_env.c _rand48.c \
 	a64l.c abort.c aligned_alloc.c atexit.c atof.c atoi.c atol.c atoll.c \
-	bsearch.c drand48.c exit.c \
+	bsearch.c cxa_thread_atexit.c drand48.c exit.c \
 	getenv.c getopt.c getopt_long.c getsubopt.c \
 	hcreate.c heapsort.c imaxdiv.c insque.c jrand48.c l64a.c lldiv.c \
 	lcong48.c lrand48.c lsearch.c merge.c mi_vector_hash.c mrand48.c \

Index: src/lib/libc/stdlib/exit.c
diff -u src/lib/libc/stdlib/exit.c:1.15 src/lib/libc/stdlib/exit.c:1.15.36.1
--- src/lib/libc/stdlib/exit.c:1.15	Wed May 18 19:36:36 2011
+++ src/lib/libc/stdlib/exit.c	Tue Aug 29 09:43:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: exit.c,v 1.15 2011/05/18 19:36:36 dsl Exp $	*/
+/*	$NetBSD: exit.c,v 1.15.36.1 2017/08/29 09:43:16 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)exit.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: exit.c,v 1.15 2011/05/18 19:36:36 dsl Exp $");
+__RCSID("$NetBSD: exit.c,v 1.15.36.1 2017/08/29 09:43:16 bouyer Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -55,6 +55,8 @@ exit(int status)
 {
 
 #ifdef _LIBC
+	if (__cxa_thread_atexit_used)
+		__cxa_thread_run_atexit();
 	__cxa_finalize(NULL);
 #endif
 	if (__cleanup)

Index: src/lib/libpthread/pthread.c
diff -u src/lib/libpthread/pthread.c:1.147 src/lib/libpthread/pthread.c:1.147.8.1
--- src/lib/libpthread/pthread.c:1.147	Fri May 29 16:05:13 2015
+++ src/lib/libpthread/pthread.c	Tue Aug 29 09:43:16 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: pthread.c,v 1.147 2015/05/29 16:05:13 christos Exp $	*/
+/*	$NetBSD: pthread.c,v 1.147.8.1 2017/08/29 09:43:16 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.147 2015/05/29 16:05:13 christos Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.147.8.1 2017/08/29 09:43:16 bouyer Exp $");
 
 #define	__EXPOSE_STACK	1
 
@@ -57,6 +57,7 @@ __RCSID("$NetBSD: pthread.c,v 1.147 2015
 #include <unistd.h>
 #include <sched.h>
 
+#include "atexit.h"
 #include "pthread.h"
 #include "pthread_int.h"
 #include "pthread_makelwp.h"
@@ -638,6 +639,10 @@ pthread_exit(void *retval)
 		pthread_mutex_lock(&self->pt_lock);
 	}
 
+	pthread_mutex_unlock(&self->pt_lock);
+	__cxa_thread_run_atexit();
+	pthread_mutex_lock(&self->pt_lock);
+
 	/* Perform cleanup of thread-specific data */
 	pthread__destroy_tsd(self);
 

Index: src/libexec/ld.elf_so/rtld.c
diff -u src/libexec/ld.elf_so/rtld.c:1.183.4.1 src/libexec/ld.elf_so/rtld.c:1.183.4.2
--- src/libexec/ld.elf_so/rtld.c:1.183.4.1	Sat Jun 10 06:27:51 2017
+++ src/libexec/ld.elf_so/rtld.c	Tue Aug 29 09:43:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.c,v 1.183.4.1 2017/06/10 06:27:51 snj Exp $	 */
+/*	$NetBSD: rtld.c,v 1.183.4.2 2017/08/29 09:43:17 bouyer Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -40,7 +40,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: rtld.c,v 1.183.4.1 2017/06/10 06:27:51 snj Exp $");
+__RCSID("$NetBSD: rtld.c,v 1.183.4.2 2017/08/29 09:43:17 bouyer Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -1425,6 +1425,45 @@ dl_iterate_phdr(int (*callback)(struct d
 	return error;
 }
 
+void
+__dl_cxa_refcount(void *addr, ssize_t delta)
+{
+	sigset_t mask;
+	Obj_Entry *obj;
+
+	if (delta == 0)
+		return;
+
+	dbg(("__dl_cxa_refcount of %p with %zd", addr, delta));
+
+	_rtld_exclusive_enter(&mask);
+	obj = _rtld_obj_from_addr(addr);
+
+	if (obj == NULL) {
+		dbg(("__dl_cxa_refcont: address not found"));
+		_rtld_error("No shared object contains address");
+		_rtld_exclusive_exit(&mask);
+		return;
+	}
+	if (delta > 0 && obj->cxa_refcount > SIZE_MAX - delta)
+		_rtld_error("Reference count overflow");
+	else if (delta < 0 && obj->cxa_refcount < -1 + (size_t)-(delta + 1))
+		_rtld_error("Reference count underflow");
+	else {
+		if (obj->cxa_refcount == 0)
+			++obj->refcount;
+		obj->cxa_refcount += delta;
+		dbg(("new reference count: %zu", obj->cxa_refcount));
+		if (obj->cxa_refcount == 0) {
+			--obj->refcount;
+			if (obj->refcount == 0)
+				_rtld_unload_object(&mask, obj, true);
+		}
+	}
+
+	_rtld_exclusive_exit(&mask);
+}
+
 /*
  * Error reporting function.  Use it like printf.  If formats the message
  * into a buffer, and sets things up so that the next call to dlerror()

Index: src/libexec/ld.elf_so/rtld.h
diff -u src/libexec/ld.elf_so/rtld.h:1.126.6.2 src/libexec/ld.elf_so/rtld.h:1.126.6.3
--- src/libexec/ld.elf_so/rtld.h:1.126.6.2	Mon Jul 24 06:15:54 2017
+++ src/libexec/ld.elf_so/rtld.h	Tue Aug 29 09:43:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtld.h,v 1.126.6.2 2017/07/24 06:15:54 snj Exp $	 */
+/*	$NetBSD: rtld.h,v 1.126.6.3 2017/08/29 09:43:17 bouyer Exp $	 */
 
 /*
  * Copyright 1996 John D. Polstra.
@@ -298,6 +298,7 @@ typedef struct Struct_Obj_Entry {
 	size_t		init_arraysz;	/* # of entries in it */
 	Elf_Addr	*fini_array;	/* start of fini array */
 	size_t		fini_arraysz;	/* # of entries in it */
+	size_t		cxa_refcount;	/* For TLS destructors. */
 #ifdef __ARM_EABI__
 	void		*exidx_start;
 	size_t		exidx_sz;
@@ -355,6 +356,7 @@ __dso_public int dl_iterate_phdr(int (*)
     void *);
 
 __dso_public void *_dlauxinfo(void) __pure;
+__dso_public void __dl_cxa_refcount(void *addr, ssize_t delta);
 
 #if defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
 /*

Index: src/libexec/ld.elf_so/symbols.map
diff -u src/libexec/ld.elf_so/symbols.map:1.1 src/libexec/ld.elf_so/symbols.map:1.1.8.1
--- src/libexec/ld.elf_so/symbols.map:1.1	Thu Dec  1 14:29:15 2016
+++ src/libexec/ld.elf_so/symbols.map	Tue Aug 29 09:43:17 2017
@@ -22,5 +22,6 @@
     __tls_get_addr;
     ___tls_get_addr;
     __gnu_Unwind_Find_exidx;
+    __dl_cxa_refcount;
   local: *;
 };

Index: src/tests/lib/libpthread/Makefile
diff -u src/tests/lib/libpthread/Makefile:1.12 src/tests/lib/libpthread/Makefile:1.12.6.1
--- src/tests/lib/libpthread/Makefile:1.12	Sun Oct 30 16:17:16 2016
+++ src/tests/lib/libpthread/Makefile	Tue Aug 29 09:43:18 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.12 2016/10/30 16:17:16 kamil Exp $
+# $NetBSD: Makefile,v 1.12.6.1 2017/08/29 09:43:18 bouyer Exp $
 
 NOMAN=		# defined
 
@@ -38,6 +38,7 @@ TESTS_C+=	t_sigsuspend
 TESTS_C+=	t_siglongjmp
 TESTS_C+=	t_sleep
 TESTS_C+=	t_swapcontext
+TESTS_SH+=	t_thread_local_dtor
 TESTS_C+=	t_timedmutex
 
 LDADD.t_sem+=	-lrt
@@ -47,6 +48,11 @@ PROGS=		h_atexit
 PROGS+=		h_cancel
 PROGS+=		h_exit
 PROGS+=		h_resolv
+PROGS_CXX+=	h_thread_local_dtor
+
+COPTS.h_thread_local_dtor.cpp+=	-std=c++11
+# Deal with questionable warning and header quality in libstdc++.
+COPTS.h_thread_local_dtor.cpp+=	 ${${ACTIVE_CC} == "gcc" :?  -Wno-ctor-dtor-privacy -Wno-sign-compare -Wno-shadow :}
 
 FILESDIR=	${TESTSDIR}
 FILES=		d_mach

Index: src/tests/libexec/ld.elf_so/Makefile
diff -u src/tests/libexec/ld.elf_so/Makefile:1.8 src/tests/libexec/ld.elf_so/Makefile:1.8.8.1
--- src/tests/libexec/ld.elf_so/Makefile:1.8	Mon Aug 25 20:40:53 2014
+++ src/tests/libexec/ld.elf_so/Makefile	Tue Aug 29 09:43:16 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2014/08/25 20:40:53 joerg Exp $
+# $NetBSD: Makefile,v 1.8.8.1 2017/08/29 09:43:16 bouyer Exp $
 #
 
 NOMAN=		# defined
@@ -7,7 +7,7 @@ NOMAN=		# defined
 
 .if ${MKPIC} != "no"
 
-SUBDIR+=	helper_dso1 .WAIT helper_dso2 .WAIT \
+SUBDIR+=	helper_dso1 helper_dso3 .WAIT helper_dso2 .WAIT \
 		helper_ifunc_dso \
 		helper_symver_dso0 .WAIT helper_symver_dso1 .WAIT \
 		helper_symver_dso2 .WAIT \
@@ -22,7 +22,7 @@ LDADD.t_dlvsym=		-Wl,-rpath,${TESTSDIR}/
 LDADD.t_ifunc=		-Wl,-rpath,${TESTSDIR} -lutil
 DPADD.t_ifunc=		${LIBUTIL}
 
-TESTS_SH+=		t_df_1_noopen t_dl_symver
+TESTS_SH+=		t_df_1_noopen t_dl_symver t_thread_local_dtor
 
 BINDIR=			${TESTSDIR}
 PROGS+=			h_df_1_noopen1
@@ -32,6 +32,9 @@ PROGS+=			h_df_1_noopen2
 SRCS.h_df_1_noopen2=	h_df_1_noopen.c
 LDADD.h_df_1_noopen2=	-lpthread
 
+PROGS+=			h_thread_local_dtor
+LDADD.h_thread_local_dtor=	-Wl,-rpath,${TESTSDIR}  -lpthread
+
 PROGS+=			h_ifunc
 SRCS.h_ifunc=		h_ifunc.c
 IFUNCDIR!=		cd ${.CURDIR}/helper_ifunc_dso && ${PRINTOBJDIR}

Added files:

Index: src/lib/libc/include/atexit.h
diff -u /dev/null src/lib/libc/include/atexit.h:1.2.2.2
--- /dev/null	Tue Aug 29 09:43:21 2017
+++ src/lib/libc/include/atexit.h	Tue Aug 29 09:43:18 2017
@@ -0,0 +1,41 @@
+/*	$NetBSD: atexit.h,v 1.2.2.2 2017/08/29 09:43:18 bouyer Exp $	*/
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdbool.h>
+
+int	__cxa_atexit(void (*)(void *), void *, void *);
+void	__cxa_finalize(void *);
+void	__cxa_thread_run_atexit(void);
+int	__cxa_thread_atexit(void (*)(void *), void *, void *);
+
+#ifdef _LIBC
+extern __dso_hidden bool __cxa_thread_atexit_used;
+#endif

Index: src/lib/libc/stdlib/cxa_thread_atexit.c
diff -u /dev/null src/lib/libc/stdlib/cxa_thread_atexit.c:1.1.4.2
--- /dev/null	Tue Aug 29 09:43:21 2017
+++ src/lib/libc/stdlib/cxa_thread_atexit.c	Tue Aug 29 09:43:16 2017
@@ -0,0 +1,88 @@
+/* $NetBSD: cxa_thread_atexit.c,v 1.1.4.2 2017/08/29 09:43:16 bouyer Exp $ */
+
+/*-
+ * Copyright (c) 2017 Joerg Sonnenberger <jo...@netbsd.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: cxa_thread_atexit.c,v 1.1.4.2 2017/08/29 09:43:16 bouyer Exp $");
+
+#include <sys/queue.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+
+#include "atexit.h"
+
+__dso_hidden bool __cxa_thread_atexit_used;
+
+struct cxa_dtor {
+	SLIST_ENTRY(cxa_dtor) link;
+	void *dso_symbol;
+	void *obj;
+	void (*dtor)(void *);
+};
+
+/* Assumes NULL initialization. */
+static __thread SLIST_HEAD(, cxa_dtor) cxa_dtors = SLIST_HEAD_INITIALIZER(cxa_dstors);
+
+void
+__cxa_thread_run_atexit(void)
+{
+	struct cxa_dtor *entry;
+
+	while ((entry = SLIST_FIRST(&cxa_dtors)) != NULL) {
+		SLIST_REMOVE_HEAD(&cxa_dtors, link);
+		(*entry->dtor)(entry->obj);
+		if (entry->dso_symbol)
+			__dl_cxa_refcount(entry->dso_symbol, -1);
+		free(entry);
+	}
+}
+
+/*
+ * This dance is necessary since libstdc++ includes
+ * __cxa_thread_atexit unconditionally.
+ */
+__weak_alias(__cxa_thread_atexit, __cxa_thread_atexit_impl)
+int	__cxa_thread_atexit_impl(void (*)(void *), void *, void *);
+
+int
+__cxa_thread_atexit_impl(void (*dtor)(void *), void *obj, void *dso_symbol)
+{
+	struct cxa_dtor *entry;
+
+	__cxa_thread_atexit_used = true;
+
+	entry = malloc(sizeof(*entry));
+	if (entry == NULL)
+		return -1;
+	entry->dso_symbol = dso_symbol;
+	if (dso_symbol)
+		__dl_cxa_refcount(entry->dso_symbol, 1);
+	entry->obj = obj;
+	entry->dtor = dtor;
+	SLIST_INSERT_HEAD(&cxa_dtors, entry, link);
+	return 0;
+}

Index: src/tests/libexec/ld.elf_so/h_thread_local_dtor.c
diff -u /dev/null src/tests/libexec/ld.elf_so/h_thread_local_dtor.c:1.2.2.2
--- /dev/null	Tue Aug 29 09:43:21 2017
+++ src/tests/libexec/ld.elf_so/h_thread_local_dtor.c	Tue Aug 29 09:43:16 2017
@@ -0,0 +1,92 @@
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <dlfcn.h>
+#include <err.h>
+#include <pthread.h>
+#include <stdio.h>
+
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t cond1 = PTHREAD_COND_INITIALIZER;
+static pthread_cond_t cond2 = PTHREAD_COND_INITIALIZER;
+
+static void *
+thread_helper(void *arg)
+{
+	void (*testfunc)(void) = arg;
+	testfunc();
+
+	pthread_mutex_lock(&mutex);
+	pthread_cond_broadcast(&cond1);
+	pthread_mutex_unlock(&mutex);
+
+	pthread_mutex_lock(&mutex);
+	pthread_cond_wait(&cond2, &mutex);
+	pthread_mutex_unlock(&mutex);
+
+	return NULL;
+}
+
+int
+main(void)
+{
+	void *dso;
+	void (*testfunc)(void);
+	pthread_t thread;
+
+	dso = dlopen("libh_helper_dso3.so", RTLD_LAZY);
+	if (dso == NULL)
+		errx(1, "%s", dlerror());
+	testfunc = dlsym(dso, "testfunc");
+	if (testfunc == NULL)
+		errx(1, "%s", dlerror());
+
+	pthread_mutex_lock(&mutex);
+
+	if (pthread_create(&thread, NULL, thread_helper, testfunc))
+		err(1, "pthread_create");
+
+	pthread_cond_wait(&cond1, &mutex);
+	pthread_mutex_unlock(&mutex);
+
+	pthread_mutex_lock(&mutex);
+	pthread_cond_signal(&cond2);
+	pthread_mutex_unlock(&mutex);
+
+	printf("before dlclose\n");
+	dlclose(dso);
+	printf("after dlclose\n");
+	dso = dlopen("libh_helper_dso3.so", RTLD_LAZY);
+	if (dso == NULL)
+		errx(1, "%s", dlerror());
+	dlclose(dso);
+	if (pthread_join(thread, NULL))
+		err(1, "pthread_join");
+	return 0;
+}

Index: src/tests/libexec/ld.elf_so/t_thread_local_dtor.sh
diff -u /dev/null src/tests/libexec/ld.elf_so/t_thread_local_dtor.sh:1.1.4.2
--- /dev/null	Tue Aug 29 09:43:21 2017
+++ src/tests/libexec/ld.elf_so/t_thread_local_dtor.sh	Tue Aug 29 09:43:16 2017
@@ -0,0 +1,54 @@
+# $NetBSD: t_thread_local_dtor.sh,v 1.1.4.2 2017/08/29 09:43:16 bouyer Exp $
+#
+# Copyright (c) 2017 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+atf_test_case thread_local_dtor
+thread_local_dtor_head()
+{
+	atf_set "descr" "Checks dlclose vs thread_local"
+}
+thread_local_dtor_body()
+{
+	$(atf_get_srcdir)/h_thread_local_dtor >out \
+		|| atf_fail "h_thread_local_dtor failed, see output of the test for details"
+
+	cat >exp <<EOF
+in ctor: global_dtor
+in ctor: thread_local
+before dlclose
+after dlclose
+in dtor: thread_local
+in dtor: global_dtor
+EOF
+
+	diff -Nru exp out \
+		|| atf_fail "h_thread_local_dtor failed, see output of the test for details"
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case thread_local_dtor
+}

Index: src/tests/libexec/ld.elf_so/helper_dso3/Makefile
diff -u /dev/null src/tests/libexec/ld.elf_so/helper_dso3/Makefile:1.1.4.2
--- /dev/null	Tue Aug 29 09:43:21 2017
+++ src/tests/libexec/ld.elf_so/helper_dso3/Makefile	Tue Aug 29 09:43:19 2017
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1.4.2 2017/08/29 09:43:19 bouyer Exp $
+
+.include <bsd.own.mk>
+
+LIB=			h_helper_dso3
+LIBISCXX=	yes
+SRCS=			h_helper_dso3.cpp
+
+LIBDIR=		${TESTSBASE}/libexec/ld.elf_so
+SHLIBDIR=	${TESTSBASE}/libexec/ld.elf_so
+SHLIB_MAJOR=	1
+
+MKSTATICLIB=	no
+MKPROFILE=	no
+MKPICINSTALL=	no
+MKLINT=		no
+
+NOMAN=		# defined
+
+CXXFLAGS+=	-std=c++11
+
+.include <bsd.lib.mk>
Index: src/tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp
diff -u /dev/null src/tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp:1.1.4.2
--- /dev/null	Tue Aug 29 09:43:21 2017
+++ src/tests/libexec/ld.elf_so/helper_dso3/h_helper_dso3.cpp	Tue Aug 29 09:43:19 2017
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <cstdio>
+
+struct VerboseDestructor {
+  const char *identifier;
+  VerboseDestructor(const char *identifier_) : identifier(identifier_) {
+    printf("in ctor: %s\n", identifier);
+  }
+  ~VerboseDestructor() {
+    printf("in dtor: %s\n", identifier);
+  }
+};
+
+static VerboseDestructor global_dtor("global_dtor");
+
+extern "C" void testfunc(void) {
+  static thread_local VerboseDestructor tls_dtor("thread_local");
+}

Reply via email to