On 31.10.2017 15:04, Jakub Jelinek wrote: > On Tue, Oct 31, 2017 at 02:53:26PM +0100, Kamil Rytarowski wrote: >>>> http://netbsd.org/~kamil/gcc/test_summary.log.8-20171022.txt >>> >>> That seems that asan pretty much doesn't work at all in GCC for netbsd. >>> A few FAILs might be acceptable, but so many FAILs certainly aren't. >>> The testsuite doesn't use python, at least not for *san testing nor >>> test_summary, so that shouldn't be the problem. If it is asan/ubsan tests >>> that are hanging, that is something that needs to be debugged and understood >>> why it hangs. >>> >> >> It is similar in LLVM, where it works against statically linked .a files >> with sanitizers. For .so, I can observe similar information about >> DEADLYSIGNAL without detailed information. > > But dynamic linking of libasan or libubsan is the default in gcc, so > it needs to work out of the box. > Note gcc/config/gnu-user.h has: > /* Link -lasan early on the command line. For -static-libasan, don't link > it for -shared link, the executable should be compiled with -static-libasan > in that case, and for executable link with --{,no-}whole-archive around > it to force everything into the executable. And similarly for -ltsan > and -llsan. */ > #if defined(HAVE_LD_STATIC_DYNAMIC) > #undef LIBASAN_EARLY_SPEC > #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \ > "%{static-libasan:%{!shared:" \ > LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \ > LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}" > #undef LIBTSAN_EARLY_SPEC > #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \ > "%{static-libtsan:%{!shared:" \ > LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \ > LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}" > #undef LIBLSAN_EARLY_SPEC > #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \ > "%{static-liblsan:%{!shared:" \ > LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \ > LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}" > #endif > > which might need to be duplicated into gcc/config/netbsd-elf.h. > > Jakub >
I'm giving it a try. I took the asan part and skipped "%{!shared:libasan_preinit%O%s} ". If I understand this correctly, it attempts to use the ELF section with preinit property in order to bootstrap asan quickly. The preinit sections are not enabled on NetBSD/amd64. From my understanding, there is a design choice in NetBSD to not include extensional sections unless they are requested by ABI. $NetBSD$ --- ./gcc/config/netbsd-elf.h.orig 2017-01-01 12:07:43.000000000 +0000 +++ ./gcc/config/netbsd-elf.h @@ -85,3 +85,16 @@ along with GCC; see the file COPYING3. #ifdef HAVE_LD_AS_NEEDED #define USE_LD_AS_NEEDED 1 #endif + +/* Link -lasan early on the command line. For -static-libasan, don't link + it for -shared link, the executable should be compiled with -static-libasan + in that case, and for executable link with --{,no-}whole-archive around + it to force everything into the executable. And similarly for -ltsan + and -llsan. */ +#if defined(HAVE_LD_STATIC_DYNAMIC) +#undef LIBASAN_EARLY_SPEC +#define LIBASAN_EARLY_SPEC \ + "%{static-libasan:%{!shared:" \ + LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \ + LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}" +#endif
signature.asc
Description: OpenPGP digital signature