From 55352cac7adcd70c663192f706102adc4472fb2c Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Sun, 7 Aug 2022 12:09:19 -0700 Subject: [PATCH 1/8] Add address sanitizer flags --- .../tests/vc2010/test_config_props.lua | 68 ++++++++++++++++++- modules/vstudio/vs2010_vcxproj.lua | 12 ++++ src/_premake_init.lua | 2 + src/tools/gcc.lua | 1 + src/tools/msc.lua | 4 ++ tests/tools/test_gcc.lua | 10 ++- tests/tools/test_msc.lua | 18 ++++- website/docs/flags.md | 2 + 8 files changed, 111 insertions(+), 6 deletions(-) diff --git a/modules/vstudio/tests/vc2010/test_config_props.lua b/modules/vstudio/tests/vc2010/test_config_props.lua index 5cc90417..cd91b1b8 100644 --- a/modules/vstudio/tests/vc2010/test_config_props.lua +++ b/modules/vstudio/tests/vc2010/test_config_props.lua @@ -156,7 +156,7 @@ Pure ]] end - + function suite.clrSupport_onClrNetCore() clr "NetCore" prepare() @@ -353,3 +353,69 @@ ]] end + +-- +-- If the AddressSanitizer flag is set, add the EnableASAN element. +-- + +function suite.onAddressSanitizer() + p.action.set("vs2022") + flags "AddressSanitizer" + prepare() + test.capture [[ + + Application + false + Unicode + v143 + true + + ]] +end + +function suite.onAddressSanitizer_BeforeVS2022() + p.action.set("vs2019") + flags "AddressSanitizer" + prepare() + test.capture [[ + + Application + false + Unicode + v142 + + ]] +end + +-- +-- If the Fuzzer flag is set, add the EnableFuzzer element. +-- + +function suite.onFuzzer() + p.action.set("vs2022") + flags "Fuzzer" + prepare() + test.capture [[ + + Application + false + Unicode + v143 + true + + ]] +end + +function suite.onFuzzer_BeforeVS2022() + p.action.set("vs2019") + flags "Fuzzer" + prepare() + test.capture [[ + + Application + false + Unicode + v142 + + ]] +end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index d38ccdb3..65f9990f 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -195,6 +195,7 @@ m.clrSupport, m.characterSet, m.platformToolset, + m.sanitizers, m.toolsVersion, m.wholeProgramOptimization, m.nmakeOutDirs, @@ -2507,6 +2508,17 @@ end end + function m.sanitizers(cfg) + if _ACTION >= "vs2022" then + if cfg.flags.AddressSanitizer then + m.element("EnableASAN", nil, "true") + end + if cfg.flags.Fuzzer then + m.element("EnableFuzzer", nil, "true") + end + end + end + function m.precompiledHeaderFile(fileName, cfg) m.element("PrecompiledHeaderFile", nil, "%s", fileName) end diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 3eac1fc1..06abc43d 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -489,6 +489,7 @@ scope = "config", kind = "list:string", allowed = { + "AddressSanitizer", "Component", -- DEPRECATED "DebugEnvsDontMerge", "DebugEnvsInherit", @@ -500,6 +501,7 @@ "FatalLinkWarnings", "FloatFast", -- DEPRECATED "FloatStrict", -- DEPRECATED + "Fuzzer", -- Visual Studio 2022+ only "LinkTimeOptimization", "Managed", -- DEPRECATED "Maps", diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 5f2080fa..46220eb5 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -203,6 +203,7 @@ Off = "-fno-exceptions" }, flags = { + AddressSanitizer = "-fsanitize=address", NoBufferSecurityCheck = "-fno-stack-protector", }, cppdialect = { diff --git a/src/tools/msc.lua b/src/tools/msc.lua index e8046070..f5543d27 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -154,6 +154,10 @@ -- msc.cxxflags = { + flags = { + AddressSanitizer = "/fsanitize=address", + Fuzzer = "/fsanitize=fuzzer", + }, exceptionhandling = { Default = "/EHsc", On = "/EHsc", diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index eff4056a..81a8e6bd 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -356,18 +356,24 @@ -- Check the translation of CXXFLAGS. -- - function suite.cflags_onNoExceptions() + function suite.cxxflags_onNoExceptions() exceptionhandling "Off" prepare() test.contains({ "-fno-exceptions" }, gcc.getcxxflags(cfg)) end - function suite.cflags_onNoBufferSecurityCheck() + function suite.cxxflags_onNoBufferSecurityCheck() flags { "NoBufferSecurityCheck" } prepare() test.contains({ "-fno-stack-protector" }, gcc.getcxxflags(cfg)) end + function suite.cxxflags_onAddressSanitizer() + flags { "AddressSanitizer" } + prepare() + test.contains({ "-fsanitize=address" }, gcc.getcxxflags(cfg)) + end + -- -- Check the basic translation of LDFLAGS for a Posix system. -- diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 56bf1824..79190b75 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -441,6 +441,18 @@ test.contains("/GR-", msc.getcxxflags(cfg)) end + function suite.cxxflags_onAddressSanitizer() + flags { "AddressSanitizer" } + prepare() + test.contains("/fsanitize=address", msc.getcxxflags(cfg)) + end + + function suite.cxxflags_onFuzzer() + flags { "Fuzzer" } + prepare() + test.contains("/fsanitize=fuzzer", msc.getcxxflags(cfg)) + end + -- -- Check handling of additional linker options. @@ -573,9 +585,9 @@ end - -- - -- Check handling of Run-Time Library flags. - -- +-- +-- Check handling of Run-Time Library flags. +-- function suite.cflags_onStaticRuntime() staticruntime "On" diff --git a/website/docs/flags.md b/website/docs/flags.md index b002eee5..daae9da7 100644 --- a/website/docs/flags.md +++ b/website/docs/flags.md @@ -10,6 +10,8 @@ flags { "flag_list" } | Flag | Description | Notes | |-----------------------|---------------------------------------------------------------------|----------------| +| AddressSanitizer | Enables compiler support for AddressSanitizer. | Visual Studio support starts with 2022. | +| Fuzzer | Enables support for LibFuzzer, a coverage-guided fuzzing library. | Visual Studio 2022+ only. | | ExcludeFromBuild | Exclude a source code file from the build, for the current configuration. | | FatalCompileWarnings | Treat compiler warnings as errors. | | FatalLinkWarnings | Treat linker warnings as errors. | From 7cfc60e7151723dd20c322d5f25aca4ee7b1960f Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Mon, 8 Aug 2022 07:29:49 -0700 Subject: [PATCH 2/8] Rewrite to a new API --- .../tests/vc2010/test_config_props.lua | 38 ++++++++++++------- modules/vstudio/vs2010_vcxproj.lua | 6 +-- src/_premake_init.lua | 14 +++++-- src/tools/gcc.lua | 4 +- src/tools/msc.lua | 8 ++-- tests/tools/test_gcc.lua | 4 +- tests/tools/test_msc.lua | 15 ++++++-- website/docs/Project-API.md | 1 + website/docs/flags.md | 2 - website/docs/sanitize.md | 28 ++++++++++++++ 10 files changed, 88 insertions(+), 32 deletions(-) create mode 100644 website/docs/sanitize.md diff --git a/modules/vstudio/tests/vc2010/test_config_props.lua b/modules/vstudio/tests/vc2010/test_config_props.lua index cd91b1b8..35732e73 100644 --- a/modules/vstudio/tests/vc2010/test_config_props.lua +++ b/modules/vstudio/tests/vc2010/test_config_props.lua @@ -355,12 +355,12 @@ end -- --- If the AddressSanitizer flag is set, add the EnableASAN element. +-- If the sanitizer flags are set, add the correct elements. -- -function suite.onAddressSanitizer() +function suite.onSanitizeAddress() p.action.set("vs2022") - flags "AddressSanitizer" + sanitize { "Address" } prepare() test.capture [[ @@ -373,9 +373,9 @@ function suite.onAddressSanitizer() ]] end -function suite.onAddressSanitizer_BeforeVS2022() +function suite.onSanitizeAddress_BeforeVS2022() p.action.set("vs2019") - flags "AddressSanitizer" + sanitize { "Address" } prepare() test.capture [[ @@ -387,13 +387,9 @@ function suite.onAddressSanitizer_BeforeVS2022() ]] end --- --- If the Fuzzer flag is set, add the EnableFuzzer element. --- - -function suite.onFuzzer() +function suite.onSanitizeFuzzer() p.action.set("vs2022") - flags "Fuzzer" + sanitize { "Fuzzer" } prepare() test.capture [[ @@ -406,9 +402,9 @@ function suite.onFuzzer() ]] end -function suite.onFuzzer_BeforeVS2022() +function suite.onSanitizeFuzzer_BeforeVS2022() p.action.set("vs2019") - flags "Fuzzer" + sanitize { "Fuzzer" } prepare() test.capture [[ @@ -419,3 +415,19 @@ function suite.onFuzzer_BeforeVS2022() ]] end + +function suite.onSanitizeAddressFuzzer() + p.action.set("vs2022") + sanitize { "Address", "Fuzzer" } + prepare() + test.capture [[ + + Application + false + Unicode + v143 + true + true + + ]] +end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 65f9990f..ef09e59e 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2509,11 +2509,11 @@ end function m.sanitizers(cfg) - if _ACTION >= "vs2022" then - if cfg.flags.AddressSanitizer then + if _ACTION >= "vs2022" and cfg.sanitize then + if table.contains(cfg.sanitize, "Address") then m.element("EnableASAN", nil, "true") end - if cfg.flags.Fuzzer then + if table.contains(cfg.sanitize, "Fuzzer") then m.element("EnableFuzzer", nil, "true") end end diff --git a/src/_premake_init.lua b/src/_premake_init.lua index 06abc43d..6055eefb 100644 --- a/src/_premake_init.lua +++ b/src/_premake_init.lua @@ -190,7 +190,7 @@ "HeaderUnit" } } - + api.register { name = "allmodulespublic", scope = "config", @@ -489,7 +489,6 @@ scope = "config", kind = "list:string", allowed = { - "AddressSanitizer", "Component", -- DEPRECATED "DebugEnvsDontMerge", "DebugEnvsInherit", @@ -501,7 +500,6 @@ "FatalLinkWarnings", "FloatFast", -- DEPRECATED "FloatStrict", -- DEPRECATED - "Fuzzer", -- Visual Studio 2022+ only "LinkTimeOptimization", "Managed", -- DEPRECATED "Maps", @@ -1120,6 +1118,16 @@ kind = "list:string", } + api.register { + name = "sanitize", + scope = "config", + kind = "list:string", + allowed = { + "Address", + "Fuzzer", -- Visual Studio 2022+ only + } + } + api.register { name = "startproject", scope = "workspace", diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index 46220eb5..3aca52b2 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -203,7 +203,6 @@ Off = "-fno-exceptions" }, flags = { - AddressSanitizer = "-fsanitize=address", NoBufferSecurityCheck = "-fno-stack-protector", }, cppdialect = { @@ -230,6 +229,9 @@ rtti = { Off = "-fno-rtti" }, + sanitize = { + Address = "-fsanitize=address", + }, visibility = { Default = "-fvisibility=default", Hidden = "-fvisibility=hidden", diff --git a/src/tools/msc.lua b/src/tools/msc.lua index f5543d27..efff2740 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -154,10 +154,6 @@ -- msc.cxxflags = { - flags = { - AddressSanitizer = "/fsanitize=address", - Fuzzer = "/fsanitize=fuzzer", - }, exceptionhandling = { Default = "/EHsc", On = "/EHsc", @@ -165,6 +161,10 @@ }, rtti = { Off = "/GR-" + }, + sanitize = { + Address = "/fsanitize=address", + Fuzzer = "/fsanitize=fuzzer", } } diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index 81a8e6bd..94b50d23 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -368,8 +368,8 @@ test.contains({ "-fno-stack-protector" }, gcc.getcxxflags(cfg)) end - function suite.cxxflags_onAddressSanitizer() - flags { "AddressSanitizer" } + function suite.cxxflags_onSanitizeAddress() + sanitize { "Address" } prepare() test.contains({ "-fsanitize=address" }, gcc.getcxxflags(cfg)) end diff --git a/tests/tools/test_msc.lua b/tests/tools/test_msc.lua index 79190b75..e6e6f11a 100644 --- a/tests/tools/test_msc.lua +++ b/tests/tools/test_msc.lua @@ -441,18 +441,25 @@ test.contains("/GR-", msc.getcxxflags(cfg)) end - function suite.cxxflags_onAddressSanitizer() - flags { "AddressSanitizer" } + function suite.cxxflags_onSanitizeAddress() + sanitize { "Address" } prepare() test.contains("/fsanitize=address", msc.getcxxflags(cfg)) end - function suite.cxxflags_onFuzzer() - flags { "Fuzzer" } + function suite.cxxflags_onSanitizeFuzzer() + sanitize { "Fuzzer" } prepare() test.contains("/fsanitize=fuzzer", msc.getcxxflags(cfg)) end + function suite.cxxflags_onSanitizeAddressFuzzer() + sanitize { "Address", "Fuzzer" } + prepare() + test.contains("/fsanitize=address", msc.getcxxflags(cfg)) + test.contains("/fsanitize=fuzzer", msc.getcxxflags(cfg)) + end + -- -- Check handling of additional linker options. diff --git a/website/docs/Project-API.md b/website/docs/Project-API.md index 4ca4bb4a..2b456fd5 100644 --- a/website/docs/Project-API.md +++ b/website/docs/Project-API.md @@ -150,6 +150,7 @@ | [rule](rule.md) | | | [rules](rules.md) | | | [runtime](runtime.md) | | +| [sanitize](sanitize.md) | Enable `fsanitize` compiler options | | [sharedlibtype](sharedlibtype.md) | | | [startproject](startproject.md) | | | [strictaliasing](strictaliasing.md) | | diff --git a/website/docs/flags.md b/website/docs/flags.md index daae9da7..b002eee5 100644 --- a/website/docs/flags.md +++ b/website/docs/flags.md @@ -10,8 +10,6 @@ flags { "flag_list" } | Flag | Description | Notes | |-----------------------|---------------------------------------------------------------------|----------------| -| AddressSanitizer | Enables compiler support for AddressSanitizer. | Visual Studio support starts with 2022. | -| Fuzzer | Enables support for LibFuzzer, a coverage-guided fuzzing library. | Visual Studio 2022+ only. | | ExcludeFromBuild | Exclude a source code file from the build, for the current configuration. | | FatalCompileWarnings | Treat compiler warnings as errors. | | FatalLinkWarnings | Treat linker warnings as errors. | diff --git a/website/docs/sanitize.md b/website/docs/sanitize.md new file mode 100644 index 00000000..966f0bed --- /dev/null +++ b/website/docs/sanitize.md @@ -0,0 +1,28 @@ +Enables various `fsanitize` options for compilers. + +```lua +sanitize { "value_list" } +``` + +### Parameters ### + +`value_list` specifies the desired `fsanitize` options to enable. + +| Value | Description | +|-------------|--------------------------------------------------------| +| Address | Enables compiler support for AddressSanitizer. | Visual Studio support starts with 2022. | +| Fuzzer | Enables support for LibFuzzer, a coverage-guided fuzzing library. | Visual Studio 2022+ only. | + +### Applies To ### + +Project configurations. + +### Availability ### + +Premake 5.0 or later. + +### Examples ### + +```lua +sanitize { "Address", "Fuzzer" } +``` From 30409ca3582c9e901db263d7f2630f50dd42f4c0 Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Tue, 23 Aug 2022 10:24:12 -0700 Subject: [PATCH 3/8] Add Fuzzer for clang --- src/tools/clang.lua | 3 +++ tests/tools/test_clang.lua | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 104f3f1e..a9e2da54 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -115,6 +115,9 @@ -- clang.cxxflags = table.merge(gcc.cxxflags, { + sanitize = { + Fuzzer = "-fsanitize=fuzzer", + }, }) function clang.getcxxflags(cfg) diff --git a/tests/tools/test_clang.lua b/tests/tools/test_clang.lua index 162e2720..08be4489 100644 --- a/tests/tools/test_clang.lua +++ b/tests/tools/test_clang.lua @@ -37,7 +37,7 @@ prepare() test.contains({ "-mmacosx-version-min=10.9" }, clang.getcflags(cfg)) end - + function suite.cxxflags_macosx_systemversion() system "MacOSX" systemversion "10.9" @@ -50,7 +50,7 @@ prepare() test.excludes({ "-mmacosx-version-min=10.9" }, clang.getcxxflags(cfg)) end - + -- -- Check iOS deployment target flags -- @@ -61,7 +61,7 @@ prepare() test.contains({ "-miphoneos-version-min=12.1" }, clang.getcflags(cfg)) end - + function suite.cxxflags_ios_systemversion() system "iOS" systemversion "5.0" @@ -85,3 +85,12 @@ test.excludes("-fopenmp", clang.getcflags(cfg)) end +-- +-- Check the translation of CXXFLAGS. +-- + +function suite.cxxflags_onSanitizeFuzzer() + sanitize { "Fuzzer" } + prepare() + test.contains({ "-fsanitize=fuzzer" }, gcc.getcxxflags(cfg)) +end From b51c82c0081ca425dcc32a283fe099ac95b3788a Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Tue, 23 Aug 2022 10:26:12 -0700 Subject: [PATCH 4/8] Update sanitize docs --- website/docs/sanitize.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/sanitize.md b/website/docs/sanitize.md index 966f0bed..65311813 100644 --- a/website/docs/sanitize.md +++ b/website/docs/sanitize.md @@ -11,7 +11,7 @@ sanitize { "value_list" } | Value | Description | |-------------|--------------------------------------------------------| | Address | Enables compiler support for AddressSanitizer. | Visual Studio support starts with 2022. | -| Fuzzer | Enables support for LibFuzzer, a coverage-guided fuzzing library. | Visual Studio 2022+ only. | +| Fuzzer | Enables support for LibFuzzer, a coverage-guided fuzzing library. | Visual Studio 2022+ & Clang only. | ### Applies To ### From 9befc96f88c89778ad863026ac9dfa790ddfed0c Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Tue, 23 Aug 2022 10:29:26 -0700 Subject: [PATCH 5/8] Fix typo in tests --- tests/tools/test_clang.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tools/test_clang.lua b/tests/tools/test_clang.lua index 08be4489..e26430ed 100644 --- a/tests/tools/test_clang.lua +++ b/tests/tools/test_clang.lua @@ -92,5 +92,5 @@ function suite.cxxflags_onSanitizeFuzzer() sanitize { "Fuzzer" } prepare() - test.contains({ "-fsanitize=fuzzer" }, gcc.getcxxflags(cfg)) + test.contains({ "-fsanitize=fuzzer" }, clang.getcxxflags(cfg)) end From 519e6a99fef67d4ef65ea025f3d29ff3490e3414 Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Tue, 23 Aug 2022 10:32:33 -0700 Subject: [PATCH 6/8] Allow sanitize{} for VS2019 --- .../tests/vc2010/test_config_props.lua | 44 +++++++++---------- modules/vstudio/vs2010_vcxproj.lua | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/modules/vstudio/tests/vc2010/test_config_props.lua b/modules/vstudio/tests/vc2010/test_config_props.lua index 35732e73..45cbc6ba 100644 --- a/modules/vstudio/tests/vc2010/test_config_props.lua +++ b/modules/vstudio/tests/vc2010/test_config_props.lua @@ -359,7 +359,7 @@ -- function suite.onSanitizeAddress() - p.action.set("vs2022") + p.action.set("vs2019") sanitize { "Address" } prepare() test.capture [[ @@ -367,14 +367,14 @@ function suite.onSanitizeAddress() Application false Unicode - v143 + v142 true ]] end -function suite.onSanitizeAddress_BeforeVS2022() - p.action.set("vs2019") +function suite.onSanitizeAddress_BeforeVS2019() + p.action.set("vs2017") sanitize { "Address" } prepare() test.capture [[ @@ -382,27 +382,12 @@ function suite.onSanitizeAddress_BeforeVS2022() Application false Unicode - v142 + v141 ]] end function suite.onSanitizeFuzzer() - p.action.set("vs2022") - sanitize { "Fuzzer" } - prepare() - test.capture [[ - - Application - false - Unicode - v143 - true - - ]] -end - -function suite.onSanitizeFuzzer_BeforeVS2022() p.action.set("vs2019") sanitize { "Fuzzer" } prepare() @@ -412,12 +397,27 @@ function suite.onSanitizeFuzzer_BeforeVS2022() false Unicode v142 + true + + ]] +end + +function suite.onSanitizeFuzzer_BeforeVS2019() + p.action.set("vs2017") + sanitize { "Fuzzer" } + prepare() + test.capture [[ + + Application + false + Unicode + v141 ]] end function suite.onSanitizeAddressFuzzer() - p.action.set("vs2022") + p.action.set("vs2019") sanitize { "Address", "Fuzzer" } prepare() test.capture [[ @@ -425,7 +425,7 @@ function suite.onSanitizeAddressFuzzer() Application false Unicode - v143 + v142 true true diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index ef09e59e..0ee0d6eb 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2509,7 +2509,7 @@ end function m.sanitizers(cfg) - if _ACTION >= "vs2022" and cfg.sanitize then + if _ACTION >= "vs2019" and cfg.sanitize then if table.contains(cfg.sanitize, "Address") then m.element("EnableASAN", nil, "true") end From b7ad535fc9647f48230f31ad5dd489fde364e050 Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Tue, 23 Aug 2022 10:40:04 -0700 Subject: [PATCH 7/8] Correct versions for sanitize docs --- website/docs/sanitize.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/sanitize.md b/website/docs/sanitize.md index 65311813..a2f3895d 100644 --- a/website/docs/sanitize.md +++ b/website/docs/sanitize.md @@ -10,8 +10,8 @@ sanitize { "value_list" } | Value | Description | |-------------|--------------------------------------------------------| -| Address | Enables compiler support for AddressSanitizer. | Visual Studio support starts with 2022. | -| Fuzzer | Enables support for LibFuzzer, a coverage-guided fuzzing library. | Visual Studio 2022+ & Clang only. | +| Address | Enables compiler support for AddressSanitizer. | Visual Studio support starts with 2019 16.9 | +| Fuzzer | Enables support for LibFuzzer, a coverage-guided fuzzing library. | Visual Studio support starts with 2019 16.9 | ### Applies To ### From e4f8448719050bc6193ef07fd2d26ff56cbd8e67 Mon Sep 17 00:00:00 2001 From: Chad Engler Date: Tue, 23 Aug 2022 11:13:17 -0700 Subject: [PATCH 8/8] asan = 2019; fuzzer = 2022 --- .../tests/vc2010/test_config_props.lua | 29 ++++++++++++++----- modules/vstudio/vs2010_vcxproj.lua | 2 ++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/modules/vstudio/tests/vc2010/test_config_props.lua b/modules/vstudio/tests/vc2010/test_config_props.lua index 45cbc6ba..78f0c71e 100644 --- a/modules/vstudio/tests/vc2010/test_config_props.lua +++ b/modules/vstudio/tests/vc2010/test_config_props.lua @@ -388,6 +388,21 @@ function suite.onSanitizeAddress_BeforeVS2019() end function suite.onSanitizeFuzzer() + p.action.set("vs2022") + sanitize { "Fuzzer" } + prepare() + test.capture [[ + + Application + false + Unicode + v143 + true + + ]] +end + +function suite.onSanitizeFuzzer_BeforeVS2022() p.action.set("vs2019") sanitize { "Fuzzer" } prepare() @@ -397,26 +412,27 @@ function suite.onSanitizeFuzzer() false Unicode v142 - true ]] end -function suite.onSanitizeFuzzer_BeforeVS2019() - p.action.set("vs2017") - sanitize { "Fuzzer" } +function suite.onSanitizeAddressFuzzer() + p.action.set("vs2022") + sanitize { "Address", "Fuzzer" } prepare() test.capture [[ Application false Unicode - v141 + v143 + true + true ]] end -function suite.onSanitizeAddressFuzzer() +function suite.onSanitizeAddressFuzzer_BeforeVS2022() p.action.set("vs2019") sanitize { "Address", "Fuzzer" } prepare() @@ -427,7 +443,6 @@ function suite.onSanitizeAddressFuzzer() Unicode v142 true - true ]] end diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 0ee0d6eb..fe84c4f3 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2513,6 +2513,8 @@ if table.contains(cfg.sanitize, "Address") then m.element("EnableASAN", nil, "true") end + end + if _ACTION >= "vs2022" and cfg.sanitize then if table.contains(cfg.sanitize, "Fuzzer") then m.element("EnableFuzzer", nil, "true") end