From f694f2eeddb3a0523b277a015d96c4a2eef6fd02 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 26 Dec 2020 23:21:47 -0600 Subject: [PATCH] Adjust new asan support. The proposed asan support didn't fit into the regular msvc init structure. This fixes that aspect and cleans up the support to correctly be minimal and to add the missing runtime libs needed to actually enable the asan support. --- src/tools/msvc.jam | 80 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/src/tools/msvc.jam b/src/tools/msvc.jam index 9225597cf..fabe64f7c 100644 --- a/src/tools/msvc.jam +++ b/src/tools/msvc.jam @@ -489,23 +489,71 @@ rule configure-version-specific ( toolset : version : conditions ) # This check however now only tests for 14.2 (which is 16.0) as msvc.jam doesn't distinguish between minor versions (e.g. 14.21..14.28 etc) if ! [ version.version-less [ SPLIT_BY_CHARACTERS [ MATCH "^([0123456789.]+)" : $(version) ] : . ] : 14 2 ] { - # Declare flags for the address sanitizer. - toolset.flags msvc.compile.c OPTIONS on : /fsanitize=address /FS ; - toolset.flags msvc.compile.c++ OPTIONS on : /fsanitize=address /FS ; + # General asan compile and link options. + toolset.flags $(toolset).compile OPTIONS + $(conditions)/on + : /fsanitize=address /FS ; + toolset.flags $(toolset).link LINKFLAGS + $(conditions)/on + : -incremental\:no ; - # Declare flags for the address sanitizer. - toolset.flags msvc.link OPTIONS on/64/shared/EXE : -incremental\:no /wholearchive\:"clang_rt.asan_dynamic-x86_64.lib" /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" ; - toolset.flags msvc.link OPTIONS on/64/static/EXE : -incremental\:no /wholearchive\:"clang_rt.asan-x86_64.lib" /wholearchive\:"clang_rt.asan_cxx-x86_64.lib" ; - toolset.flags msvc.link OPTIONS on/32/shared/EXE : -incremental\:no /wholearchive\:"clang_rt.asan_dynamic-i386.lib" /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-i386.lib" ; - toolset.flags msvc.link OPTIONS on/32/static/EXE : -incremental\:no /wholearchive\:"clang_rt.asan-i386.lib" /wholearchive\:"clang_rt.asan_cxx-i386.lib" ; - toolset.flags msvc.link OPTIONS on/64/shared/UNIT_TEST : -incremental\:no /wholearchive\:"clang_rt.asan_dynamic-x86_64.lib" /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" ; - toolset.flags msvc.link OPTIONS on/64/static/UNIT_TEST : -incremental\:no /wholearchive\:"clang_rt.asan-x86_64.lib" /wholearchive\:"clang_rt.asan_cxx-x86_64.lib" ; - toolset.flags msvc.link OPTIONS on/32/shared/UNIT_TEST : -incremental\:no /wholearchive\:"clang_rt.asan_dynamic-i386.lib" /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-i386.lib" ; - toolset.flags msvc.link OPTIONS on/32/static/UNIT_TEST : -incremental\:no /wholearchive\:"clang_rt.asan-i386.lib" /wholearchive\:"clang_rt.asan_cxx-i386.lib" ; - toolset.flags msvc.link.dll OPTIONS on/64/shared : -incremental\:no /wholearchive\:"clang_rt.asan_dynamic-x86_64.lib" /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" ; - toolset.flags msvc.link.dll OPTIONS on/64/static : -incremental\:no /wholearchive\:"clang_rt.asan_dll_thunk-x86_64.lib" ; - toolset.flags msvc.link.dll OPTIONS on/32/shared : -incremental\:no /wholearchive\:"clang_rt.asan_dynamic-i386.lib" /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-i386.lib" ; - toolset.flags msvc.link.dll OPTIONS on/32/static : -incremental\:no /wholearchive\:"clang_rt.asan_dll_thunk-i386.lib" ; + # The various 64 bit runtime asan support libraries and related flags. + toolset.flags $(toolset).link FINDLIBS_SA + $(conditions)/on//shared + $(conditions)/on/64/shared + : clang_rt.asan_dynamic-x86_64 + clang_rt.asan_dynamic_runtime_thunk-x86_64 ; + toolset.flags $(toolset).link LINKFLAGS + $(conditions)/on//shared + $(conditions)/on/64/shared + : /wholearchive\:"clang_rt.asan_dynamic-x86_64.lib" + /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-x86_64.lib" ; + toolset.flags $(toolset).link FINDLIBS_SA + $(conditions)/on//static/EXE + $(conditions)/on//static/UNIT_TEST + $(conditions)/on/64/static/EXE + $(conditions)/on/64/static/UNIT_TEST + : clang_rt.asan-x86_64 + clang_rt.asan_cxx-x86_64 ; + toolset.flags $(toolset).link LINKFLAGS + $(conditions)/on//static/EXE + $(conditions)/on//static/UNIT_TEST + $(conditions)/on/64/static/EXE + $(conditions)/on/64/static/UNIT_TEST + : /wholearchive\:"clang_rt.asan-x86_64.lib" + /wholearchive\:"clang_rt.asan_cxx-x86_64.lib" ; + toolset.flags $(toolset).link.dll FINDLIBS_SA + $(conditions)/on//static + $(conditions)/on/64/static + : clang_rt.asan_dll_thunk-x86_64 ; + toolset.flags $(toolset).link.dll LINKFLAGS + $(conditions)/on//static + $(conditions)/on/64/static + : /wholearchive\:"clang_rt.asan_dll_thunk-x86_64.lib" ; + + # The various 32 bit runtime asan support libraries and related flags. + toolset.flags $(toolset).link FINDLIBS_SA + $(conditions)/on/32/shared + : clang_rt.asan_dynamic-i386 clang_rt.asan_dynamic_runtime_thunk-i386 ; + toolset.flags $(toolset).link LINKFLAGS + $(conditions)/on/32/shared + : /wholearchive\:"clang_rt.asan_dynamic-i386.lib" + /wholearchive\:"clang_rt.asan_dynamic_runtime_thunk-i386.lib" ; + toolset.flags $(toolset).link FINDLIBS_SA + $(conditions)/on/32/static/EXE + $(conditions)/on/32/static/UNIT_TEST + : clang_rt.asan-i386 clang_rt.asan_cxx-i386 ; + toolset.flags $(toolset).link LINKFLAGS + $(conditions)/on/32/static/EXE + $(conditions)/on/32/static/UNIT_TEST + : /wholearchive\:"clang_rt.asan-i386.lib" + /wholearchive\:"clang_rt.asan_cxx-i386.lib" ; + toolset.flags $(toolset).link.dll FINDLIBS_SA + $(conditions)/on/32/static/LIB/shared + : clang_rt.asan_dll_thunk-i386 ; + toolset.flags $(toolset).link.dll LINKFLAGS + $(conditions)/on/32/static/LIB/shared + : /wholearchive\:"clang_rt.asan_dll_thunk-i386.lib" ; } #