Add Undefined Sanitizer support
authorCharles Giessen <charles@lunarg.com>
Mon, 20 Nov 2023 21:34:46 +0000 (14:34 -0700)
committerCharles Giessen <46324611+charles-lunarg@users.noreply.github.com>
Tue, 21 Nov 2023 18:16:11 +0000 (11:16 -0700)
Allows easy enabling of UBSAN.

Fixes one issue found with UBSAN in the tests.

loader/CMakeLists.txt
tests/framework/CMakeLists.txt
tests/loader_version_tests.cpp

index 3ae4059799476e288b938ec5cf85bf37370c7307..8a8eee6cb013e5d7c90b44e5c0f6fc5cdde5f34a 100644 (file)
@@ -380,6 +380,10 @@ else()
         target_compile_options(vulkan PUBLIC -fsanitize=thread)
         target_link_options(vulkan PUBLIC -fsanitize=thread)
     endif()
+    if (LOADER_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER)
+        target_compile_options(vulkan PUBLIC -fsanitize=undefined)
+        target_link_options(vulkan PUBLIC -fsanitize=undefined)
+    endif()
 
     if(APPLE)
         find_library(COREFOUNDATION_LIBRARY NAMES CoreFoundation)
index 71312997676acca578c013c4f0ab034d83d488bd..de2229d133c8094fd9f3cf226609692ee3cdfb2d 100644 (file)
@@ -40,6 +40,10 @@ if (UNIX)
         target_compile_options(gtest PUBLIC -fsanitize=thread)
         target_link_options(gtest PUBLIC -fsanitize=thread)
     endif()
+    if (LOADER_ENABLE_UNDEFINED_BEHAVIOR_SANITIZER)
+        target_compile_options(testing_framework_util PUBLIC -fsanitize=undefined)
+        target_link_options(testing_framework_util PUBLIC -fsanitize=undefined)
+    endif()
 endif()
 
 if (MSVC)
index 28191fc38daeb94e81cd5ba90986bb70f9560a40..8307995acb2085299e8b7e387eb34adfbf8f3011 100644 (file)
@@ -545,7 +545,7 @@ TEST(MultipleICDConfig, version_5_and_version_6) {
 
 // shim function pointers for 1.3
 // Should use autogen for this - it generates 'shim' functions for validation layers, maybe that could be used here.
-void test_vkCmdBeginRendering(VkCommandBuffer, const VkRenderPassBeginInfo*, VkSubpassContents) {}
+void test_vkCmdBeginRendering(VkCommandBuffer, const VkRenderingInfo*) {}
 void test_vkCmdBindVertexBuffers2(VkCommandBuffer, uint32_t, uint32_t, const VkBuffer*, const VkDeviceSize*, const VkDeviceSize*,
                                   const VkDeviceSize*) {}
 void test_vkCmdBlitImage2(VkCommandBuffer, const VkBlitImageInfo2*) {}