From d001c81fee5167340bfc7e46ca5701626bd2786e Mon Sep 17 00:00:00 2001 From: "Michael G. Kazakov" Date: Tue, 17 Nov 2020 11:51:34 +0000 Subject: [PATCH] moved ASAN-related definitions under a version check --- src/tools/msvc.jam | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/tools/msvc.jam b/src/tools/msvc.jam index 260024d10..21011952c 100644 --- a/src/tools/msvc.jam +++ b/src/tools/msvc.jam @@ -485,6 +485,29 @@ rule configure-version-specific ( toolset : version : conditions ) toolset.flags $(toolset).compile CFLAGS $(conditions) : "/Zc:throwingNew" ; } + # 14.27 (VS2019 Version 16.7) introduced support for ASAN on x86 and x64 CPUs + # 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 ; + + # 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" ; + } + # # Processor-specific optimization. # @@ -1881,10 +1904,6 @@ local rule register-toolset-really ( ) toolset.flags msvc.compile INCLUDES ; toolset.flags msvc.compile FORCE_INCLUDES ; - # 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 ; - # Declare flags for the assembler. toolset.flags msvc.compile.asm USER_ASMFLAGS ; @@ -1923,20 +1942,6 @@ local rule register-toolset-really ( ) toolset.flags msvc.link LIBRARIES_MENTIONED_BY_FILE : ; toolset.flags msvc.link.dll LINKFLAGS true : /NOENTRY ; - - # 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" ; } toolset.flags msvc.archive AROPTIONS ;